Guido van Rossum [Thu, 28 Mar 2002 20:34:59 +0000 (20:34 +0000)]
This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction).
The fix makes it possible to call PyObject_GC_UnTrack() more than once
on the same object, and then move the PyObject_GC_UnTrack() call to
*before* the trashcan code is invoked.
Guido van Rossum [Thu, 28 Mar 2002 20:17:52 +0000 (20:17 +0000)]
Fix an issue that was reported in but unrelated to the main problem of
SF bug 535905 (Evil Trashcan and GC interaction).
The SETLOCAL() macro should not DECREF the local variable in-place and
then store the new value; it should copy the old value to a temporary
value, then store the new value, and then DECREF the temporary value.
This is because it is possible that during the DECREF the frame is
accessed by other code (e.g. a __del__ method or gc.collect()) and the
variable would be pointing to already-freed memory.
Tim Peters [Thu, 28 Mar 2002 07:32:11 +0000 (07:32 +0000)]
PYMALLOC_DEBUG routines: The "check API family" gimmick was going nowhere
fast, and just cluttered the code. Get rid of it for now. If a compelling
case can be made for it, easy to restore it later.
Fred Drake [Thu, 28 Mar 2002 05:33:33 +0000 (05:33 +0000)]
Introduce two new flag bits that can be set in a PyMethodDef method
descriptor, as used for the tp_methods slot of a type. These new flag
bits are both optional, and mutually exclusive. Most methods will not
use either. These flags are used to create special method types which
exist in the same namespace as normal methods without having to use
tedious construction code to insert the new special method objects in
the type's tp_dict after PyType_Ready() has been called.
If METH_CLASS is specified, the method will represent a class method
like that returned by the classmethod() built-in.
If METH_STATIC is specified, the method will represent a static method
like that returned by the staticmethod() built-in.
These flags may not be used in the PyMethodDef table for modules since
these special method types are not meaningful in that case; a
ValueError will be raised if these flags are found in that context.
Barry Warsaw [Tue, 26 Mar 2002 20:27:35 +0000 (20:27 +0000)]
__init__(): We'll try to be more RFC 2821 compliant by providing for a
better local_hostname default. According to RFC 2821, it is
recommended that the fqdn hostname be provided in the EHLO/HELO verb
and if that can't be calculated, to use a domain literal.
The rationale for this change is documented in SF patch #497736 which
also had privacy concerns about leaking the fqdn in the EHLO/HELO. We
decided this wasn't a big concern because no user data is leaked, and
the IP will always be leaked. The local_hostname argument is provided
for those clients that are super paranoid.
Using localhost.localdomain may break some strict smtp servers so we
decided against using it as the default.
Skip Montanaro [Mon, 25 Mar 2002 21:44:07 +0000 (21:44 +0000)]
remove unqualified excepts - catch ImportError when trying to import
readline and get rid of string exception fallback when showing syntax
errors.
see bug 411881
Jack Jansen [Mon, 25 Mar 2002 15:32:01 +0000 (15:32 +0000)]
Due to interaction between the MSL C library and the GUSI I/O library I can get reads from sockets to work consistently either for unbuffered binary files or for buffered binary files, but not for both:-(
The workaround is to force socket.makefile() to disable buffering for binary files.
Tim Peters [Mon, 25 Mar 2002 06:55:57 +0000 (06:55 +0000)]
Remove bug.py. This is something I sent to Guido via email in or before
'94, demonstrating a thread bug that was later repaired via Python growing
an internal import lock. It's of no current interest, and the now-std
test_threaded_import.py is pretty much the same test.
Jack Jansen [Mon, 25 Mar 2002 00:32:17 +0000 (00:32 +0000)]
Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception.
Jack Jansen [Sun, 24 Mar 2002 23:04:18 +0000 (23:04 +0000)]
Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception.
Should finally fix 531398. 2.2.1 candidate.
Also blacklisted some constants with definitions that were not Python-compatible.
Jack Jansen [Sun, 24 Mar 2002 22:59:16 +0000 (22:59 +0000)]
Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception.
Tim Peters [Sun, 24 Mar 2002 19:25:00 +0000 (19:25 +0000)]
SF bug 480215: softspace confused in nested print
This fixes the symptom, but PRINT_ITEM has no way to know what (if
anything) PyFile_WriteObject() writes unless the object being printed
is a string. When the object isn't a string, this fix retains the
guess that softspace should be set after PyFile_WriteObject().
We might want to say that it's the job of filelike-object write methods
to leave the file's softspace in the correct state. That would probably
be better -- but everyone relies on PRINT_ITEM to guess for them now.
Tim Peters [Sun, 24 Mar 2002 00:34:21 +0000 (00:34 +0000)]
_PyMalloc_DebugRealloc(): simplify decl of "fresh".
Assorted: bump the serial number via a trivial new bumpserialno()
function. The point is to give a single place to set a breakpoint when
waiting for a specific serial number.
Neil Schemenauer [Sat, 23 Mar 2002 19:41:34 +0000 (19:41 +0000)]
Grow the string buffer at a mildly exponential rate for the getc version
of get_line. This makes test_bufio finish in 1.7 seconds instead of 57
seconds on my machine (with Py_DEBUG defined).
Also, rename the local variables n1 and n2 to used_v_size and
total_v_size.
Tim Peters [Sat, 23 Mar 2002 10:03:50 +0000 (10:03 +0000)]
Give Python a debug-mode pymalloc, much as sketched on Python-Dev.
When WITH_PYMALLOC is defined, define PYMALLOC_DEBUG to enable the debug
allocator. This can be done independent of build type (release or debug).
A debug build automatically defines PYMALLOC_DEBUG when pymalloc is
enabled. It's a detected error to define PYMALLOC_DEBUG when pymalloc
isn't enabled.
Two debugging entry points defined only under PYMALLOC_DEBUG:
+ _PyMalloc_DebugCheckAddress(const void *p) can be used (e.g., from gdb)
to sanity-check a memory block obtained from pymalloc. It sprays
info to stderr (see next) and dies via Py_FatalError if the block is
detectably damaged.
+ _PyMalloc_DebugDumpAddress(const void *p) can be used to spray info
about a debug memory block to stderr.
A tiny start at implementing "API family" checks isn't good for
anything yet.
_PyMalloc_DebugRealloc() has been optimized to do little when the new
size is <= old size. However, if the new size is larger, it really
can't call the underlying realloc() routine without either violating its
contract, or knowing something non-trivial about how the underlying
realloc() works. A memcpy is always done in this case.
This was a disaster for (and only) one of the std tests: test_bufio
creates single text file lines up to a million characters long. On
Windows, fileobject.c's get_line() uses the horridly funky
getline_via_fgets(), which keeps growing and growing a string object
hoping to find a newline. It grew the string object 1000 bytes each
time, so for a million-character string it took approximately forever
(I gave up after a few minutes).
So, also:
fileobject.c, getline_via_fgets(): When a single line is outrageously
long, grow the string object at a mildly exponential rate, instead of
just 1000 bytes at a time.
That's enough so that a debug-build test_bufio finishes in about 5 seconds
on my Win98SE box. I'm curious to try this on Win2K, because it has very
different memory behavior than Win9X, and test_bufio always took a factor
of 10 longer to complete on Win2K. It *could* be that the endless
reallocs were simply killing it on Win2K even in the release build.
Skip Montanaro [Sat, 23 Mar 2002 05:58:52 +0000 (05:58 +0000)]
Only AttributeError can be raised in this situation - on systems without
getuid or getpid. posix_getuid & posix_getpid never raise exceptions when
called with no args.