Address SF patch #480716 as well as related issues.
SF patch #480716 by Greg Chapman fixes the problem that super's
__get__ method always returns an instance of super, even when the
instance whose __get__ method is called is an instance of a subclass
of super.
Other issues fixed:
- super(C, C()).__class__ would return the __class__ attribute of C()
rather than the __class__ attribute of the super object. This is
confusing. To fix this, I decided to change the semantics of super
so that it only applies to code attributes, not to data attributes.
After all, overriding data attributes is not supported anyway.
- While super(C, x) carefully checked that x is an instance of C,
super(C).__get__(x) made no such check, allowing for a loophole.
This is now fixed.
slot_tp_descr_set(): When deleting an attribute described by a
descriptor implemented in Python, the descriptor's __del__ method is
called by the slot_tp_descr_set dispatch function. This is bogus --
__del__ already has a different meaning. Renaming this use of __del__
is renamed to __delete__.
Tim Peters [Mon, 3 Dec 2001 00:43:33 +0000 (00:43 +0000)]
mysnprintf.c: Massive rewrite of PyOS_snprintf and PyOS_vsnprintf, to
use wrappers on all platforms, to make this as consistent as possible x-
platform (in particular, make sure there's at least one \0 byte in
the output buffer). Also document more of the truth about what these do.
getargs.c, seterror(): Three computations of remaining buffer size were
backwards, thus telling PyOS_snprintf the buffer is larger than it
actually is. This matters a lot now that PyOS_snprintf ensures there's a
trailing \0 byte (because it didn't get the truth about the buffer size,
it was storing \0 beyond the true end of the buffer).
sysmodule.c, mywrite(): Simplify, now that PyOS_vsnprintf guarantees to
produce a \0 byte.
Jack Jansen [Mon, 3 Dec 2001 00:11:35 +0000 (00:11 +0000)]
A system() lookalike that sends commands to ToolServer, by Daniel Brotsky. The semantics aren't enough like system() to add this to the main Lib folder, but it is pretty useful nonetheless for selected people.
slot_tp_descr_set(): When deleting an attribute described by a
descriptor implemented in Python, the descriptor's __del__ method is
called by the slot_tp_descr_set dispatch function. This is bogus --
__del__ already has a different meaning. Renaming this use of __del__
is renamed to __delete__.
Jack Jansen [Sun, 2 Dec 2001 23:56:28 +0000 (23:56 +0000)]
Changed logic for finding python home in Mac OS X framework Pythons.
Now sys.executable points to the executable again, in stead of to
the shared library. The latter is used only for locating the python
home.
Fred Drake [Sun, 2 Dec 2001 15:10:46 +0000 (15:10 +0000)]
Add reference to the "String Methods" section to make that information
easier to find. Based on the comment from Steve Alexander on the
zope-coders mailing list.
When the number of bytes written to the malloc'ed buffer is larger
than the argument string size, copy as many bytes as will fit
(including a terminating '\0'), rather than not copying anything.
This to make it satisfy the C99 spec.
Tim Peters [Sat, 1 Dec 2001 02:52:56 +0000 (02:52 +0000)]
SF bug #487743: test_builtin fails on 64 bit platform.
Bugfix candidate.
int_repr(): we've never had a buffer big enough to hold the largest
possible result on a 64-bit box. Now that we're using snprintf instead
of sprintf, this can lead to nonsense results instead of random stack
corruption.
Fred Drake [Fri, 30 Nov 2001 18:09:54 +0000 (18:09 +0000)]
Add a new environment in the Python docs markup: seealso*. This is similar
to seealso, but does not add the "See also:" header or put the content in a
box in the HTML version.
Updated the description of \seeurl to better indicate when it should be used;
the old description was written before we had \seetitle.
Fred Drake [Thu, 29 Nov 2001 04:30:46 +0000 (04:30 +0000)]
A few small changes:
- Change PREFIX to PREFIXES, which contains a sequence of prefix strings.
This is useful since we want to look for both Py and PY.
- Wrap a long line.
- Collect struct tags as well as typedef names. Since we generally only
use one of the other, that improves coverage.
- Make the script executable on Unix.
This could use a better approach to determine if a symbol is documented,
and could easily avoid keeping the massive string in memory. That would
take time to actually write more code, though, so we'll bail on that
for now.
Tim Peters [Thu, 29 Nov 2001 03:26:37 +0000 (03:26 +0000)]
SF bug 486278 SystemError: Python/getargs.c:1086: bad.
vgetargskeywords(): Now that this routine is checking for bad input
(rather than dump core in some cases), some bad calls are raising errors
that previously "worked". This patch makes the error strings more
revealing, and changes the exceptions from SystemError to RuntimeError
(under the theory that SystemError is more of a "can't happen!" assert-
like thing, and so inappropriate for bad arguments to a public C API
function).
Guido van Rossum [Thu, 29 Nov 2001 02:50:15 +0000 (02:50 +0000)]
canonic(): don't use abspath() for filenames looking like <...>; this
fixes the problem reported in SF bug #477023 (Jonathan Mark): "pdb:
unexpected path confuses Emacs".
Tim Peters [Wed, 28 Nov 2001 23:16:40 +0000 (23:16 +0000)]
SF bug 486480: zipfile __del__ is broken
ZipFile.__del__(): call ZipFile.close(), like its docstring says it does.
ZipFile.close(): allow calling more than once (as all file-like objects
in Python should support).
Tim Peters [Wed, 28 Nov 2001 22:43:45 +0000 (22:43 +0000)]
PyFloat_AsStringEx(): This function takes an output char* but doesn't
pass the buffer length. Stop using it. It should be deprecated, but too
late in the release cycle to do that now.
New static format_float() does the same thing but requires passing the
buffer length too. Use it instead.
Tim Peters [Wed, 28 Nov 2001 22:13:25 +0000 (22:13 +0000)]
PyFile_WriteString(): change prototype so that the string arg is
const char* instead of char*. The change is conceptually correct, and
indirectly fixes a compiler wng introduced when somebody else innocently
passed a const char* to this function.
Jeremy Hylton [Wed, 28 Nov 2001 21:46:59 +0000 (21:46 +0000)]
Use PyOS_snprintf() at some cost even though it was correct before.
seterror() uses a char array and a pointer to the current position in
that array. Use snprintf() and compute the amount of space left in
the buffer based on the current pointer position.
Jeremy Hylton [Wed, 28 Nov 2001 21:44:53 +0000 (21:44 +0000)]
Use PyOS_vsnprintf() and check its return value.
If it returns -1 (which indicates overflow on old Linux platforms and
perhaps on Windows) or size greater than buffer, write a message
indicating that the previous message was truncated.
Tim Peters [Wed, 28 Nov 2001 20:27:42 +0000 (20:27 +0000)]
sprintf -> PyOS_snprintf in some "obviously safe" cases.
Also changed <>-style #includes to ""-style in some places where the
former didn't make sense.
Fred Drake [Wed, 28 Nov 2001 07:26:15 +0000 (07:26 +0000)]
Clean up some markup cruft. A number of the macros that take no
parameters (like \UNIX) are commonly entered using an empty group to
separate the markup from a following inter-word space; this is not
needed when the next character is punctuation, or the markup is the
last thing in the enclosing group. These cases were marked
inconsistently; the empty group is now *only* used when needed.
Tim Peters [Tue, 27 Nov 2001 23:29:29 +0000 (23:29 +0000)]
SF bug #483469: crash on unbounded recursion in __del__.
PyEval_EvalCodeEx(): increment tstate->recursion_depth around the
decref of the frame, because the C stack for this call is still in
use and the decref can lead to __del__ methods getting called.
While this gives tstate->recursion_depth a value proportional to the
depth of the C stack (instead of a small constant no matter how
deeply __del__s recurse), it's not enough to stop the reported crash
when using the default recursion limit on Windows.
Tim Peters [Tue, 27 Nov 2001 20:30:42 +0000 (20:30 +0000)]
SF bug 485175: buffer overflow in traceback.c.
Bugfix candidate.
tb_displayline(): the sprintf format was choking off the file name, but
used plain %s for the function name (which can be arbitrarily long).
Limit both to 500 chars max.
Barry Warsaw [Tue, 27 Nov 2001 07:12:35 +0000 (07:12 +0000)]
test_formatdate(): Integrating Jack's 22b2 branch fix for Mac epoch:
More changes to the formatdate epoch test: the Mac epoch is in
localtime, so east of GMT it falls in 1903:-( Changed the test to
obtain the epoch in both local time and GMT, and do the right
thing in the comparisons. As a sanity measure also check that
day/month is Jan 1.