summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
Commit message (Collapse)AuthorAgeFilesLines
* Code by Inyeol Lee, submitted to SF bug 595350, to implementGuido van Rossum2002-08-231-4/+0
| | | | | the string/unicode method .replace() with a zero-lengt first argument. Inyeol contributed tests for this too.
* Add tests for including __dict__ and/or __weakref__ in __slots__.Guido van Rossum2002-08-131-1/+50
| | | | Add some more rigor to slotmultipleinheritance().
* Add test for SF bug # 575229, multiple inheritance w/ slots dumps coreNeal Norwitz2002-08-131-0/+11
| | | | Fix already checked in by Guido
* Disallow class assignment completely unless both old and new are heapGuido van Rossum2002-08-101-0/+5
| | | | | types. This prevents nonsense like 2.__class__ = bool or True.__class__ = int.
* Test for Neil's fix to correctly invoke __rmul__.Guido van Rossum2002-08-091-0/+16
|
* Add testcase for SF bug 574207 (chained __slots__ dealloc segfault).Guido van Rossum2002-08-061-0/+14
| | | | Fix forthcoming.
* SF patch 588728 (Nathan Srebro).Guido van Rossum2002-08-011-4/+11
| | | | | | | | The __delete__ method wrapper for descriptors was not supported (I added a test, too.) 2.2 bugfix candidate.
* Get rid of relative imports in all unittests. Now anything thatBarry Warsaw2002-07-231-1/+1
| | | | | | | | | | | imports e.g. test_support must do so using an absolute package name such as "import test.test_support" or "from test import test_support". This also updates the README in Lib/test, and gets rid of the duplicate data dirctory in Lib/test/data (replaced by Lib/email/test/data). Now Tim and Jack can have at it. :)
* subtype_resurrection(): Removed unused import.Tim Peters2002-07-111-1/+0
|
* subtype_resurrection(): The test suite with -l properly reported theTim Peters2002-07-111-2/+13
| | | | immortal object here as a leak. Made the object mortal again at the end.
* Repaired optimistic comment in new test.Tim Peters2002-07-111-4/+3
|
* Added a test that provokes the hypothesized (in my last checkin comment)Tim Peters2002-07-111-0/+20
| | | | | | | | | | | debug-build failure when an instance of a new-style class is resurrected by a __del__ method -- we simply never had any code that tried this. This is already fixed in 2.3 CVS. In 2.2.1, it blows up via Fatal Python error: GC object already in linked list I'll fix it in 2.2.1 CVS next.
* Fix SF bug 572567: Memory leak in object comparison.Raymond Hettinger2002-06-241-0/+12
|
* SF 569257 -- Name mangle double underscored variable names in __slots__.Raymond Hettinger2002-06-201-0/+18
|
* Patch from SF bug 570483 (Tim Northover).Guido van Rossum2002-06-181-0/+6
| | | | | | In a fresh interpreter, type.mro(tuple) would segfault, because PyType_Ready() isn't called for tuple yet. To fix, call PyType_Ready(type) if type->tp_dict is NULL.
* Test for the bug in recurse_down_subclasses() that I just fixed.Guido van Rossum2002-06-141-0/+10
|
* Hopefully this addresses the remaining issues of SF bugs 459235 andGuido van Rossum2002-06-131-0/+46
| | | | | | 473985. Through a subtle rearrangement of some members in the etype struct (!), mapping methods are now preferred over sequence methods, which is necessary to support str.__getitem__("hello", slice(4)) etc.
* Fix from SF patch 565085: copy._reduction doesn't __setstate__.Guido van Rossum2002-06-061-0/+29
| | | | | | Straightforward fix. Will backport to 2.2. If there's ever a new 2.1 release, this could be backported there too (since it's an issue with anything that's got both a __reduce__ and a __setstate__).
* Address SF bug 519621: slots weren't traversed by GC.Guido van Rossum2002-06-041-0/+51
| | | | | | | | | | | | | | While I was at it, I added a tp_clear handler and changed the tp_dealloc handler to use the clear_slots helper for the tp_clear handler. Also tightened the rules for slot names: they must now be proper identifiers (ignoring the dirty little fact that <ctype.h> is locale sensitive). Also set mp->flags = READONLY for the __weakref__ pseudo-slot. Most of this is a 2.2 bugfix candidate; I'll apply it there myself.
* Test repair now that module.__init__ requires a name and initializesGuido van Rossum2002-06-041-6/+7
| | | | __name__ and __doc__.
* The warning filter was ineffective when this module was invoked as aGuido van Rossum2002-06-031-1/+1
| | | | script.
* Fix for SF bug 551412. When _PyType_Lookup() is called on a typeGuido van Rossum2002-05-241-0/+16
| | | | | | whose tp_mro hasn't been initialized, it would dump core. Fix this by checking for NULL and calling PyType_Ready(). Will fix this in 2.2.1 too.
* Jim Fulton reported a segfault in dir(). A heavily proxied objectGuido van Rossum2002-05-131-0/+20
| | | | | | | | returned a proxy for __class__ whose __bases__ was also a proxy. The merge_class_dict() helper for dir() assumed incorrectly that __bases__ would always be a tuple and used the in-line tuple API on the proxy. I will backport this to 2.2 as well.
* ceval.c/do_raise(): Tighten the test to disallow raising an instance ofTim Peters2002-04-181-0/+26
| | | | | | | | a str subclass. test_descr.py/string_exceptions(): New sub-test. For 2.3 only. Guido doesn't want this backported.
* SF bug 542984.Guido van Rossum2002-04-181-0/+20
| | | | | | | | | | | Change type_get_doc (the get function for __doc__) to look in tp_dict more often, and if it finds a descriptor in tp_dict, to call it (with a NULL instance). This means you can add a __doc__ descriptor to a new-style class that returns instance docs when called on an instance, and class docs when called on a class -- or the same docs in either case, but lazily computed. I'll also check this into the 2.2 maintenance branch.
* SF bug 544647.Guido van Rossum2002-04-161-0/+27
| | | | | | | | | 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.
* Fewer deprecation warnings.Tim Peters2002-04-161-0/+5
|
* SF bug #541883 (Vincent Fiack).Guido van Rossum2002-04-151-0/+6
| | | | | | | A stupid bug in object_set_class(): didn't check for value==NULL before checking its type. Bugfix candidate.
* - Changed new-style class instantiation so that when C's __new__Guido van Rossum2002-04-061-0/+22
| | | | | method returns something that's not a C instance, its __init__ is not called. [SF bug #537450]
* Add the 'bool' type and its values 'False' and 'True', as described inGuido van Rossum2002-04-031-1/+1
| | | | | | | | | | | | | PEP 285. Everything described in the PEP is here, and there is even some documentation. I had to fix 12 unit tests; all but one of these were printing Boolean outcomes that changed from 0/1 to False/True. (The exception is test_unicode.py, which did a type(x) == type(y) style comparison. I could've fixed that with a single line using issubtype(x, type(y)), but instead chose to be explicit about those places where a bool is expected. Still to do: perhaps more documentation; change standard library modules to return False/True from predicates.
* SF patch 537536 by Phillip J. Eby, fix for SF bug 535444, super()Guido van Rossum2002-04-021-0/+8
| | | | | | broken w/ classmethods. Bugfix candidate.
* There is no TestError, use TestFailed appropriatelyNeal Norwitz2002-04-011-1/+1
|
* Add a simple test of the METH_CLASS and METH_STATIC flags for type methods.Fred Drake2002-03-281-0/+30
|
* Add tests for the iterkeys, itervalues and iteritemsWalter Dörwald2002-03-251-0/+29
| | | | methods in dict-proxy objects.
* Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfaultGuido van Rossum2002-03-181-0/+5
| | | | | | | | | | | The proper fix is not quite what was submitted; it's really better to take the class of the object passed rather than calling PyMethod_New with NULL pointer args, because that can then cause other core dumps later. I also added a testcase for the fix to classmethods() in test_descr.py. I've already applied this to the 2.2 branch.
* "Fix" for SF bug #520644: __slots__ are not pickled.Guido van Rossum2002-03-141-0/+89
| | | | | | | | | | | As promised in my response to the bug report, I'm not really fixing it; in fact, one could argule over what the proper fix should do. Instead, I'm adding a little magic that raises TypeError if you try to pickle an instance of a class that has __slots__ but doesn't define or override __getstate__. This is done by adding a bozo __getstate__ that always raises TypeError. Bugfix candidate (also the checkin to typeobject.c, of course).
* Test for the fix I just checked in to moduleobject.c.Guido van Rossum2002-03-121-0/+12
| | | | Bugfix candidate.
* Fix typoNeal Norwitz2002-03-111-1/+1
|
* Add a check that SF bug 516727 is really fixed.Guido van Rossum2002-03-111-0/+10
|
* Bugfix candidate.Guido van Rossum2002-03-111-0/+3
| | | | | | | Adapter from SF patch 528038; fixes SF bug 527816. The wrapper for __nonzero__ should be wrap_inquiry rather than wrap_unaryfunc, since the slot returns an int, not a PyObject *.
* _PyLong_Copy(): was creating a copy of the absolute value, but shouldTim Peters2002-03-021-0/+1
| | | | | | copy the sign too. Added a test to test_descr to ensure that it does. Bugfix candidate.
* SF patch 514641 (Naofumi Honda) - Negative ob_size of LongObjectsGuido van Rossum2002-03-011-0/+4
| | | | | | | | | | 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.
* Fix for SF bug ##497426: can't deepcopy recursive new objectsGuido van Rossum2001-12-281-1/+10
| | | | | | | | deepcopy(), _reconstruct(): pass the memo to the other function, so that recursive data structures built out of new-style objects may be deeply copied correctly. 2.2.1 bugfix!
* (Merge into trunk.)Guido van Rossum2001-12-141-0/+10
| | | | | | | | | | | | | | | | | Fix for SF bug #492345. (I could've sworn I checked this in, but apparently I didn't!) This code: class Classic: pass class New(Classic): __metaclass__ = type attempts to create a new-style class with only classic bases -- but it doesn't work right. Attempts to fix it so it works caused problems elsewhere, so I'm now raising a TypeError in this case.
* Additional coverage tests by Neil Norwitz.Guido van Rossum2001-12-111-0/+66
| | | | (SF patch #491418, #491420, #491421.)
* SF bug #488514: -Qnew needs workTim Peters2001-12-061-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Big Hammer to implement -Qnew as PEP 238 says it should work (a global option affecting all instances of "/"). pydebug.h, main.c, pythonrun.c: define a private _Py_QnewFlag flag, true iff -Qnew is passed on the command line. This should go away (as the comments say) when true division becomes The Rule. This is deliberately not exposed to runtime inspection or modification: it's a one-way one-shot switch to pretend you're using Python 3. ceval.c: when _Py_QnewFlag is set, treat BINARY_DIVIDE as BINARY_TRUE_DIVIDE. test_{descr, generators, zipfile}.py: fiddle so these pass under -Qnew too. This was just a matter of s!/!//! in test_generators and test_zipfile. test_descr was trickier, as testbinop() is passed assumptions that "/" is the same as calling a "__div__" method; put a temporary hack there to call "__truediv__" instead when the method name is "__div__" and 1/2 evaluates to 0.5. Three standard tests still fail under -Qnew (on Windows; somebody please try the Linux tests with -Qnew too! Linux runs a whole bunch of tests Windows doesn't): test_augassign test_class test_coercion I can't stay awake longer to stare at this (be my guest). Offhand cures weren't obvious, nor was it even obvious that cures are possible without major hackery. Question: when -Qnew is in effect, should calls to __div__ magically change into calls to __truediv__? See "major hackery" at tail end of last paragraph <wink>.
* Fix SF bug #489581: __slots__ leak.Guido van Rossum2001-12-051-0/+34
| | | | | | It was easier than I thought, assuming that no other things contribute to the instance size besides slots -- a pretty good bet. With a test suite, no less!
* At the PythonLabs meeting someone mentioned it would make Jim reallyGuido van Rossum2001-12-051-6/+1
| | | | | | | | | happy if one could delete the __dict__ attribute of an instance. I love to make Jim happy, so here goes... - New-style objects now support deleting their __dict__. This is for all intents and purposes equivalent to assigning a brand new empty dictionary, but saves space if the object is not used further.
* Fix SF bug #486144: Uninitialized __slot__ vrbl is None.Guido van Rossum2001-12-041-5/+7
| | | | | | | There's now a new structmember code, T_OBJECT_EX, which is used for all __slot__ variables (except __weakref__, which has special behavior anyway). This new code raises AttributeError when the variable is NULL rather than converting NULL to None.
* Fix of SF bug #475877 (Mutable subtype instances are hashable).Guido van Rossum2001-12-031-0/+24
| | | | | | | | | | | | | | | | | Rather than tweaking the inheritance of type object slots (which turns out to be too messy to try), this fix adds a __hash__ to the list and dict types (the only mutable types I'm aware of) that explicitly raises an error. This has the advantage that list.__hash__([]) also raises an error (previously, this would invoke object.__hash__([]), returning the argument's address); ditto for dict.__hash__. The disadvantage for this fix is that 3rd party mutable types aren't automatically fixed. This should be added to the rules for creating subclassable extension types: if you don't want your object to be hashable, add a tp_hash function that raises an exception. Also, it's possible that I've forgotten about other mutable types for which this should be done.