summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* SF bug #1238681: freed pointer is used in longobject.c:long_pow().Tim Peters2005-07-171-5/+8
| | | | | | | | | | In addition, long_pow() skipped a necessary (albeit extremely unlikely to trigger) error check when converting an int modulus to long. Alas, I was unable to write a test case that crashed due to either cause. Bugfix candidate.
* Fix:Michael W. Hudson2005-07-121-8/+13
| | | | | | | [ 1229429 ] missing Py_DECREF in PyObject_CallMethod Add a test in test_enumerate, which is a bit random, but suffices (reversed_new calls PyObject_CallMethod under some circumstances).
* SF bug 1185883: PyObject_Realloc can't safely take over a block currentlyTim Peters2005-07-101-27/+23
| | | | | | | | | | managed by C, because it's possible for the block to be smaller than the new requested size, and at the end of allocated VM. Trying to copy over nbytes bytes to a Python small-object block can segfault then, and there's no portable way to avoid this (we would have to know how many bytes starting at p are addressable, and std C has no means to determine that). Bugfix candidate. Should be backported to 2.4, but I'm out of time.
* Apparently some compiler gives a warning onMichael W. Hudson2005-06-301-1/+1
| | | | | | float y = x; when x is a double. Go figure.
* SF bug #1224347: int/long unification and hex()Raymond Hettinger2005-06-292-13/+7
| | | | Hex longs now print with lowercase letters like their int counterparts.
* Insert missing flag.Raymond Hettinger2005-06-191-1/+1
|
* SF patch #1200018: Restore GC support to set objectsRaymond Hettinger2005-06-181-7/+24
| | | | | Reverts 1.26 and 1.27. And adds cycle testing.
* fix object.__divmod__.__doc__Anthony Baxter2005-06-031-2/+8
| | | | backport candidate
* This is my patch:Michael W. Hudson2005-05-271-239/+509
| | | | | | | | | | | | | | [ 1181301 ] make float packing copy bytes when they can which hasn't been reviewed, despite numerous threats to check it in anyway if noone reviews it. Please read the diff on the checkin list, at least! The basic idea is to examine the bytes of some 'probe values' to see if the current platform is a IEEE 754-ish platform, and if so _PyFloat_{Pack,Unpack}{4,8} just copy bytes around. The rest is hair for testing, and tests.
* Disallow opening files with modes 'aU' or 'wU' as specified by PEPSkip Montanaro2005-05-201-0/+51
| | | | 278. Closes bug 967182.
* Fixed a quite misleading comment: a "not" should not have been there.Armin Rigo2005-05-151-1/+1
|
* SF patch #1200051: Small optimization for PyDict_Merge()Raymond Hettinger2005-05-141-0/+6
| | | | (Contributed by Barry Warsaw and Matt Messier.)
* Make subclasses of int, long, complex, float, and unicode perform typeBrett Cannon2005-04-265-75/+73
| | | | | | | conversion using the proper magic slot (e.g., __int__()). Also move conversion code out of PyNumber_*() functions in the C API into the nb_* function. Applied patch #1109424. Thanks Walter Doewald.
* As per discussion on python-dev, descriptors defined in C with a NULL setterBarry Warsaw2005-04-191-2/+2
| | | | | now raise AttributeError instead of TypeError, for consistency with their pure-Python equivalent.
* SF bug #1183742: PyDict_Copy() can return non-NULL value on errorRaymond Hettinger2005-04-151-1/+1
|
* Fix for rather inaccurately titled bugMichael W. Hudson2005-03-301-0/+6
| | | | | | | | | [ 1165306 ] Property access with decorator makes interpreter crash Don't allow the creation of unbound methods with NULL im_class, because attempting to call such crashes. Backport candidate.
* SF bug #1770766: weakref proxy has incorrect __nonzero__ behavior.Raymond Hettinger2005-03-271-5/+1
|
* SF bug #1155938: Missing None check for __init__().Raymond Hettinger2005-03-031-0/+6
|
* Revert previous checkin on getargs 'L' code. Try to convert allMartin v. Löwis2005-03-031-1/+22
| | | | | numbers in PyLong_AsLongLong, and update test suite accordingly. Backported to 2.4.
* * Beef-up tests for str.count().Raymond Hettinger2005-02-201-2/+7
| | | | * Speed-up str.count() by using memchr() to fly between first char matches.
* * Beef-up testing of str.__contains__() and str.find().Raymond Hettinger2005-02-201-13/+26
| | | | | | | | | | | | | | | | | | | * Speed-up "x in y" where x has more than one character. The existing code made excessive calls to the expensive memcmp() function. The new code uses memchr() to rapidly find a start point for memcmp(). In addition to knowing that the first character is a match, the new code also checks that the last character is a match. This significantly reduces the incidence of false starts (saving memcmp() calls and making quadratic behavior less likely). Improves the timings on: python -m timeit -r7 -s"x='a'*1000" "'ab' in x" python -m timeit -r7 -s"x='a'*1000" "'bc' in x" Once this code has proven itself, then string_find_internal() should refer to it rather than running its own version. Also, something similar may apply to unicode objects.
* FixMichael W. Hudson2005-02-171-2/+0
| | | | | | | | [ 1124295 ] Function's __name__ no longer accessible in restricted mode which I introduced with a bit of mindless copy-paste when making __name__ writable. You can't assign to __name__ in restricted mode, which I'm going to pretend was intentional :)
* Code simplification -- eliminate lookup when value is known in advance.Raymond Hettinger2005-02-051-2/+4
|
* More bug #1077106 stuff, sorry -- modem induced impatiece!Michael W. Hudson2005-01-311-0/+1
| | | | This should go on whatever bugfix branches the other fetches up on.
* Dima Dorfman's patch for coercion/comparison of C types (patch #995939), withArmin Rigo2004-12-231-16/+11
| | | | | a minor change after the coercion, to accept two objects not necessarily of the same type but with the same tp_compare.
* Bug #1079011: Incorrect error message (somewhat)Raymond Hettinger2004-12-191-1/+1
|
* Small boost to PySequence_Fast(). Lists build faster than tuples forRaymond Hettinger2004-12-181-1/+1
| | | | unsized iterable inputs.
* Add missing decref.Raymond Hettinger2004-12-161-0/+1
|
* SF bug #1085744: Performance issues with PySequence_Tuple()Raymond Hettinger2004-12-161-4/+14
| | | | | | | * Added missing error checks. * Fixed O(n**2) growth pattern. Modeled after lists to achieve linear amortized resizing. Improves construction of "tuple(it)" when "it" is large and does not have a __len__ method. Other cases are unaffected.
* Remove PyRange_New().Raymond Hettinger2004-12-031-45/+0
|
* Correct the handling of 0-termination of PyUnicode_AsWideChar()Marc-André Lemburg2004-11-221-1/+7
| | | | | | | | and its usage in PyLocale_strcoll(). Clarify the documentation on this. Thanks to Andreas Degert for pointing this out.
* SF 1062353: set pickling problemsRaymond Hettinger2004-11-091-2/+9
| | | | Support automatic pickling of dictionaries in instance of set subclasses.
* If close() fails in file_dealloc, then print an error message toPeter Astrand2004-11-071-1/+8
| | | | | stderr. close() can fail if the user is out-of-quota, for example. Fixes #959379.
* SF 1055820: weakref callback vs gc vs threadsTim Peters2004-10-301-1/+3
| | | | | | | | In cyclic gc, clear weakrefs to unreachable objects before allowing any Python code (weakref callbacks or __del__ methods) to run. This is a critical bugfix, affecting all versions of Python since weakrefs were introduced. I'll backport to 2.3.
* Wrote down the invariants of some common objects whose structure isArmin Rigo2004-10-281-0/+12
| | | | | | | | | | exposed in header files. Fixed a few comments in these headers. As we might have expected, writing down invariants systematically exposed a (minor) bug. In this case, function objects have a writeable func_code attribute, which could be set to code objects with the wrong number of free variables. Calling the resulting function segfaulted the interpreter. Added a corresponding test.
* SF bug #1054139: serious string hashing error in 2.4b1Raymond Hettinger2004-10-261-0/+1
| | | | | _PyString_Resize() readied strings for mutation but did not invalidate the cached hash value.
* Applied patch for [ 1047269 ] Buffer overwrite in PyUnicode_AsWideChar.Marc-André Lemburg2004-10-151-2/+2
| | | | Python 2.3.x candidate.
* Finalize the freelist of list objects.Raymond Hettinger2004-10-071-0/+13
|
* Use Py_CLEAR(). Add unrelated test.Raymond Hettinger2004-09-281-1/+1
|
* Checkin Tim's fix to an error discussed on python-dev.Raymond Hettinger2004-09-261-10/+20
| | | | | | | | | | | | | | | | | Also, add a testcase. Formerly, the list_extend() code used several local variables to remember its state across iterations. Since an iteration could call arbitrary Python code, it was possible for the list state to be changed. The new code uses dynamic structure references instead of C locals. So, they are always up-to-date. After list_resize() is called, its size has been updated but the new cells are filled with NULLs. These needed to be filled before arbitrary iteration code was called; otherwise, that code could attempt to modify a list that was in a semi-invalid state. The solution was to change the ob->size field back to a value reflecting the actual number of valid cells.
* Remove 'extern' declaration for _Py_SwappedOp.Brett Cannon2004-09-251-1/+1
|
* Ensure negative offsets cannot be passed to buffer(). When composingNeil Schemenauer2004-09-241-2/+15
| | | | | buffers, compute the new buffer size based on the old buffer size. Fixes SF bug #1034242.
* Fix buffer offset calculation (need to compute it before changingNeil Schemenauer2004-09-241-11/+7
| | | | | 'base'). Fixes SF bug #1033720. Move offset sanity checking to buffer_from_memory().
* float_richcompare(): Use the new Py_IS_NAN macro to ensure that, onTim Peters2004-09-231-11/+9
| | | | | platforms where that macro works, NaN compared to an int or long works the same as NaN compared to a finite float.
* SF bug #513866: Float/long comparison anomaly.Tim Peters2004-09-231-8/+206
| | | | | | | | | | | | | | | | | | When an integer is compared to a float now, the int isn't coerced to float. This avoids spurious overflow exceptions and insane results. This should compute correct results, without raising spurious exceptions, in all cases now -- although I expect that what happens when an int/long is compared to a NaN is still a platform accident. Note that we had potential problems here even with "short" ints, on boxes where sizeof(long)==8. There's #ifdef'ed code here to handle that, but I can't test it as intended. I tested it by changing the #ifdef to trigger on my 32-bit box instead. I suppose this is a bugfix candidate, but I won't backport it. It's long-winded (for speed) and messy (because the problem is messy). Note that this also depends on a previous 2.4 patch that introduced _Py_SwappedOp[] as an extern.
* A static swapped_op[] array was defined in 3 different C files, & I thinkTim Peters2004-09-233-12/+6
| | | | | I need to define it again. Bite the bullet and define it once as an extern, _Py_SwappedOp[].
* Patch #1024670: Support int objects in PyLong_AsUnsignedLong[Mask].Martin v. Löwis2004-09-201-0/+11
|
* SF bug #1030557: PyMapping_Check crashes when argument is NULLRaymond Hettinger2004-09-191-2/+2
| | | | | | Make PySequence_Check() and PyMapping_Check() handle NULL inputs. This goes beyond what most of the other checks do, but it is nice defensive programming and solves the OP's problem.
* Initialize sep and seplen to suppress warning from gcc.Skip Montanaro2004-09-161-3/+3
|
* Add a missing line continuation character.Thomas Heller2004-09-151-1/+1
|