Barry Warsaw [Mon, 15 Apr 2002 22:14:06 +0000 (22:14 +0000)]
test_main(): Added this so the test can actually get run under the
regrtest framework. Keep the original standalone-unittest
scaffolding (i.e. suite() and __main__).
Barry Warsaw [Mon, 15 Apr 2002 22:00:25 +0000 (22:00 +0000)]
parseaddr(): Don't use rfc822.parseaddr() because this now implies a
double call to AddressList.getaddrlist(), and /that/ always returns an
empty list for the second and subsequent calls.
Instead, instantiate an AddressList directly, and get the parsed
addresses out of the addresslist attribute.
Fred Drake [Mon, 15 Apr 2002 20:51:19 +0000 (20:51 +0000)]
Add documentation for PyObject_Call().
Note that PyObject_Size() is a synonym for PyObject_Length().
This closes SF patch #544330 (contributed by Thomas Heller).
Fred Drake [Mon, 15 Apr 2002 20:48:40 +0000 (20:48 +0000)]
Separate out a \cfuncline macro from the cfuncdesc environment.
This matches many other of the *desc environments, and is useful when
multiple functions share a description.
Barry Warsaw [Mon, 15 Apr 2002 20:03:30 +0000 (20:03 +0000)]
ehlo(): A proper fix for SF bug #498572. RFC 1869 describes ESMTP
which requires that if there are ehlo parameters returned with an ehlo
keyword (in the response to EHLO), the keyword and parameters must be
delimited by an ASCII space. Thus responses like
250-AUTH=LOGIN
should be ignored as non-conformant to the RFC (the `=' isn't allowed
in the ehlo keyword).
Fred Drake [Mon, 15 Apr 2002 19:40:07 +0000 (19:40 +0000)]
posix_fildes(): New helper: run a function that takes a file descriptor
and returns None. This allows any object that supports the fileno()
method to be passed as a file descriptor, not just an integer.
posix_fchdir(): New exposed function: implements posix.fchdir(). This
closes SF feature #536796.
posix_fsync(), posix_fdatasync(): Convert to use posix_fildes() instead
of posix_int(). This also changes them from METH_VARARGS to METH_O
functions.
setup_confname_table(): Remove unused variable. Change to take a module
rather than a dict to save the resulting table into.
setup_confname_tables(): Change to take a module instead of a dict to
pass to setup_confname_table().
Fred Drake [Mon, 15 Apr 2002 18:41:31 +0000 (18:41 +0000)]
Clean up the application of style to verbatim text.
This moves styling to the stylesheet; the use of <dl> structures to control
style sometimes produced improper indentation of subsequent text in many
browsers when the text was already part of the <dl> structure (as in a
function or class description).
Walter Dörwald [Mon, 15 Apr 2002 13:36:47 +0000 (13:36 +0000)]
Apply the second version of SF patch http://www.python.org/sf/536241
Add a method zfill to str, unicode and UserString and change
Lib/string.py accordingly.
This activates the zfill version in unicodeobject.c that was
commented out and implements the same in stringobject.c. It also
adds the test for unicode support in Lib/string.py back in and
uses repr() instead() of str() (as it was before Lib/string.py 1.62)
Complex numbers implement divmod() and //, neither of which makes one
lick of sense. Unfortunately this is documented, so I'm adding a
deprecation warning now, so we can delete this silliness, oh, around
2005 or so.
Provisional fix for writefile() [SF bug # 541730].
The problem was that an exception can occur in the text.get() call or
in the write() call, when the text buffer contains non-ASCII
characters. This causes the previous contents of the file to be lost.
The provisional fix is to call str(self.text.get(...)) *before*
opening the file, so that if the exception occurs, we never open the
file.
Two orthogonal better solutions have to wait for policy decisions:
1. We could try to encode the data as Latin-1 or as UTF-8; but that
would require IDLE to grow a notion of file encoding which requires
more thought.
2. We could make backups before overwriting a file. This requires
more thought because it needs to be fast and cross-platform and
configurable.
Tim Peters [Sun, 14 Apr 2002 22:04:03 +0000 (22:04 +0000)]
SF bug 543840: complex(string) accepts strings with \0
complex_subtype_from_string(): this stopped parsing at the first 0
byte, as if that were the end of the input string.
Jack Jansen [Sun, 14 Apr 2002 20:12:41 +0000 (20:12 +0000)]
Mass checkin of universal newline support.
Highlights: import and friends will understand any of \r, \n and \r\n
as end of line. Python file input will do the same if you use mode 'U'.
Everything can be disabled by configuring with --without-universal-newlines.
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_.