aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_weakref.py
Commit message (Collapse)AuthorAge
* gh-71339: Use new assertion methods in tests (GH-129046)Serhiy Storchaka2025-05-22
|
* gh-125900: Clean-up logic around immortalization in free-threading (#125901)Sam Gross2024-10-24
| | | | | | | | | * Remove `@suppress_immortalization` decorator * Make suppression flag per-thread instead of per-interpreter * Suppress immortalization in `eval()` to avoid refleaks in three tests (test_datetime.test_roundtrip, test_logging.test_config8_ok, and test_random.test_after_fork). * frozenset() is constant, but not a singleton. When run multiple times, the test could fail due to constant interning.
* gh-123046: Fix regexp to catch cases where the module name is omitted from ↵Kirill Podoprigora2024-08-16
| | | | | the weakref repr (#123047) Co-authored-by: sobolevn <mail@sobolevn.me>
* gh-121220: Mark test_threaded_weak_value_dict_copy() as CPU-heavy (#121221)Kirill Podoprigora2024-07-01
| | | | | Mark test_threaded_weak_value_dict_copy() and test_threaded_weak_key_dict_copy() of test_weakref as CPU-heavy tests
* gh-120065: Increase `collect_in_thread` period to 5 ms. (#120068)Sam Gross2024-06-05
| | | | | This matches the default GIL switch interval. It greatly speeds up the free-threaded build: previously, it spent nearly all its time in `gc.collect()`.
* gh-118335: Configure Tier 2 interpreter at build time (#118339)Guido van Rossum2024-04-30
| | | | | | | | | | | | | | | | | | | | | | The code for Tier 2 is now only compiled when configured with `--enable-experimental-jit[=yes|interpreter]`. We drop support for `PYTHON_UOPS` and -`Xuops`, but you can disable the interpreter or JIT at runtime by setting `PYTHON_JIT=0`. You can also build it without enabling it by default using `--enable-experimental-jit=yes-off`; enable with `PYTHON_JIT=1`. On Windows, the `build.bat` script supports `--experimental-jit`, `--experimental-jit-off`, `--experimental-interpreter`. In the C code, `_Py_JIT` is defined as before when the JIT is enabled; the new variable `_Py_TIER2` is defined when the JIT *or* the interpreter is enabled. It is actually a bitmask: 1: JIT; 2: default-off; 4: interpreter.
* gh-117783: Immortalize objects that use deferred reference counting (#118112)Sam Gross2024-04-29
| | | | | | | | | Deferred reference counting is not fully implemented yet. As a temporary measure, we immortalize objects that would use deferred reference counting to avoid multi-threaded scaling bottlenecks. This is only performed in the free-threaded build once the first non-main thread is started. Additionally, some tests, including refleak tests, suppress this behavior.
* gh-118331: Don't raise an error if tuple allocation fails when clearing ↵mpage2024-04-29
| | | | | | | | | | weakrefs (#118338) It's not safe to raise an exception in `PyObject_ClearWeakRefs()` if one is not already set, since it may be called by `_Py_Dealloc()`, which requires that the active exception does not change. Additionally, make sure we clear the weakrefs even when tuple allocation fails.
* gh-117657: Add TSAN suppressions for the free-threaded build (#117736)mpage2024-04-15
| | | | | Additionally, reduce the iterations for a few weakref tests that would otherwise take a prohibitively long amount of time (> 1 hour) when TSAN is enabled and the GIL is disabled.
* gh-111926: Make weakrefs thread-safe in free-threaded builds (#117168)mpage2024-04-08
| | | | | | | | | Most mutable data is protected by a striped lock that is keyed on the referenced object's address. The weakref's hash is protected using the weakref's per-object lock. Note that this only affects free-threaded builds. Apart from some minor refactoring, the added code is all either gated by `ifdef`s or is a no-op (e.g. `Py_BEGIN_CRITICAL_SECTION`).
* gh-116303: Skip test module dependent tests if test modules are unavailable ↵Erlend E. Aasland2024-04-03
| | | | (#117341)
* gh-117281: Change weakref repr() to fully qualified name (#117285)Victor Stinner2024-04-03
| | | | | | | | Use the fully qualified type name in repr() of weakref.ref and weakref.proxy types. Fix a crash in proxy_repr() when the reference is dead. Add also test_ref_repr() and test_proxy_repr().
* gh-108416: Mark slow test methods with @requires_resource('cpu') (GH-108421)Serhiy Storchaka2023-09-02
| | | | Only mark tests which spend significant system or user time, by itself or in subprocesses.
* gh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (#99244)Nikita Sobolev2023-04-24
|
* gh-99051: remove duplicated test from `test_weakref` (GH-99052)Nikita Sobolev2022-11-06
|
* gh-79512: Fixed names and __module__ value of weakref classes (GH-93719)Serhiy Storchaka2022-06-14
| | | | | Classes ReferenceType, ProxyType and CallableProxyType have now correct atrtributes __module__, __name__ and __qualname__. It makes them (types, not instances) pickleable.
* bpo-40280: Detect missing threading on WASM platforms (GH-32352)Christian Heimes2022-04-07
| | | Co-authored-by: Brett Cannon <brett@python.org>
* Fix typos in the Lib directory (GH-28775)Christian Clauss2021-10-06
| | | | | Fix typos in the Lib directory as identified by codespell. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* bpo-45229: Use doctest.DocTestSuite instead of run_doctest (GH-28468)Serhiy Storchaka2021-09-20
| | | Alo use load_tests() for adding tests.
* bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005)Serhiy Storchaka2021-08-29
|
* bpo-44720: Don't crash when calling weakref.proxy(not_an_iterator).__next__ ↵Dennis Sweeney2021-07-24
| | | | (GH-27316)
* bpo-44523: Remove the pass-through for hash() in weakref proxy objects ↵Pablo Galindo2021-06-29
| | | | (GH-26950)
* bpo-40523: Add pass-throughs for hash() and reversed() to weakref.proxy ↵Pablo Galindo2020-05-05
| | | | objects (GH-19946)
* bpo-36144: Add union operators to WeakValueDictionary584 (#19127)Curtis Bucher2020-03-24
|
* bpo-36144: Add union operators to WeakKeyDictionary (#19106)Curtis Bucher2020-03-23
|
* bpo-39489: Remove COUNT_ALLOCS special build (GH-18259)Victor Stinner2020-02-03
| | | | | | | | | | | Remove: * COUNT_ALLOCS macro * sys.getcounts() function * SHOW_ALLOC_COUNT code in listobject.c * SHOW_TRACK_COUNT code in tupleobject.c * PyConfig.show_alloc_count field * -X showalloccount command line option * @test.support.requires_type_collecting decorator
* bpo-38395: Fix ownership in weakref.proxy methods (GH-16632)Pablo Galindo2019-10-08
| | | | | | | | | | | | | The implementation of weakref.proxy's methods call back into the Python API using a borrowed references of the weakly referenced object (acquired via PyWeakref_GET_OBJECT). This API call may delete the last reference to the object (either directly or via GC), leaving a dangling pointer, which can be subsequently dereferenced. To fix this, claim a temporary ownership of the referenced object when calling the appropriate method. Some functions because at the moment they do not need to access the borrowed referent, but to protect against future changes to these functions, ownership need to be fixed in all potentially affected methods.
* bpo-38006: Avoid closure in weakref.WeakValueDictionary (GH-15641)Victor Stinner2019-09-09
| | | | | weakref.WeakValueDictionary defines a local remove() function used as callback for weak references. This function was created with a closure. Modify the implementation to avoid the closure.
* bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)Serhiy Storchaka2019-08-08
| | | | They now return NotImplemented for unsupported type of the other operand.
* [3.9] bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-12620)Serhiy Storchaka2019-06-05
| | | Turn deprecation warnings added in 3.8 into TypeError.
* bpo-36669: add matmul support to weakref.proxy (GH-12932)Mark Dickinson2019-04-26
|
* bpo-36492: Deprecate passing some arguments as keyword arguments. (GH-12637)Serhiy Storchaka2019-04-01
| | | | | | | | | | | | | | | | | | | | | | Deprecated passing the following arguments as keyword arguments: - "func" in functools.partialmethod(), weakref.finalize(), profile.Profile.runcall(), cProfile.Profile.runcall(), bdb.Bdb.runcall(), trace.Trace.runfunc() and curses.wrapper(). - "function" in unittest.addModuleCleanup() and unittest.TestCase.addCleanup(). - "fn" in the submit() method of concurrent.futures.ThreadPoolExecutor and concurrent.futures.ProcessPoolExecutor. - "callback" in contextlib.ExitStack.callback(), contextlib.AsyncExitStack.callback() and contextlib.AsyncExitStack.push_async_callback(). - "c" and "typeid" in the create() method of multiprocessing.managers.Server and multiprocessing.managers.SharedMemoryServer. - "obj" in weakref.finalize(). Also allowed to pass arbitrary keyword arguments (even "self" and "func") if the above arguments are passed as positional argument.
* bpo-35615: Fix crashes when copying a Weak{Key,Value}Dictionary. (GH-11384)Fish2019-02-07
| | | | | | | | | | Protect dict iterations by wrapping them with _IterationGuard in the following methods: - WeakValueDictionary.copy() - WeakValueDictionary.__deepcopy__() - WeakKeyDictionary.copy() - WeakKeyDictionary.__deepcopy__()
* bpo-32746: Fix multiple typos (GH-5144)Leo Arias2018-02-03
| | | Fix typos found by codespell in docs, docstrings, and comments.
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-07
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* Issue #28427: old keys should not remove new values fromAntoine Pitrou2016-12-27
|\ | | | | | | WeakValueDictionary when collecting from another thread.
| * Issue #28427: old keys should not remove new values fromAntoine Pitrou2016-12-27
| | | | | | | | WeakValueDictionary when collecting from another thread.
* | Issue #19542: Fix bugs in WeakValueDictionary.setdefault() and ↵Antoine Pitrou2016-12-19
|\| | | | | | | | | | | | | | | WeakValueDictionary.pop() when a GC collection happens in another thread. Original patch and report by Armin Rigo.
| * Issue #19542: Fix bugs in WeakValueDictionary.setdefault() and ↵Antoine Pitrou2016-12-19
| | | | | | | | | | | | | | | | WeakValueDictionary.pop() when a GC collection happens in another thread. Original patch and report by Armin Rigo.
* | merge 3.5 (#26617)Benjamin Peterson2016-10-04
|\|
| * ensure gc tracking is off when invoking weakref callbacks (closes #26617)Benjamin Peterson2016-10-04
| |
* | Implement compact dictVictor Stinner2016-09-07
| | | | | | | | | | | | | | | | | | | | | | | | Issue #27350: `dict` implementation is changed like PyPy. It is more compact and preserves insertion order. _PyDict_Dummy() function has been removed. Disable test_gdb: python-gdb.py is not updated yet to the new structure of compact dictionaries (issue #28023). Patch written by INADA Naoki.
* | Correct a comment in the test referencing the wrong issue number (issue3100Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)2016-09-07
|/ | | | is correct, not 3110).
* Issue #19527: Fixed tests with defined COUNT_ALLOCS.Serhiy Storchaka2016-07-03
|
* Issue #17765: weakref.ref() no longer silently ignores keyword arguments.Serhiy Storchaka2016-05-07
| | | | Patch by Georg Brandl.
* Issue #25523: Merge "a" to "an" fixes from 3.4 into 3.5Martin Panter2015-11-02
|\
| * Issue #25523: Correct "a" article to "an" articleMartin Panter2015-11-02
| | | | | | | | | | | | This changes the main documentation, doc strings, source code comments, and a couple error messages in the test suite. In some cases the word was removed or edited some other way to fix the grammar.
* | Issue #22958: Constructor and update method of weakref.WeakValueDictionarySerhiy Storchaka2015-09-29
|\| | | | | | | now accept the self and the dict keyword arguments.
| * Issue #22958: Constructor and update method of weakref.WeakValueDictionarySerhiy Storchaka2015-09-29
| | | | | | | | now accept the self and the dict keyword arguments.
* | Issue #9517: Move script_helper to the support package.Berker Peksag2015-05-06
| | | | | | | | Patch by Christie Wilson.