Tim Peters [Sat, 13 Apr 2002 08:29:14 +0000 (08:29 +0000)]
_PyObject_DebugDumpStats: renamed to _PyObject_DebugMallocStats.
Added code to call this when PYMALLOC_DEBUG is enabled, and envar
PYTHONMALLOCSTATS is set, whenever a new arena is obtained and once
late in the Python shutdown process.
Fred Drake [Fri, 12 Apr 2002 19:32:07 +0000 (19:32 +0000)]
Warn people away from PyModule_GetDict(), but not too strongly.
(The real issue is whether modules can benefit from an alternate
implementation strategy rather than using a dictionary. We should migrate
away from direct dictionary manipulation to allow more room for Jeremy to
flex the implementation with changes in globals lookup.)
Fred Drake [Fri, 12 Apr 2002 19:08:31 +0000 (19:08 +0000)]
Do not use PyModule_GetDict().
Clean up the example of exporting a C-callable API from an extension module.
Add a hyperlink to a related section in the Python/C API reference.
Fred Drake [Fri, 12 Apr 2002 19:04:17 +0000 (19:04 +0000)]
Change example of retrieving & calling a Python function to not use
PyModule_GetDict(), which is also more flexible: it does not assume that the
"module" is a real module.
but the output argument was omitted. This caused all tests to fail,
because the expected output was passed as the initial argument to the
method call. But because of the way the test works (it compares the
results for a regular string to the results for a UserString instance
with the same value, and it's OK if both raise the same exception) the
test never failed!
I've fixed this, and also cleaned up a few warts in the verbose
output. Finally, I've made it possible to run the test stand-alone in
verbose mode by passing -v as a command line argument.
Now, the test will report failure related to zfill. That's not my
fault, that's a legitimate problem: the string_tests.py file contains
a test for the zfill() method (just added) but this method is not
implemented. The responsible party will surely fix this soon now.
Tim Peters [Fri, 12 Apr 2002 08:52:50 +0000 (08:52 +0000)]
_PyObject_DebugRealloc(): rewritten to let the underlying realloc do
most of the work. In particular, if the underlying realloc is able to
grow the memory block in place, great (this routine used to do a fresh
malloc + memcpy every time a block grew). BTW, I'm not so keen here on
avoiding possible quadratic-time realloc patterns as I am on making
the debug pymalloc more invisible (the more it uses memory "just like"
the underlying allocator, the better the chance that a suspected memory
corruption bug won't vanish when the debug malloc is turned on).
Tim Peters [Fri, 12 Apr 2002 07:38:53 +0000 (07:38 +0000)]
PYMALLOC_{CLEAN, DEAD, FORBIDDEN}BYTE symbols: remove the PYMALLOC_
prefix. These symbols are private to the file, and the PYMALLOC_ gets
in the way (overly long code lines, comments, and error messages).
Tim Peters [Fri, 12 Apr 2002 07:22:56 +0000 (07:22 +0000)]
First stab at rationalizing the PyMem_ API. Mixing PyObject_xyz with
PyMem_{Del, DEL} doesn't work yet (compilation problems).
pyport.h: _PyMem_EXTRA is gone.
pmem.h: Repaired comments. PyMem_{Malloc, MALLOC} and
PyMem_{Realloc, REALLOC} now make the same x-platform guarantees when
asking for 0 bytes, and when passing a NULL pointer to the latter.
object.c: PyMem_{Malloc, Realloc} just call their macro versions
now, since the latter take care of the x-platform 0 and NULL stuff
by themselves now.
pypcre.c, grow_stack(): So sue me. On two lines, this called
PyMem_RESIZE to grow a "const" area. It's not legit to realloc a
const area, so the compiler warned given the new expansion of
PyMem_RESIZE. It would have gotten the same warning before if it
had used PyMem_Resize() instead; the older macro version, but not the
function version, silently cast away the constness. IMO that was a wrong
thing to do, and the docs say the macro versions of PyMem_xyz are
deprecated anyway. If somebody else is resizing const areas with the
macro spelling, they'll get a warning when they recompile now too.
Neil Schemenauer [Fri, 12 Apr 2002 03:10:20 +0000 (03:10 +0000)]
Move PyObject_Malloc and PyObject_Free here from object.c. Remove
PyMalloc_ prefix and use PyObject_ instead. I'm not sure about the
debugging functions. Perhaps they should stay as PyMalloc_.
At CNRI's request, I'm changing the status of 1.6.1 from
not-GPL-compatible to GPL-compatible, with a footnote explaining that
RMS disagrees. I'm not going to discuss this further -- both sides
(CNRI and RMS) will argue their POV till they're blue in the face.
Tim Peters [Thu, 11 Apr 2002 06:36:45 +0000 (06:36 +0000)]
SF bug 542181: Realloc behavior
The bug report pointed out a bogosity in the comment block explaining
thread safety for arena management. Repaired that comment, repaired a
couple others while I was at it, and added an assert.
_PyMalloc_DebugRealloc: If this needed to get more memory, but couldn't,
it erroneously freed the original memory. Repaired that.
This is for 2.3 only (unless we decide to backport the new pymalloc).
Barry Warsaw [Wed, 10 Apr 2002 21:01:31 +0000 (21:01 +0000)]
Sync'ing with standalone email package 2.0.1. This adds support for
non-us-ascii character sets in headers and bodies. Some API changes
(with DeprecationWarnings for the old APIs). Better RFC-compliant
implementations of base64 and quoted-printable.
Updated test cases. Documentation updates to follow (after I finish
writing them ;).
Fred Drake [Wed, 10 Apr 2002 04:20:33 +0000 (04:20 +0000)]
When adding a name to the table of macros and environments, make sure it
is not already present. If it is, raise an exception, since that should not
happen in a well-defined conversion.