Commit Graph

1549 Commits

Author SHA1 Message Date
Martin v. Löwis 7198a525f3 Patch #494783: Rename cmp_op enumerators. 2002-01-01 19:59:11 +00:00
Martin v. Löwis a6e975801e Patch #497098: build support for GNU/Hurd. 2002-01-01 18:41:33 +00:00
Tim Peters 54b11918be SF bug #496549 -Qnew and in-place division "/=".
eval_frame():  Under -Qnew, INPLACE_DIVIDE wasn't getting handed off to
INPLACE_TRUE_DIVIDE (like BINARY_DIVIDE was getting handed off to
BINARY_TRUE_DIVIDE).

Bugfix candidate.
2001-12-25 18:49:11 +00:00
Barry Warsaw b2dd86defe PyOS_vsnprintf(): Change PyMem_Malloc() call to PyMem_MALLOC() macro,
(ditto for PyMem_Free() -> PyMem_FREE()) to fix and close SF bug
#495875 on systems that HAVE_SNPRINTF=0.

Check in on both release-22 branch and trunk.
2001-12-21 16:32:15 +00:00
Tim Peters b6d14daa1c SF bug #494668: PUSH() should assert-fail on overflow.
eval_frame():  Added asserts to the top of the eval loop, to verify
that the eval stack pointer is in bounds, plus some comments.
2001-12-19 04:11:07 +00:00
Martin v. Löwis 8d3ce5a6b3 Patch #494384: Disable more Unicode API if Unicode is not used. 2001-12-18 22:36:40 +00:00
Tim Peters b519638d1e _PyEval_SliceIndex(): explain why a NULL argument is allowed (thanks
to Guido for the revelation).
2001-12-16 19:44:20 +00:00
Tim Peters cb479e78e0 _PyEval_SliceIndex(): Repaired the comments, and added XXX comments
about its dubious treatment of NULL (also opened a bug report on that,
but don't want to risk changing it this late in the 2.2 game).
2001-12-16 19:11:44 +00:00
Jeremy Hylton 733c8935f9 Fix for SF bug [ #492403 ] exec() segfaults on closure's func_code
Based on the patch from Danny Yoo.  The fix is in exec_statement() in
ceval.c.

There are also changes to introduce use of PyCode_GetNumFree() in
several places.
2001-12-13 19:51:56 +00:00
Jeremy Hylton 2990640d8a Add a comment explaining the st_symbols cache. 2001-12-10 00:53:18 +00:00
Tim Peters 0f2d4b84a6 PySymtableEntry_New(): I'm not sure what this routine is doing, but it
was obviously leaking an int object when whatever the heck it's looking for
was found.  Repaired that.  This accounts for why entering function and
class definitions at an interactive prompt leaked a reference to the
integer 1 each time.
Bugfix candidate.
2001-12-08 23:40:38 +00:00
Jeremy Hylton 0702858d73 Missing DECREFs when exception is raised in sys.excepthook.
Bug fix candidate for 2.1 branch.

(I imagine the other recent leak patches are bug fix candidates, too,
but I forgot to mark mine as such.)
2001-12-07 15:35:35 +00:00
Jack Jansen e3d7622fb3 Don't fail on importing things with undefined references. Unfortunately we
still fail on importing modules that link with libraries that fail
their initialization code (such as windowing libraries when we don't have
access to the window server) and that is what I really wanted to fix.
2001-12-06 22:58:56 +00:00
Guido van Rossum 35974fbf31 Fix for SF bug #489671 (Neil Norwitz): memory leak in test_richcmp.
Had nothing to do with rich comparisons -- some stack cleanup code was
lost as a result of merging in Neil Schemenauer's generators patch.
Reinserted the stack cleanup code, skipping it when yielding.
2001-12-06 21:28:18 +00:00
Guido van Rossum 2556f2e1e2 Fix a typo (probably caused by autocompletion <blush>) that caused a
leak when a class defined a __metaclass__.  This fixes the problem
reported on python-dev by Ping; I dunno if it's the same as SF bug
#489669 (since that mentions Unicode).
2001-12-06 14:09:56 +00:00
Tim Peters 3caca2326e SF bug #488514: -Qnew needs work
Big Hammer to implement -Qnew as PEP 238 says it should work (a global
option affecting all instances of "/").

pydebug.h, main.c, pythonrun.c:  define a private _Py_QnewFlag flag, true
iff -Qnew is passed on the command line.  This should go away (as the
comments say) when true division becomes The Rule.  This is
deliberately not exposed to runtime inspection or modification:  it's
a one-way one-shot switch to pretend you're using Python 3.

ceval.c:  when _Py_QnewFlag is set, treat BINARY_DIVIDE as
BINARY_TRUE_DIVIDE.

test_{descr, generators, zipfile}.py:  fiddle so these pass under
-Qnew too.  This was just a matter of s!/!//! in test_generators and
test_zipfile.  test_descr was trickier, as testbinop() is passed
assumptions that "/" is the same as calling a "__div__" method; put
a temporary hack there to call "__truediv__" instead when the method
name is "__div__" and 1/2 evaluates to 0.5.

Three standard tests still fail under -Qnew (on Windows; somebody
please try the Linux tests with -Qnew too!  Linux runs a whole bunch
of tests Windows doesn't):
    test_augassign
    test_class
    test_coercion
I can't stay awake longer to stare at this (be my guest).  Offhand
cures weren't obvious, nor was it even obvious that cures are possible
without major hackery.

Question:  when -Qnew is in effect, should calls to __div__ magically
change into calls to __truediv__?  See "major hackery" at tail end of
last paragraph <wink>.
2001-12-06 06:23:26 +00:00
Guido van Rossum 6b70599450 Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
There's now a new structmember code, T_OBJECT_EX, which is used for
all __slot__ variables (except __weakref__, which has special behavior
anyway).  This new code raises AttributeError when the variable is
NULL rather than converting NULL to None.
2001-12-04 16:23:42 +00:00
Jeremy Hylton 86424e333f SF bug #488687 reported by Neal Norwitz
The error for assignment to __debug__ used ste->ste_opt_lineno instead
of n->n_lineno.  The latter was at best incorrect; often the slot was
uninitialized.  Two fixes here: Use the correct lineno for the error.
Initialize ste_opt_lineno in PySymtable_New(); while there are no
current cases where it is referenced unless it has already been
assigned to, there is no harm in initializing it.
2001-12-04 02:41:46 +00:00
Tim Peters 22a51efc1c More sprintf -> PyOS_snprintf. 2001-12-04 01:11:32 +00:00
Guido van Rossum 354797ccad Fix the final two issues in Armin Rigo's SF bug #488477: apply_slice()
and assign_slice() weren't properly DECREF'ing the temporary slice
object they created.  (Shame on me. :-)
2001-12-03 19:45:06 +00:00
Guido van Rossum bb8f59a371 unpack_iterable(): Add a missing DECREF in an error case. Reported by
Armin Rigo (SF bug #488477).  Added a testcase to test_unpack_iter()
in test_iter.py.
2001-12-03 19:33:25 +00:00
Tim Peters faad5ad590 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.
2001-12-03 00:43:33 +00:00
Tim Peters 080d5b3f0b mywrite(): The test for trouble in PyOS_vsnprintf was wrong on both
ends.  Also, when there is trouble, ensure the buffer has a traiing
0 byte.
2001-12-02 08:29:16 +00:00
Guido van Rossum 64be0b4aa5 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.
2001-12-01 16:00:10 +00:00
Tim Peters cffed4bc21 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).
2001-11-29 03:26:37 +00:00
Jeremy Hylton b048b26db0 Two screwups fixed for sizeof(char *) instead of sizeof(char []).
Also change all the helper functions to pass along the size of the
msgbuf and use PyOS_snprintf() when writing into the buffer.
2001-11-28 22:14:37 +00:00
Tim Peters 75cdad5584 More sprintf -> PyOS_snprintf. 2001-11-28 22:07:30 +00:00
Jeremy Hylton f16e05e7ec 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.
2001-11-28 21:46:59 +00:00
Jeremy Hylton 5d3d134d56 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.
2001-11-28 21:44:53 +00:00
Barry Warsaw 4b4ab20f2c ste_repr(): Conversion of sprintf() to PyOS_snprintf() for buffer
overrun avoidance.
2001-11-28 21:36:28 +00:00
Barry Warsaw 857bf52d56 aix_loaderror(): Conversion of sprintf() to PyOS_snprintf() for buffer
overrun avoidance.
2001-11-28 21:35:49 +00:00
Barry Warsaw 8f6d868bbb code_repr(), com_addop_varname(), com_list_comprehension(),
com_arglist(), symtable_check_unoptimized(), symtable_params(),
symtable_global(), symtable_list_comprehension():

    Conversion of sprintf() to PyOS_snprintf() for buffer overrun
    avoidance.
2001-11-28 21:10:39 +00:00
Jeremy Hylton 518ab1c02a Use PyOS_snprintf instead of sprintf. 2001-11-28 20:42:20 +00:00
Jeremy Hylton ef58b31991 Use PyOS_snprintf instead of sprintf.
Also replace a switch statement with one case and a default to an
if/else.
2001-11-28 20:37:25 +00:00
Jeremy Hylton 23ae987401 Use PyOS_snprintf when possible. 2001-11-28 20:29:22 +00:00
Jeremy Hylton 05bd787c6c Use PyOS_snprintf instead of sprintf.
Just being sure.  The old code looks like it was safe, but there's no
harm in double-checking.
2001-11-28 20:24:33 +00:00
Marc-André Lemburg d4c0a9c59b Fixes for possible buffer overflows in sprintf() usages. 2001-11-28 11:47:00 +00:00
Tim Peters b13680bf03 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.

Bugfix candidate.
2001-11-27 23:29:29 +00:00
Tim Peters 6d20b43a4e 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.
2001-11-27 20:30:42 +00:00
Marc-André Lemburg 0c4d8d05a8 Fix for bug #480188: printing unicode objects 2001-11-20 15:17:25 +00:00
Tim Peters 36515e28ed Since the MAGIC number scheme is going to break on January 1st, document
what it is more carefully and point out some of the subtleties.
2001-11-18 04:06:29 +00:00
Barry Warsaw afeb2a4d89 PyOS_getsig(), PyOS_setsig(): The minimal amount of work to avoid the
uninitialized memory reads reported in bug #478001.

Note that this doesn't address the following larger issues:

- Error conditions are not documented for PyOS_*sig() in the C API.

- Nothing that actually calls PyOS_*sig() in the core interpreter and
  extension modules actually /checks/ the return value of the call.

Fixing those is left as an exercise for a later day.
2001-11-13 23:08:26 +00:00
Jeremy Hylton 9f64caaf00 Use PyObject_CheckReadBuffer(). 2001-11-09 22:02:48 +00:00
Martin v. Löwis 107b7daf5a Include sys_getdefaultencoding in #ifdef Py_USING_UNICODE. Fixes #479571. 2001-11-09 20:59:39 +00:00
Jeremy Hylton 778e265462 Fix SF buf #480096: Assign to __debug__ still allowed
Easy enough to catch assignment in the compiler.  The perverse user
can still change the value of __debug__, but that may be the least he
can do.
2001-11-09 19:50:08 +00:00
Fred Drake 03459a5cd7 Fix memory leak. This is part of SF patch #478006. 2001-11-09 16:00:41 +00:00
Marc-André Lemburg 4962fc8fed Backing out the fast path for interned string compares again as requested. 2001-11-08 08:34:43 +00:00
Marc-André Lemburg c52d713b7a Add fast-path for comparing interned (true) string objects.
This patch boosts performance for comparing identical string object
by some 20% on my machine while not causing any noticable slow-down
for other operations (according to tests done with pybench).
2001-11-07 14:54:49 +00:00
Jack Jansen 537a69fe66 Make the CoreFoundation object _New and _Convert routines available to other modules. Idea by Donovan Preston, implementaion by me. 2001-11-05 14:39:22 +00:00
Tim Peters 603c6831d0 SF patch 473749 compile under OS/2 VA C++, from Michael Muller.
Changes enabling Python to compile under OS/2 Visual Age C++.
2001-11-05 02:45:59 +00:00