summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_weakref.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-29796: test_weakref: Fix collect_in_thread() on Windows (#2553)Victor Stinner2017-07-041-1/+1
| | | | | | | Sleep 1 ms instead of 0.1 ms to workaround a rounding issue on Windows. On Windows, time.sleep(0.0001) sleeps 0 ms, so collect_in_thread() calls gc.collect() in a loop and tests using this thread takes too long. Sleep 1 ms so time.sleep() sleeps 15.6 ms on Windows.
* Issue #28427: old keys should not remove new values fromAntoine Pitrou2016-12-271-0/+12
| | | | WeakValueDictionary when collecting from another thread.
* Issue #19542: Fix bugs in WeakValueDictionary.setdefault() and ↵Antoine Pitrou2016-12-191-0/+44
| | | | | | | | WeakValueDictionary.pop() when a GC collection happens in another thread. Original patch and report by Armin Rigo.
* Issue #17765: weakref.ref() no longer silently ignores keyword arguments.Serhiy Storchaka2016-05-071-0/+4
| | | | Patch by Georg Brandl.
* Issue #22958: Constructor and update method of weakref.WeakValueDictionarySerhiy Storchaka2015-09-291-0/+25
| | | | now accept the self keyword argument.
* fix some test_weakref tests to not rely on ref-counting (closes #22267)Benjamin Peterson2014-08-241-0/+2
|
* Issue #7105: weak dict iterators are fragile because of unpredictable GC runsKristján Valur Jónsson2013-12-051-5/+92
| | | | Backport the fix from pyton 3.x for this issue.
* Issue #19607: Use specific asserts in weakref tests.Serhiy Storchaka2013-11-171-77/+74
|
* Issue #16602: When a weakref's target was part of a long deallocation chain, ↵Antoine Pitrou2012-12-081-0/+21
| | | | | | the object could remain reachable through its weakref even though its refcount had dropped to zero. Thanks to Eugene Toder for diagnosing and reporting the issue.
* Issue #16453: Fix equality testing of dead weakref objects.Antoine Pitrou2012-11-111-11/+69
| | | | Also add tests for hashing.
* Issue #14159: Fix the len() of weak sets to return a better approximation ↵Antoine Pitrou2012-03-011-0/+60
| | | | | | | when some objects are dead or dying. Moreover, the implementation is now O(1) rather than O(n). Thanks to Yury Selivanov for reporting.
* Issue #8268: Old-style classes (not just instances) now support weakAntoine Pitrou2010-03-311-0/+20
| | | | references.
* #7092 - Silence more py3k deprecation warnings, using ↵Florent Xicluna2010-03-211-28/+28
| | | | test_support.check_py3k_warnings() helper.
* use assert[Not]In where appropriateEzio Melotti2010-01-231-9/+8
|
* Reverting the Revision: 77368. I committed Flox's big patch for tests bySenthil Kumaran2010-01-081-20/+17
| | | | mistake. ( It may come in for sure tough)
* Fixing - Issue7026 - RuntimeError: dictionary changed size during iteration. ↵Senthil Kumaran2010-01-081-17/+20
| | | | Patch by flox
* #5037 proxy __unicode__ correctlyBenjamin Peterson2009-11-191-0/+11
|
* convert usage of fail* to assert*Benjamin Peterson2009-06-301-105/+105
|
* Fix #3634 invalid return value from _weakref.ref(Exception).__init__Benjamin Peterson2008-09-091-0/+8
| | | | Reviewers: Amaury, Antoine, Benjamin
* Issue 3110: Crash with weakref subclass,Amaury Forgeot d'Arc2008-06-161-1/+40
| | | | | | | | | seen after a "import multiprocessing.reduction" An instance of a weakref subclass can have attributes. If such a weakref holds the only strong reference to the object, deleting the weakref will delete the object. In this case, the callback must not be called, because the ref object is being deleted!
* #2592: delegate nb_index and the floor/truediv slots in weakref.proxy.Georg Brandl2008-05-201-1/+22
|
* Fix crasher for when an object's __del__ creates a new weakref to itself.Brett Cannon2007-01-231-0/+14
| | | | | | Patch only fixes new-style classes; classic classes still buggy. Closes bug #1377858. Already backported.
* Fix typo.Walter Dörwald2006-12-121-1/+1
|
* ("Forward-port" of r46506)Armin Rigo2006-05-281-2/+2
| | | | | | | | | | | | | | Remove various dependencies on dictionary order in the standard library tests, and one (clearly an oversight, potentially critical) in the standard library itself - base64.py. Remaining open issues: * test_extcall is an output test, messy to make robust * tarfile.py has a potential bug here, but I'm not familiar enough with this code. Filed in as SF bug #1496501. * urllib2.HTTPPasswordMgr() returns a random result if there is more than one matching root path. I'm asking python-dev for clarification...
* SF #1479988: add methods to allow access to weakrefs for theFred Drake2006-05-021-0/+44
| | | | weakref.WeakKeyDictionary and weakref.WeakValueDictionary
* Add doctest for examples in libweakref.tex to test_weakref.Georg Brandl2005-07-021-0/+86
|
* SF bug #1770766: weakref proxy has incorrect __nonzero__ behavior.Raymond Hettinger2005-03-271-0/+6
|
* SF bug #978308, Spurious errors taking bool of dead proNeal Norwitz2004-07-081-0/+1
| | | | | | Need to return -1 on error. Needs backport.
* Make weak references subclassable:Fred Drake2004-07-021-0/+66
| | | | | | | | | | | | | | | | | | | | | | - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019.
* Rename class attribute containing the class to be tested, so the name is theWalter Dörwald2004-06-021-2/+2
| | | | same as for the string and sequence tests.
* Port the dictionary tests from test_types.py to unittest. Collect as muchWalter Dörwald2004-05-311-3/+3
| | | | | | mapping tests as possible in mapping_test.py and reuse the tests in test_dict.py, test_userdict.py, test_weakref.py, test_os.py and test_shelve.py. From SF patch #736962.
* further testing indicates that the simplified version of the testFred Drake2004-02-131-4/+6
| | | | | | | | | | (re-using an existing test object class) no longer triggered the original segfault when the fix was backed out; restoring the local test object class to make the test effective the assignment of the ref created at the end does not affect the test, since the segfault happended before weakref.ref() returned; removing the assignment
* use existing test object instead of defining a new classFred Drake2004-02-121-5/+3
|
* Replace backticks with repr() or "%r"Walter Dörwald2004-02-121-1/+1
| | | | From SF patch #852334.
* Allocating a new weakref object can cause existing weakref objects forFred Drake2004-02-041-0/+32
| | | | | | | | | the same object to be collected by the cyclic GC support if they are only referenced by a cycle. If the weakref being collected was one of the weakrefs without callbacks, some local variables for the constructor became invalid and have to be re-computed. The test caused a segfault under a debug build without the fix applied.
* - add tests that exercise fixes for the PyWeakref_NewRef() andFred Drake2004-02-031-0/+41
| | | | | PyWeakref_NewProxy() constructors from the C API - elaborate the getweakrefcount() and getweakrefs() tests slightly
* Add tests to test_weakref.py to bring code coverage in _weakref.c up to 100%.Walter Dörwald2003-12-111-0/+8
| | | | | | | | Port test_md5.py to PyUnit. (Written by Neal Norwitz; from SF patch 736962) (Backport candidate)
* SF bug 839548: Bug in type's GC handling causes segfaults.Tim Peters2003-11-201-0/+205
| | | | | | | | Also SF patch 843455. This is a critical bugfix. I'll backport to 2.3 maint, but not beyond that. The bugs this fixes have been there since weakrefs were introduced.
* * Migrate set() and frozenset() from the sandbox.Raymond Hettinger2003-11-161-2/+1
| | | | | | | | * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming.
* subtype_dealloc(): A more complete fix for critical bug 840829 +Tim Peters2003-11-131-0/+19
| | | | | | expanded the test case with a piece that needs the more-complete fix. I'll backport this to 2.3 maint.
* SF bug 840829: weakref callbacks and gc corrupt memory.Tim Peters2003-11-121-0/+20
| | | | | | | | | | | | | | | | | subtype_dealloc(): This left the dying object exposed to gc, so that if cyclic gc triggered during the weakref callback, gc tried to delete the dying object a second time. That's a disaster. subtype_dealloc() had a (I hope!) unique problem here, as every normal dealloc routine untracks the object (from gc) before fiddling with weakrefs etc. But subtype_dealloc has obscure technical reasons for re-registering the dying object with gc (already explained in a large comment block at the bottom of the function). The fix amounts to simply refraining from reregistering the dying object with gc until after the weakref callback (if any) has been called. This is a critical bug (hard to predict, and causes seemingly random memory corruption when it occurs). I'll backport it to 2.3 later.
* stylistic nits:Fred Drake2003-07-141-6/+8
| | | | | | - wrap some long lines - shorten others - fix indentation
* Fix SF 762891: "del p[key]" on proxy object raises SystemError()Raymond Hettinger2003-06-301-0/+11
|
* Fleshed out WeakKeyDictionary.__delitem__ NEWS to cover issues raised onTim Peters2003-05-251-2/+10
| | | | | | | | | Python-Dev. Fixed typos in test comments. Added some trivial new test guts to show the parallelism (now) among __delitem__, __setitem__ and __getitem__ wrt error conditions. Still a bugfix candidate for 2.2.3 final, but waiting for Fred to get a chance to chime in.
* SF 742860: WeakKeyDictionary __delitem__ uses iterkeysTim Peters2003-05-251-0/+51
| | | | | | | | | | | | | | | | | Someone review this, please! Final releases are getting close, Fred (the weakref guy) won't be around until Tuesday, and the pre-patch code can indeed raise spurious RuntimeErrors in the presence of threads or mutating comparison functions. See the bug report for my confusions: I can't see any reason for why __delitem__ iterated over the keys. The new one-liner implementation is much faster, can't raise RuntimeError, and should be better-behaved in all respects wrt threads. New tests test_weak_keyed_bad_delitem and test_weak_keyed_cascading_deletes fail before this patch. Bugfix candidate for 2.2.3 too, if someone else agrees with this patch.
* Used sets.Set() to compare unordered sequences.Raymond Hettinger2003-05-021-3/+2
| | | | Improves clarity and brevity.
* Combine the functionality of test_support.run_unittest()Walter Dörwald2003-05-011-6/+6
| | | | | | | | | | and test_support.run_classtests() into run_unittest() and use it wherever possible. Also don't use "from test.test_support import ...", but "from test import test_support" in a few spots. From SF patch #662807.
* SF patch #667730: More DictMixinRaymond Hettinger2003-03-091-0/+17
| | | | | | | | * Adds missing pop() methods to weakref.py * Expands test suite to broaden coverage of objects with a mapping interface. Contributed by Sebastien Keim.
* Standardize behavior: no docstrings in test functions. Also useGuido van Rossum2002-08-221-6/+4
| | | | unittest.makeSuite() rather than loader.loadTestsFromTestCase().
* 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. :)