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.
Tim Peters [Sun, 25 Nov 2001 21:12:43 +0000 (21:12 +0000)]
SF patch 483059: Avoid use of eval() in random.py, from Finn Bock.
_verify(): Pass in the values of globals insted of eval()ing their
names. The use of eval() was obscure and unnecessary, and the patch
claimed random.py couldn't be used in Jython applets because of it.
Guido van Rossum [Sat, 24 Nov 2001 21:04:31 +0000 (21:04 +0000)]
_reduce():
- Fix for SF bug #482752: __getstate__ & __setstate__ ignored (by Anon.)
In fact, only __getstate__ isn't recognized. This fixes that.
- Separately, the test for base.__flags__ & _HEAPTYPE raised an
AttributeError exception when a classic class was amongst the
bases. Fixed this with a hasattr() bandaid (classic classes never
qualify as the "hard" base class anyway, which is what the code is
trying to find).
Guido van Rossum [Sat, 24 Nov 2001 18:24:47 +0000 (18:24 +0000)]
PyObject_GetItem(), PyObject_SetItem(), PyObject_DelItem(): Fix a few
confusing error messages. If a new-style class has no sequence or
mapping behavior, attempting to use the indexing notation with a
non-integer key would complain that the sequence index must be an
integer, rather than complaining that the operation is not supported.
Barry Warsaw [Mon, 19 Nov 2001 18:36:43 +0000 (18:36 +0000)]
formatdate(): Jason Mastaler correctly points out that divmod with a
negative modulus won't return the right values. So always do positive
modulus on an absolute value and twiddle the sign as appropriate after
the fact.
Barry Warsaw [Mon, 19 Nov 2001 16:31:06 +0000 (16:31 +0000)]
test_formatdate(), test_formatdate_zoneoffsets(): Two changes. First,
use the correct way to test for epoch, by looking at the year
component of gmtime(0). Add clause for Unix epoch and Mac epoch (Tim,
what is Windows epoch?).
Also, get rid of the strptime() test, it was way too problematic given
that strptime() is missing on many platforms and issues with locales.
Instead, simply test that formatdate() gets the numeric timezone
calculation correct for the altzone and timezone.
Barry Warsaw [Mon, 19 Nov 2001 16:28:07 +0000 (16:28 +0000)]
formatdate(): The calculation of the minutes part of the zone was
incorrect for "uneven" timezones. This algorithm should work for even
timezones (e.g. America/New_York) and uneven timezones (e.g.
Australia/Adelaide and America/St_Johns).