summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* New private API function _PyInstance_Lookup. gc will use this to figureTim Peters2003-04-071-0/+21
| | | | out whether __del__ exists, without executing any Python-level code.
* SF bug #699934: Obscure error messageRaymond Hettinger2003-04-061-4/+2
| | | | | mwh pointed out that the error message did not make sense if obtained by rearranging the bases.
* Change formatchar(), so that u"%c" % 0xffffffff now raisesWalter Dörwald2003-04-021-2/+2
| | | | | an OverflowError instead of a TypeError to be consistent with "%c" % 256. See SF patch #710127.
* Fix PyString_Format() so that '%c' % u'a' returns u'a'Walter Dörwald2003-03-311-0/+7
| | | | | | | | instead of raising a TypeError. (From SF patch #710127) Add tests to verify this is fixed. Add various tests for '%c' % int.
* Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.Martin v. Löwis2003-03-291-22/+22
|
* Refactoring: rename update_these_slots() into update_subclasses() andGuido van Rossum2003-03-241-47/+68
| | | | | generalize to take a callback function and a void * data argument. This might come in handy later... :-)
* Typo in comment.Tim Peters2003-03-231-1/+1
|
* Improved new Py_TRACE_REFS gimmicks.Tim Peters2003-03-232-18/+37
| | | | | | | | | | | Arranged that all the objects exposed by __builtin__ appear in the list of all objects. I basically peed away two days tracking down a mystery leak in sys.gettotalrefcount() in a ZODB app (== tons of code), because the object leaking the references didn't appear in the sys.getobjects(0) list. The object happened to be False. Now False is in the list, along with other popular & previously missing leak candidates (like None). Alas, we still don't have a choke point covering *all* Python objects, so the list of all objects may still be incomplete.
* slot_sq_contains(): This leaked a reference to the result of callingTim Peters2003-03-231-11/+12
| | | | | | __contains__(). Bugfix candidate.
* Refactored some of the Py_TRACE_REFS code. New private API functionTim Peters2003-03-232-10/+26
| | | | | | | _Py_AddToAllObjects() that simply inserts an object at the front of the doubly-linked list of all objects. Changed PyType_Ready() (the closest thing we've got to a choke point for type objects) to call that.
* Oops! Used a wrong preprocessor symbol.Tim Peters2003-03-231-1/+1
|
* When Py_TRACE_REFS is defined, a list of all live objects is maintained inTim Peters2003-03-231-2/+15
| | | | | | | | | | | a doubly-linked list, exposed by sys.getobjects(). Unfortunately, it's not really all live objects, and it seems my fate to bump into programs where sys.gettotalrefcount() keeps going up but where the reference leaks aren't accounted for by anything in the list of all objects. This patch helps a little: if COUNT_ALLOCS is also defined, from now on type objects will also appear in this list, provided at least one object of a type has been allocated.
* _PyFloat_Pack4(): Removed needless call of floor().Tim Peters2003-03-211-1/+1
|
* New private API functions _PyFloat_{Pack,Unpack}(4,8}. This is aTim Peters2003-03-201-0/+313
| | | | | refactoring to get all the duplicates of this delicate code out of the cPickle and struct modules.
* Renamed PyObject_GenericGetIter to PyObject_SelfIterRaymond Hettinger2003-03-177-8/+8
| | | | | | to more accurately describe what the function does. Suggested by Thomas Wouters.
* Created PyObject_GenericGetIter().Raymond Hettinger2003-03-177-51/+14
| | | | Factors out the common case of returning self.
* SF bug #699934: Obscure error messageRaymond Hettinger2003-03-121-1/+4
| | | | Clarify error message for mro conflicts.
* Sf patch #700047: unicode object leaks refcount on resizingRaymond Hettinger2003-03-091-0/+1
| | | | Contributed by Hye-Shik Chang.
* - The extended type structure used for heap types (new-styleGuido van Rossum2003-03-071-49/+34
| | | | | classes defined by Python code using a class statement) is now exported from object.h as PyHeapTypeObject. (SF patch #696193.)
* SF patch #693753: fix for bug 639806: default for dict.popRaymond Hettinger2003-03-061-3/+15
| | | | (contributed by Michael Stone.)
* Fix from Greg Chapman from SF bug #695651: a complex subclassGuido van Rossum2003-03-021-2/+3
| | | | | | | | | | | | | | constructor, when passed a single complex argument, returns the argument unchanged. This should be done only for the complex base class; a complex subclass should of course cast the value to the subclass in this case. The fix also revealed a segfault in complex_getnewargs(): the argument for the Py_BuildValue() format code "D" is the *address* of a Py_complex struct, not the value. (This corroborated by the API documentation.) I expect this needs to be backported to 2.2.3.
* Removed duplicate test from inner loop.Raymond Hettinger2003-03-011-6/+1
| | | | The PyIter_Check is already performed by PyObject_GetIter.
* Fix SF bug #689659, 64-bit int and long hash keys incompatibleNeal Norwitz2003-02-231-2/+4
| | | | | On a 64-bit machine, a dictionary could contain duplicate int/long keys if the value was > 2**32.
* Implementing the salient parts of __reduce_ex__ in C.Guido van Rossum2003-02-211-6/+229
| | | | | | | This still falls back to helpers in copy_reg for: - pickle protocols < 2 - calculating the list of slot names (done only once per class) - the __newobj__ function (which is used as a token but never called)
* Strange control flow in PyInt_AsLong. When nb_int is called insideThomas Heller2003-02-201-3/+3
| | | | | | | | the PyInt_AsLong function, and this returns a long, the value is first retrieved with PyLong_AsLong, but afterwards overwritten by a call to PyInt_AS_LONG. Fixes SF #690253.
* PyObject_Generic{Get,Set}Attr:Guido van Rossum2003-02-191-2/+4
| | | | | | | | | | Don't access tp_descr_{get,set} of a descriptor without checking the flag bits of the descriptor's type. While we know that the main type (the type of the object whose attribute is being accessed) has all the right flag bits (or else PyObject_Generic{Get,Set}Attr wouldn't be called), we don't know that for its class attributes! Will backport to 2.2.
* Introducing __reduce_ex__, which is called with a protocol number argumentGuido van Rossum2003-02-181-4/+10
| | | | | if it exists in preference over __reduce__. Now Tim can go implement this in cPickle.c.
* Removed unreferenced label.Tim Peters2003-02-181-2/+1
|
* The recent changes to super(), in particular supercheck(), broke whenGuido van Rossum2003-02-181-9/+7
| | | | | | | | using super() for an instance in a metaclass situation. Because the class was a metaclass, the instance was a class, and hence the PyType_Check() branch was taken. But this branch didn't apply. Make it so that if this branch doesn't apply, the other branch is still tried. All tests pass.
* Make __module__ writable except in restricted mode (like for classic classes).Guido van Rossum2003-02-182-2/+2
|
* Make __module__ settable on functions and methods.Jeremy Hylton2003-02-182-2/+2
|
* default_3way_compare(): use PyNumber_Check(), rather than testing forGuido van Rossum2003-02-181-3/+3
| | | | tp_as_number directly.
* Make PyNumber_Check() a bit more careful, since all sorts of thingsGuido van Rossum2003-02-181-1/+3
| | | | now have tp_as_number. Check for nb_int or nb_float.
* Add closing ) in commentNeal Norwitz2003-02-151-1/+1
|
* cPickle.c, load_build(): Taught cPickle how to pick apartTim Peters2003-02-151-1/+11
| | | | | | | | | | | | | | | | | | the optional proto 2 slot state. pickle.py, load_build(): CAUTION: Noted that cPickle's load_build and pickle's load_build really don't do the same things with the state, and didn't before this patch either. cPickle never tries to do .update(), and has no backoff if instance.__dict__ can't be retrieved. There are no tests that can tell the difference, and part of what cPickle's load_build() did looked accidental to me, so I don't know what the true intent is here. pickletester.py, test_pickle.py: Got rid of the hack for exempting cPickle from running some of the proto 2 tests. dictobject.c, PyDict_Next(): documented intended use.
* SF patch #685738 by Michael Stone.Guido van Rossum2003-02-131-1/+19
| | | | | | | This changes the default __new__ to refuse arguments iff tp_init is the default __init__ implementation -- thus making it a TypeError when you try to pass arguments to a constructor if the class doesn't override at least __init__ or __new__.
* Issue a warning when int('0...', 0) returns an int with the signGuido van Rossum2003-02-121-2/+12
| | | | | | | | folded; this will change in Python 2.4. On a 32-bit machine, this happens for 0x80000000 through 0xffffffff, and for octal constants in the same value range. No warning is issued if an explicit base is given, *or* if the string contains a sign (since in those cases no sign folding ever happens).
* Implement another useful feature for proxies: in super(X, x), x mayGuido van Rossum2003-02-121-17/+83
| | | | now be a proxy for an X instance, as long as issubclass(x.__class__, X).
* Add missing cast in previous fix.Guido van Rossum2003-02-121-1/+2
|
* SF #532767: isinstance(x, X) should work when x is a proxy for an XGuido van Rossum2003-02-121-6/+19
| | | | | instance, as long as x.__class__ is X or a subclass thereof. Did a little cleanup of PyObject_IsInstance() too.
* Add more missing PyErr_NoMemory() after failled memory allocsNeal Norwitz2003-02-111-1/+1
|
* Fix from SF #681367: inherit tp_as_buffer. This only applies to CGuido van Rossum2003-02-111-0/+2
| | | | types -- Python types already inherited this.
* Put proper tests in classmethod_get(). Remove the type argument toGuido van Rossum2003-02-111-16/+47
| | | | | | descr_check(); it wasn't useful. Change the type argument of the various _get() methods to PyObject * because the call signature of tp_descr_get doesn't guarantee its type.
* Refactor instancemethod_descr_get() to (a) be more clear, (b) be safeGuido van Rossum2003-02-111-8/+18
| | | | | in the light of weird args, and (c) not to expect None (which is now changed to NULL by slot_tp_descr_get()).
* Inline create_specialmethod() -- since METH_CLASS is done differentlyGuido van Rossum2003-02-111-15/+5
| | | | | now, it was only called once, and its existence merely obfuscates the control flow.
* Add basic arg sanity checking to wrap_descr_get(). This is calledGuido van Rossum2003-02-111-0/+9
| | | | | | | when Python code calls a descriptor's __get__ method. It should translate None to NULL in both argument positions, and insist that at least one of the argument positions is not NULL after this transformation.
* Get rid of the "bozo" __getstate__ that was inserted when __slots__Guido van Rossum2003-02-101-32/+0
| | | | | | was used. This simplifies some logic in copy_reg.py (used by pickling). It also broke a test, but this was rewritten to test the new feature. :-)
* Fold long lines.Guido van Rossum2003-02-101-4/+7
|
* Fix SF bug #683467, 'int' ability to generate longs not inheritedNeal Norwitz2003-02-101-2/+16
| | | | | | When subclassing from an int but not overriding __new__, long values were not converted properly. Try to convert longs into an int.
* Fix two refcounting bugsWalter Dörwald2003-02-091-2/+4
|