summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix Issue 1045.Raymond Hettinger2007-12-061-30/+38
| | | | | Factor-out common calling code by simplifying the length_hint API. Speed-up the function by caching the PyObject_String for the attribute lookup.
* merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ ↵Christian Heimes2007-12-051-2/+3
| | | | can make list() raise a SystemError
* Properly indent two lines. (Spotted because it caused merge conflicts in theThomas Wouters2007-09-181-2/+2
| | | | py3k branch ;)
* Patch # 1026 by Benjamin Aranguren (with Alex Martelli):Guido van Rossum2007-09-101-0/+40
| | | | | | | | Backport abc.py and isinstance/issubclass overloading to 2.6. I had to backport test_typechecks.py myself, and make one small change to abc.py to avoid duplicate work when x.__class__ and type(x) are the same.
* Fix a crasher where Python code managed to infinitely recurse in C code withoutBrett Cannon2007-09-071-1/+5
| | | | | | | ever going back out to Python code in PyObject_Call(). Required introducing a static RuntimeError instance so that normalizing an exception there is no reliance on a recursive call that would put the exception system over the recursion check itself.
* Silence compiler warningRaymond Hettinger2007-02-071-1/+1
|
* Bug #1575169: operator.isSequenceType() now returns False for subclasses of ↵Raymond Hettinger2007-02-071-0/+2
| | | | dict.
* Forward-port of r52136,52138: a review of overflow-detecting code.Armin Rigo2006-10-041-8/+6
| | | | | | | | | | | | | | | | | | | | | | | * 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...
* Subclasses of int/long are allowed to define an __index__.Neal Norwitz2006-08-151-4/+2
|
* Patch #1538606, Patch to fix __index__() clipping.Neal Norwitz2006-08-121-21/+84
| | | | | | | 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.
* Remove "non-mapping" and "non-sequence" from TypeErrors raised byGeorg Brandl2006-08-081-2/+2
| | | | | | | 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.
* Fix for an obscure bug introduced by revs 46806 and 46808, with a test.Armin Rigo2006-06-211-11/+1
| | | | | | | | | | | | | | 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.
* Patch #1507676: improve exception messages in abstract.c, object.c and ↵Georg Brandl2006-06-181-39/+43
| | | | typeobject.c.
* Fix bug introduced in rev. 46806 by not having variable declaration at the ↵Brett Cannon2006-06-091-2/+4
| | | | top of a block.
* An object with __call__ as an attribute, when called, will have that ↵Brett Cannon2006-06-091-0/+8
| | | | | | 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.
* Fix coding style guide bug.Brett Cannon2006-06-061-1/+2
|
* C++ compilation cleanup: Migrate declaration ofSkip Montanaro2006-04-181-7/+0
| | | | | _PyObject_Call(Function|Method)_SizeT into Include/abstract.h. This gets them under the umbrella of the extern "C" { ... } block in that file.
* Make Py_BuildValue, PyObject_CallFunction andMartin v. Löwis2006-04-141-28/+90
| | | | PyObject_CallMethod aware of PY_SSIZE_T_CLEAN.
* Minor bugs in the __index__ code (PEP 357), with tests.Armin Rigo2006-03-301-2/+3
|
* Stop duplicating code and handle slice indices consistently and correctlyNeal Norwitz2006-03-231-20/+2
| | | | wrt to ssize_t.
* Update function name to reflect params and stop casting to long to avoid ↵Neal Norwitz2006-03-201-5/+5
| | | | losing data
* Checking in the code for PEP 357.Guido van Rossum2006-03-071-44/+32
| | | | | | This was mostly written by Travis Oliphant. I've inspected it all; Neal Norwitz and MvL have also looked at it (in an earlier incarnation).
* Change some sequnce APIs to use Py_ssize_t.Neal Norwitz2006-03-041-5/+9
|
* Revert backwards-incompatible const changes.Martin v. Löwis2006-02-271-1/+1
|
* Use Py_ssize_t for counts and sizes.Martin v. Löwis2006-02-161-2/+2
| | | | Convert Py_ssize_t using PyInt_FromSsize_t
* Merge ssize_t branch.Martin v. Löwis2006-02-151-43/+43
|
* Renamed _length_cue() to __length_hint__(). See:Armin Rigo2006-02-111-3/+3
| | | | http://mail.python.org/pipermail/python-dev/2006-February/060524.html
* Remove some shadowed variablesNeal Norwitz2006-01-081-1/+1
|
* SF patch #1390657:Armin Rigo2005-12-291-6/+45
| | | | | | | | | | | | | | | | | * set sq_repeat and sq_concat to NULL for user-defined new-style classes, as a way to fix a number of related problems. See test_descr.notimplemented()). One of these problems was fixed in r25556 and r25557 but many more existed; this is a general fix and thus reverts r25556-r25557. * to avoid having PySequence_Repeat()/PySequence_Concat() failing on user-defined classes, they now fall back to nb_add/nb_mul if sq_concat/sq_repeat are not defined and the arguments appear to be sequences. * added tests. Backport candidate.
* Convert iterator __len__() methods to a private API.Raymond Hettinger2005-09-241-1/+26
|
* SF bug #1242657: list(obj) can swallow KeyboardInterruptRaymond Hettinger2005-08-211-0/+5
| | | | | | Fix over-aggressive PyErr_Clear(). The same code fragment appears in various guises in list.extend(), map(), filter(), zip(), and internally in PySequence_Tuple().
* 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).
* Make subclasses of int, long, complex, float, and unicode perform typeBrett Cannon2005-04-261-47/+37
| | | | | | | 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.
* 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.
* 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.
* Check the type of values returned by __int__, __float__, __long__,Neil Schemenauer2004-07-191-6/+33
| | | | | | __oct__, and __hex__. Raise TypeError if an invalid type is returned. Note that PyNumber_Int and PyNumber_Long can still return ints or longs. Fixes SF bug #966618.
* SF bug #952866: "can't multiply sequence *by* non-int"Raymond Hettinger2004-05-121-1/+1
| | | | Minor wording fix.
* Improve previous checkin to use a slot check instead of equivalentRaymond Hettinger2004-04-051-1/+2
| | | | attribute name lookup.
* Improve accuracy of sequence and mapping checks.Raymond Hettinger2004-04-041-2/+8
|
* recursive_isinstance(), recursive_issubclass(): New code here returnedTim Peters2004-03-211-2/+2
| | | | | NULL in case of error, but the functions are declared to return int. MSVC 6 properly complains about that. Return -1 on error instead.
* Limit the nesting depth of a tuple passed as the second argument toBrett Cannon2004-03-201-9/+36
| | | | isinstance() or issubclass() to the recursion limit of the interpreter.
* Add missing decrefRaymond Hettinger2004-03-171-0/+1
|
* Eliminate a big block of duplicate code in PySequence_List() byRaymond Hettinger2004-03-111-54/+6
| | | | exposing _PyList_Extend().
* SF Patch #871704: Py_SequenceFast can mask errorsRaymond Hettinger2004-01-111-3/+11
| | | | | | | (Contributed by Greg Chapman.) Since this only changes the error message, I doubt that it should be backported.
* Apply pre-sizing optimization to a broader class of objects.Raymond Hettinger2004-01-041-8/+4
| | | | | Formerly, the length was only fetched from sequence objects. Now, any object that reports its length can benefit from pre-sizing.
* Apply tuple/list pre-sizing optimization to a broader class of objects.Raymond Hettinger2004-01-041-1/+1
| | | | | | | | Formerly, length data fetched from sequence objects. Now, any object that reports its length can benefit from pre-sizing. On one sample timing, it gave a threefold speedup for list(s) where s was a set object.
* Fix Greg Ward's error message nit: PyObject_SetItem and PySequenceSetItemRaymond Hettinger2003-10-271-1/+1
| | | | had slightly different error messages.
* Removed duplicate test from inner loop.Raymond Hettinger2003-03-011-6/+1
| | | | The PyIter_Check is already performed by PyObject_GetIter.