| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
|
|
| |
Fix over-aggressive PyErr_Clear(). The same code fragment appears in
various guises in list.extend(), map(), filter(), zip(), and internally
in PySequence_Tuple().
|
|
|
|
|
|
|
| |
[ 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).
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
unsized iterable inputs.
|
| |
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
__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.
|
|
|
|
| |
Minor wording fix.
|
|
|
|
| |
attribute name lookup.
|
| |
|
|
|
|
|
| |
NULL in case of error, but the functions are declared to return int.
MSVC 6 properly complains about that. Return -1 on error instead.
|
|
|
|
| |
isinstance() or issubclass() to the recursion limit of the interpreter.
|
| |
|
|
|
|
| |
exposing _PyList_Extend().
|
|
|
|
|
|
|
| |
(Contributed by Greg Chapman.)
Since this only changes the error message, I doubt that it should be
backported.
|
|
|
|
|
| |
Formerly, the length was only fetched from sequence objects.
Now, any object that reports its length can benefit from pre-sizing.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
had slightly different error messages.
|
|
|
|
| |
The PyIter_Check is already performed by PyObject_GetIter.
|
|
|
|
| |
now have tp_as_number. Check for nb_int or nb_float.
|
| |
|
|
|
|
|
| |
instance, as long as x.__class__ is X or a subclass thereof.
Did a little cleanup of PyObject_IsInstance() too.
|
| |
|
|
|
|
| |
Plug the leak that Tim just reported.
|
|
|
|
|
|
|
| |
andsq_inplace_repeat. This fixes a number of corner case bugs (see #624807).
Consolidate the int and long sequence repeat code. Before the change, integers
checked for integer overflow but longs did not.
|
|
|
|
|
|
| |
containing class objects) are allowed as the second argument.
This makes issubclass() more similar to isinstance() where recursive
tuples are allowed too.
|
|
|
|
|
|
|
|
|
|
|
| |
supported as the second argument. This has the same meaning as
for isinstance(), i.e. issubclass(X, (A, B)) is equivalent
to issubclass(X, A) or issubclass(X, B). Compared to isinstance(),
this patch does not search the tuple recursively for classes, i.e.
any entry in the tuple that is not a class, will result in a
TypeError.
This closes SF patch #649608.
|
|
|
|
|
| |
Added related testcase.
Closes SF bug #643260.
|
|
|
|
| |
dereference rather than the caller.
|
|
|
|
| |
both have a nb_remainer slot.
|
|
|
|
|
| |
PyNumber_Remainder(). This fixes SF bug #615506 and allows string and unicode
subclasses to override __mod__.
|
|
|
|
| |
PySequence_Fast needs to do anything siginificant.
|
|
|
|
|
|
|
| |
-- replace then with slightly faster PyObject_Call(o,a,NULL). (The
difference is that the latter requires a to be a tuple; the former
allows other values and wraps them in a tuple if necessary; it
involves two more levels of C function calls to accomplish all that.)
|
| |
|
|
|
|
|
| |
Made conversion failure error messages consistent between types.
Added related unittests.
|
|
|
|
|
|
| |
Closes SF patch # 560250.
Bugfix candidate IMO.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
states can be for this function, and ensure that only AttributeErrors
are masked. Any other exception raised via the equivalent of
getattr(cls, '__bases__') should be propagated up.
abstract_issubclass(): If abstract_get_bases() returns NULL, we must
call PyErr_Occurred() to see if an exception is being propagated, and
return -1 or 0 as appropriate. This is the specific fix for a problem
whereby if getattr(derived, '__bases__') raised an exception, an
"undetected error" would occur (under a debug build). This nasty
situation was uncovered when writing a security proxy extension type
for the Zope3 project, where the security proxy raised a Forbidden
exception on getattr of __bases__.
PyObject_IsInstance(), PyObject_IsSubclass(): After both calls to
abstract_get_bases(), where we're setting the TypeError if the return
value is NULL, we must first check to see if an exception occurred,
and /not/ mask an existing exception.
Neil Schemenauer should double check that these changes don't break
his ExtensionClass examples (there aren't any test cases for those
examples and abstract_get_bases() was added by him in response to
problems with ExtensionClass). Neil, please add test cases if
possible!
I belive this is a bug fix candidate for Python 2.2.2.
|
|
|
|
|
|
|
|
|
| |
PyNumber_InPlaceMultiply insisted on calling sq_inplace_repeat if it
existed, even if nb_inplace_multiply also existed and the arguments
weren't right for sq_inplace_repeat. Change this to only use
sq_inplace_repeat if nb_inplace_multiply isn't defined.
Bugfix candidate.
|
| |
|
|
|
|
|
| |
If result == Py_NotImplemented, always DECREF it before assigning a
new value to result.
|
|
|
|
|
|
| |
PyNumber_Add() tries the nb_add slot first, then falls back to
sq_concat. However, tt didn't check the return value of sq_concat.
If sq_concat returns NotImplemented, raise the standard TypeError.
|
|
|
|
| |
to fix was almost certainly a bug in _PyLong_Copy (which I'll fix next).
|
|
|
|
|
|
|
|
|
|
| |
Due to the bizarre definition of _PyLong_Copy(), creating an instance
of a subclass of long with a negative value could cause core dumps
later on. Unfortunately it looks like the behavior of _PyLong_Copy()
is quite intentional, so the fix is more work than feels comfortable.
This fix is almost, but not quite, the code that Naofumi Honda added;
in addition, I added a test case.
|
| |
|
|
|
|
|
|
|
| |
confusing error messages. If a new-style class has no sequence or
mapping behavior, attempting to use the indexing notation with a
non-integer key would complain that the sequence index must be an
integer, rather than complaining that the operation is not supported.
|
|
|
|
|
|
| |
supports the single-segment readable buffer interface.
Add documentation for this and other PyObject_XXXBuffer() calls.
|