Commit Graph

2608 Commits

Author SHA1 Message Date
Andrew M. Kuchling 52740be425 [Bug #1414697] Change docstring of set/frozenset types to specify that the contents are unique. Raymond, please feel free to edit or revert. 2006-07-29 15:10:32 +00:00
Neal Norwitz 101bac205d Closure can't be NULL at this point since we know it's a tuple.
Reported by Klocwork # 74.
2006-07-27 03:55:39 +00:00
Neal Norwitz c09efa8444 Move the initialization of size_a down below the check for a being NULL.
Reported by Klocwork #106
2006-07-23 07:53:14 +00:00
Neal Norwitz e1fdb32ff2 Handle allocation failures gracefully. Found with failmalloc.
Many (all?) of these could be backported.
2006-07-21 05:32:28 +00:00
Neal Norwitz 1adbb50701 Move the initialization of some pointers earlier. The problem is
that if we call Py_DECREF(frame) like we do if allocating locals fails,
frame_dealloc() will try to use these bogus values and crash.
2006-07-21 05:31:02 +00:00
Neal Norwitz 48808a1d6c Add some asserts that we got good params passed 2006-07-21 05:29:58 +00:00
Neal Norwitz 04e39ec815 otherset is known to be non-NULL based on checks before and DECREF after.
DECREF otherset rather than XDECREF in error conditions too.

Reported by Klockwork #154.
2006-07-17 00:57:15 +00:00
Neal Norwitz b337bb541b Stop INCREFing name, then checking if it's NULL. name (f_name) should never
be NULL so assert it.  Fix one place where we could have passed NULL.

Reported by Klocwork #66.
2006-07-17 00:55:45 +00:00
Neal Norwitz ee4cc698ca PyFunction_SetDefaults() is documented as taking None or a tuple.
A NULL would crash the PyTuple_Check().  Now make NULL return a SystemError.

Reported by Klocwork #73.
2006-07-16 02:35:47 +00:00
Neal Norwitz fc28e0de58 Handle a NULL name properly.
Reported by Klocwork #67
2006-07-16 02:32:03 +00:00
Neal Norwitz 4b0a315c31 Use sizeof(buffer) instead of duplicating the constants to ensure they won't
be wrong.

The real change is to pass (bufsz - 1) to PyOS_ascii_formatd and 1
to strncat.  strncat copies n+1 bytes from src (not dest).

Reported by Klocwork #58.
2006-07-16 02:22:30 +00:00
Neal Norwitz ef02b9e144 a & b were dereffed above, so they are known to be valid pointers.
z is known to be NULL, nothing to DECREF.

Reported by Klockwork, #107.
2006-07-16 02:00:32 +00:00
Neal Norwitz 7e49c6eee8 Fix uninitialized memory read reported by Valgrind when running doctest.
This could happen if size == 0.
2006-07-12 05:27:46 +00:00
Kristján Valur Jónsson 74c3ea0a0f Fix build problems with the platform SDK on windows. It is not sufficient to test for the C compiler version when determining if we have the secure CRT from microsoft. Must test with an undocumented macro, __STDC_SECURE_LIB__ too. 2006-07-03 14:59:05 +00:00
Martin v. Löwis d5cfa5491a Put method-wrappers into trashcan. Fixes #927248. 2006-07-03 13:47:40 +00:00
Neal Norwitz 0f415dc57f Another problem reported by Coverity. Backport candidate. 2006-06-30 07:32:46 +00:00
Neal Norwitz b114984225 Fix refleak 2006-06-23 03:32:44 +00:00
Armin Rigo 53c1692f6a Fix for an obscure bug introduced by revs 46806 and 46808, with a test.
The problem of checking too eagerly for recursive calls is the
following: if a RuntimeError is caused by recursion, and if code needs
to normalize it immediately (as in the 2nd test), then
PyErr_NormalizeException() needs a call to the RuntimeError class to
instantiate it, and this hits the recursion limit again...  causing
PyErr_NormalizeException() to never finish.

Moved this particular recursion check to slot_tp_call(), which is not
involved in instantiating built-in exceptions.

Backport candidate.
2006-06-21 21:58:50 +00:00
Neal Norwitz 0f2783cb4c Use Py_ssize_t 2006-06-19 05:40:44 +00:00
Georg Brandl ccff785258 Patch #1507676: improve exception messages in abstract.c, object.c and typeobject.c. 2006-06-18 22:17:29 +00:00
Martin v. Löwis d825143be1 Patch #1455898: Incremental mode for "mbcs" codec. 2006-06-14 05:21:04 +00:00
Brett Cannon ea3912b0da If a classic class defined a __coerce__() method that just returned its two
arguments in reverse, the interpreter would infinitely recourse trying to get a
coercion that worked.  So put in a recursion check after a coercion is made and
the next call to attempt to use the coerced values.

Fixes bug #992017 and closes crashers/coerce.py .
2006-06-13 21:46:41 +00:00
Neal Norwitz de4c78a1d7 Initialize the type object so pychecker can't crash the interpreter. 2006-06-13 08:28:19 +00:00
Kristján Valur Jónsson f608317061 Fix the CRT argument error handling for VisualStudio .NET 2005. Install a CRT error handler and disable the assertion for debug builds. This causes CRT to set errno to EINVAL.
This update fixes crash cases in the test suite where the default CRT error handler would cause process exit.
2006-06-12 15:45:12 +00:00
Neal Norwitz b9845e72f9 Get rid of f_restricted too. Doc the other 4 ints that were already removed
at the NeedForSpeed sprint.
2006-06-12 02:11:18 +00:00
Neal Norwitz a00c0b97bf Don't leak the list object if there's an error allocating the item storage. Backport candidate 2006-06-12 02:08:41 +00:00
Neal Norwitz 7d5b6e8991 f_code can't be NULL based on Frame_New and other code that derefs it.
So there doesn't seem to be much point to checking here.
2006-06-11 05:48:14 +00:00
Neal Norwitz 8e6675a7dc Update doc to make it agree with code.
Bottom factor out some common code.
2006-06-11 05:47:14 +00:00
Skip Montanaro 9a8ae8f46b Suppress warning on MacOSX about possible use before set of proc. 2006-06-10 22:38:13 +00:00
Martin v. Löwis 0e8bd7e1cc Patch #1495999: Part two of Windows CE changes.
- update header checks, using autoconf
- provide dummies for getenv, environ, and GetVersion
- adjust MSC_VER check in socketmodule.c
2006-06-10 12:23:46 +00:00
Armin Rigo acd0d6d416 SF bug #1503294.
PyThreadState_GET() complains if the tstate is NULL, but only in debug mode.
2006-06-10 10:57:40 +00:00
Georg Brandl 90e27d38f5 Apply perky's fix for #1503157: "/".join([u"", u""]) raising OverflowError.
Also improve error message on overflow.
2006-06-10 06:40:50 +00:00
Brett Cannon 6946ea0be0 Fix bug introduced in rev. 46806 by not having variable declaration at the top of a block. 2006-06-09 22:45:54 +00:00
Brett Cannon 22565aac3b An object with __call__ as an attribute, when called, will have that attribute checked for __call__ itself, and will continue to look until it finds an object without the attribute. This can lead to an infinite recursion.
Closes bug #532646, again.  Will be backported.
2006-06-09 22:31:23 +00:00
Georg Brandl 242508160e RFE #1491485: str/unicode.endswith()/startswith() now accept a tuple as first argument. 2006-06-09 18:45:48 +00:00
Brett Cannon c48b0e6657 Fix inconsistency in naming within an enum. 2006-06-09 17:05:48 +00:00
Brett Cannon de3b052216 Buffer objects would return the read or write buffer for a wrapped object when
the char buffer was requested.  Now it actually returns the char buffer if
available or raises a TypeError if it isn't (as is raised for the other buffer
types if they are not present but requested).

