Raymond Hettinger
db67aef672
Bug #1648179 : set.update() not recognizing __iter__ overrides in dict subclasses.
2007-02-01 21:02:59 +00:00
Brett Cannon
f5bee30e30
Fix crasher for when an object's __del__ creates a new weakref to itself.
...
Patch only fixes new-style classes; classic classes still buggy.
Closes bug #1377858 . Already backported.
2007-01-23 23:21:22 +00:00
Thomas Wouters
afea529088
SF patch #1630975 : Fix crash when replacing sys.stdout in sitecustomize
...
When running the interpreter in an environment that would cause it to set
stdout/stderr/stdin's encoding, having a sitecustomize that would replace
them with something other than PyFile objects would crash the interpreter.
Fix it by simply ignoring the encoding-setting for non-files.
This could do with a test, but I can think of no maintainable and portable
way to test this bug, short of adding a sitecustomize.py to the buildsystem
and have it always run with it (hmmm....)
2007-01-23 13:42:00 +00:00
Raymond Hettinger
9fdfadb06e
SF #1486663 -- Allow keyword args in subclasses of set() and frozenset().
2007-01-11 18:22:55 +00:00
Gustavo Niemeyer
37e6502c25
Minor change in int() docstring for proper spacing.
2007-01-10 16:15:48 +00:00
Gustavo Niemeyer
a443bc8ec7
Mention in the int() docstring that a base zero has meaning, as
...
stated in http://docs.python.org/lib/built-in-funcs.html as well.
2007-01-10 16:13:40 +00:00
Raymond Hettinger
5399910eba
For sets with cyclical reprs, emit an ellipsis instead of infinitely recursing.
2006-12-30 04:01:17 +00:00
Andrew M. Kuchling
eabc0e87af
Typo fix
2006-12-22 00:50:56 +00:00
Raymond Hettinger
9c14ffbc78
Port Georg's dictobject.c fix keys that were tuples got unpacked on the way to setting a KeyError (svn revision 52535, sf bug
...
1576657).
2006-12-08 04:57:50 +00:00
Raymond Hettinger
0c850863a2
Port Armin's fix for a dict resize vulnerability (svn revision 46589, sf bug 1456209).
2006-12-08 04:24:33 +00:00
Raymond Hettinger
f31e17509a
Eliminate two redundant calls to PyObject_Hash().
2006-12-08 03:17:18 +00:00
Georg Brandl
283a1353a0
Patch [ 1586791 ] better error msgs for some TypeErrors
2006-11-19 08:48:30 +00:00
Martin v. Löwis
056dac1bcf
Bug #1067760 : Deprecate passing floats to file.seek.
2006-11-12 18:24:26 +00:00
Martin v. Löwis
3a62404264
Correctly forward exception in instance_contains().
...
Fixes #1591996 . Patch contributed by Neal Norwitz.
Will backport.
2006-11-08 06:46:37 +00:00
Neal Norwitz
7b932da443
Fix refleak
2006-10-29 23:39:03 +00:00
Georg Brandl
b9f4ad3a9a
Bug #1576657 : when setting a KeyError for a tuple key, make sure that
...
the tuple isn't used as the "exception arguments tuple".
2006-10-29 18:31:42 +00:00
Neal Norwitz
ab77227470
Don't inline Py_ADDRESS_IN_RANGE with gcc 4+ either.
...
Will backport.
2006-10-28 21:21:00 +00:00
Neal Norwitz
e7e4e2dfab
Prevent crash if alloc of garbage fails. Found by Typo.pl.
...
Will backport.
2006-10-28 21:20:12 +00:00
Neal Norwitz
a5ccda95f2
Fix warnings with HP's C compiler. It doesn't recognize that infinite
...
loops are, um, infinite. These conditions should not be able to happen.
Will backport.
2006-10-28 21:16:54 +00:00
Thomas Heller
df08f0b9a0
WindowsError.str should display the windows error code,
...
not the posix error code; with test.
Fixes #1576174 .
Will backport to release25-maint.
2006-10-27 18:31:36 +00:00
Georg Brandl
2c1375c8db
Bug #1545497 : when given an explicit base, int() did ignore NULs
...
embedded in the string to convert.
2006-10-12 11:27:59 +00:00
Andrew M. Kuchling
b3f37556bc
Fix wording in comment
2006-10-09 18:05:19 +00:00
Armin Rigo
7ccbca93a2
Forward-port of r52136,52138: a review of overflow-detecting code.
...
* unified the way intobject, longobject and mystrtoul handle
values around -sys.maxint-1.
* in general, trying to entierely avoid overflows in any computation
involving signed ints or longs is extremely involved. Fixed a few
simple cases where a compiler might be too clever (but that's all
guesswork).
* more overflow checks against bad data in marshal.c.
* 2.5 specific: fixed a number of places that were still confusing int
and Py_ssize_t. Some of them could potentially have caused
"real-world" breakage.
* list.pop(x): fixing overflow issues on x was messy. I just reverted
to PyArg_ParseTuple("n"), which does the right thing. (An obscure
test was trying to give a Decimal to list.pop()... doesn't make
sense any more IMHO)
* trying to write a few tests...
2006-10-04 12:17:45 +00:00
Martin v. Löwis
820d6ac9d7
Fix integer negation and absolute value to not rely
...
on undefined behaviour of the C compiler anymore.
Will backport to 2.5 and 2.4.
2006-10-04 05:47:34 +00:00
Georg Brandl
3267d28f9d
Bug #1566800 : make sure that EnvironmentError can be called with any
...
number of arguments, as was the case in Python 2.4.
2006-09-30 09:03:42 +00:00
Georg Brandl
5d59c09834
Patch #1567691 : super() and new.instancemethod() now don't accept
...
keyword arguments any more (previously they accepted them, but didn't
use them).
2006-09-30 08:43:30 +00:00
Brett Cannon
f6aa86e33b
Allow exceptions to be directly sliced again
...
(e.g., ``BaseException(1,2,3)[0:2]``).
Discovered in Python 2.5.0 by Thomas Heller and reported to python-dev. This
should be backported to 2.5 .
2006-09-20 18:43:13 +00:00
Brett Cannon
ca2ca79d23
Remove the __unicode__ method from exceptions. Allows unicode() to be called
...
on exception classes. Would require introducing a tp_unicode slot to make it
work otherwise.
Fixes bug #1551432 and will be backported.
2006-09-09 07:11:46 +00:00
Raymond Hettinger
c563a1c32b
Fix refcounts and add error checks.
2006-09-07 02:42:48 +00:00
Georg Brandl
38f6237dfe
Bug #1542051 : Exceptions now correctly call PyObject_GC_UnTrack.
...
Also make sure that every exception class has __module__ set to
'exceptions'.
2006-09-06 06:50:05 +00:00
Neal Norwitz
a22975fb35
Fix SF bug #1546288 , crash in dict_equal.
2006-09-05 02:24:03 +00:00
Tim Peters
c10c9d0d6b
"Conceptual" merge of rev 51711 from the 2.5 branch.
...
i_divmod(): As discussed on Python-Dev, changed the overflow
checking to live happily with recent gcc optimizations that
assume signed integer arithmetic never overflows.
This differs from the corresponding change on the 2.5 and 2.4
branches, using a less obscure approach, but one that /may/
tickle platform idiocies in their definitions of LONG_MIN.
The 2.4 + 2.5 change avoided introducing a dependence on
LONG_MIN, at the cost of substantially goofier code.
2006-09-05 02:18:09 +00:00
Raymond Hettinger
a0c95fa4d8
Fix endcase for str.rpartition()
2006-09-04 15:32:48 +00:00
Brett Cannon
2b3666f737
Make sure memory is properly cleaned up in file_init.
...
Backport candidate.
2006-08-31 18:54:26 +00:00
Alex Martelli
348dc88097
Reverting the patch that tried to fix the issue whereby x**2 raises
...
OverflowError while x*x succeeds and produces infinity; apparently
these inconsistencies cannot be fixed across ``all'' platforms and
there's a widespread feeling that therefore ``every'' platform
should keep suffering forevermore. Ah well.
2006-08-23 22:17:59 +00:00
Alex Martelli
20362a820b
x**2 should about equal x*x (including for a float x such that the result is
...
inf) but didn't; added a test to test_float to verify that, and ignored the
ERANGE value for errno in the pow operation to make the new test pass (with
help from Marilyn Davis at the Google Python Sprint -- thanks!).
2006-08-23 20:42:02 +00:00
Neal Norwitz
17753ecbfa
Patch #1541585 : fix buffer overrun when performing repr() on
...
a unicode string in a build with wide unicode (UCS-4) support.
This code could be improved, so add an XXX comment.
2006-08-21 22:21:19 +00:00
Neal Norwitz
076d1e0c0b
Fix a couple of ssize-t issues reported by Alexander Belopolsky on python-dev
2006-08-21 18:20:10 +00:00
Neal Norwitz
7fd9607bad
Move initialization to after the asserts for non-NULL values.
...
Klocwork 286-287.
(I'm not backporting this, but if someone wants to, feel free.)
2006-08-19 04:28:55 +00:00
Neal Norwitz
6cbb726539
Move initialization of interned strings to before allocating the
...
object so we don't leak op. (Fixes an earlier patch to this code)
Klockwork #350
2006-08-19 04:22:33 +00:00
Neal Norwitz
271a8689e9
Subclasses of int/long are allowed to define an __index__.
2006-08-15 06:29:03 +00:00
Georg Brandl
26a07b5198
Fix refleak introduced in rev. 51248.
2006-08-14 20:25:39 +00:00
Marc-André Lemburg
3a457790c7
Correct an accidentally removed previous patch.
2006-08-14 12:57:27 +00:00
Marc-André Lemburg
040f76b79c
Slightly revised version of patch #1538956 :
...
Replace UnicodeDecodeErrors raised during == and !=
compares of Unicode and other objects with a new
UnicodeWarning.
All other comparisons continue to raise exceptions.
Exceptions other than UnicodeDecodeErrors are also left
untouched.
2006-08-14 10:55:19 +00:00
Neal Norwitz
af33f2d571
Can't return NULL from a void function. If there is a memory error,
...
about the best we can do is call PyErr_WriteUnraisable and go on.
We won't be able to do the call below either, so verify delstr is valid.
2006-08-14 00:59:03 +00:00
Neal Norwitz
56423e5762
Fix segfault when doing string formatting on subclasses of long if
...
__oct__, __hex__ don't return a string.
Klocwork 308
2006-08-13 18:11:08 +00:00
Neal Norwitz
b09f4f578f
Handle a whole lot of failures from PyString_FromInternedString().
...
Should fix most of Klocwork 234-272.
2006-08-13 18:10:28 +00:00
Neal Norwitz
1872b1c01f
Fix a couple of bugs exposed by the new __index__ code. The 64-bit buildbots
...
were failing due to inappropriate clipping of numbers larger than 2**31
with new-style classes. (typeobject.c) In reviewing the code for classic
classes, there were 2 problems. Any negative value return could be returned.
Always return -1 if there was an error. Also make the checks similar
with the new-style classes. I believe this is correct for 32 and 64 bit
boxes, including Windows64.
Add a test of classic classes too.
2006-08-12 18:44:06 +00:00
Neal Norwitz
8a87f5d37e
Patch #1538606 , Patch to fix __index__() clipping.
...
I modified this patch some by fixing style, some error checking, and adding
XXX comments. This patch requires review and some changes are to be expected.
I'm checking in now to get the greatest possible review and establish a
baseline for moving forward. I don't want this to hold up release if possible.
2006-08-12 17:03:09 +00:00
Neal Norwitz
b88cfad318
Check return of PyMem_MALLOC (garbage) is non-NULL.
...
Check seq in both portions of if/else.
Klocwork #289-290.
2006-08-12 03:16:54 +00:00
Neal Norwitz
421c1319ad
Whoops, how did that get in there. :-) Revert all the parts of 51227 that were not supposed to go it. Only Modules/_ctypes/cfields.c was supposed to be changed
2006-08-12 02:12:30 +00:00
Neal Norwitz
6b4953fd3d
Check returned pointer is valid.
...
Klocwork #233
2006-08-12 02:06:34 +00:00
Neal Norwitz
6f5ff3f3eb
Klocwork made another run and found a bunch more problems.
...
This is the first batch of fixes that should be easy to verify based on context.
This fixes problem numbers: 220 (ast), 323-324 (symtable),
321-322 (structseq), 215 (array), 210 (hotshot), 182 (codecs), 209 (etree).
2006-08-12 01:43:40 +00:00
Armin Rigo
51fc8c456e
Fix and test for an infinite C recursion.
2006-08-09 14:55:26 +00:00
Martin v. Löwis
ab2f8f7bd5
__hash__ may now return long int; the final hash
...
value is obtained by invoking hash on the long int.
Fixes #1536021 .
2006-08-09 07:57:39 +00:00
Thomas Heller
ab1049c046
memcmp() can return values other than -1, 0, and +1 but tp_compare
...
must not.
2006-08-08 17:37:00 +00:00
Georg Brandl
b0061c8e93
Remove "non-mapping" and "non-sequence" from TypeErrors raised by
...
PyMapping_Size and PySequence_Size.
Because len() tries first sequence, then mapping size, it will always
raise a "non-mapping object has no len" error which is confusing.
2006-08-08 11:56:21 +00:00
Andrew M. Kuchling
0067b5fa2b
Typo fixes
2006-08-04 20:37:43 +00:00
Georg Brandl
e9462c72bd
Change fix for segfaulting property(), add a NEWS entry and a test.
2006-08-04 18:03:37 +00:00
Georg Brandl
45381938e9
Fix bug caused by first decrefing, then increfing.
2006-08-04 06:03:53 +00:00
Fred Drake
7a36f5f344
SF patch #1534048 (bug #1531003 ): fix typo in error message
2006-08-04 05:17:21 +00:00
Neal Norwitz
c5e060dee6
_PyWeakref_GetWeakrefCount() now returns a Py_ssize_t instead of long.
2006-08-02 06:14:22 +00:00
Andrew M. Kuchling
5a51bf50b8
typo fix
2006-08-01 16:24:30 +00:00
Neal Norwitz
a7edb11122
Whitespace normalization
2006-07-30 06:59:13 +00:00
Neal Norwitz
f71ec5a0ac
Bug #1515471 : string.replace() accepts character buffers again.
...
Pass the char* and size around rather than PyObject's.
2006-07-30 06:57:04 +00:00
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