Not a backport candidate since it does change semantics of the buffer object
(although it could be argued this is enough of a bug to bother backporting).
2006-06-08 17:00:45 +00:00
Georg Brandl 98b40ad590 Bug #1502805: don't alias file.__exit__ to file.close since the
latter can return something that's true.
2006-06-08 14:50:21 +00:00
Armin Rigo fd01d7933b (arre, arigo) SF bug #1350060
Give a consistent behavior for comparison and hashing of method objects
(both user- and built-in methods).  Now compares the 'self' recursively.
The hash was already asking for the hash of 'self'.
2006-06-08 10:56:24 +00:00
Brett Cannon ea229bd1ed Fix coding style guide bug. 2006-06-06 18:08:16 +00:00
Georg Brandl 9f16760666 Repair refleaks in unicodeobject. 2006-06-04 21:46:16 +00:00
Martin v. Löwis 3f767795f6 Patch #1359618: Speed-up charmap encoder. 2006-06-04 19:36:28 +00:00
Neal Norwitz 7a071939d9 SF #1499797, Fix for memory leak in WindowsError_str 2006-06-04 06:19:31 +00:00
Tim Peters 3eeb17346c _PyObject_DebugMalloc(): The return value should add
2*sizeof(size_t) now, not 8.  This probably accounts for
current disasters on the 64-bit buildbot slaves.
2006-06-04 03:38:04 +00:00
Tim Peters 9ea89d2a19 In a PYMALLOC_DEBUG build obmalloc adds extra debugging info
to each allocated block.  This was using 4 bytes for each such
piece of info regardless of platform.  This didn't really matter
before (proof: no bug reports, and the debug-build obmalloc would
have assert-failed if it was ever asked for a chunk of memory
>= 2**32 bytes), since container indices were plain ints.  But after
the Py_ssize_t changes, it's at least theoretically possible to
allocate a list or string whose guts exceed 2**32 bytes, and the
PYMALLOC_DEBUG routines would fail then (having only 4 bytes
to record the originally requested size).

Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG
build's extra debugging fields.  This won't make any difference
on 32-bit boxes, but will add 16 bytes to each allocation in
a debug build on a 64-bit box.
2006-06-04 03:26:02 +00:00
Neal Norwitz 38d4d4a35b Fix memory leak found by valgrind. 2006-06-02 04:50:49 +00:00
Tim Peters d770ebd286 Armin committed his patch while I was reviewing it (I'm sure
he didn't know this), so merged in some changes I made during
review.  Nothing material apart from changing a new `mask` local
from int to Py_ssize_t.  Mostly this is repairing comments that
were made incorrect, and adding new comments.  Also a few
minor code rewrites for clarity or helpful succinctness.
2006-06-01 15:50:44 +00:00
Armin Rigo 35f6d36951 [ 1497053 ] Let dicts propagate the exceptions in user __eq__().
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
2006-06-01 13:19:12 +00:00
Georg Brandl 6b50c63a23 Correctly allocate complex types with tp_alloc. (bug #1498638) 2006-06-01 08:27:32 +00:00
Georg Brandl 85ac850834 Correctly unpickle 2.4 exceptions via __setstate__ (patch #1498571) 2006-06-01 06:39:19 +00:00