cpython/Python/clinic
Petr Viktorin 7dfa048bbb
gh-135228: Create __dict__ and __weakref__ descriptors for object (GH-136966)
This partially reverts #137047, keeping the tests for GC collectability of the
original class that dataclass adds `__slots__` to.
The reference leaks solved there are instead solved by having the `__dict__` &
`__weakref__` descriptors not tied to (and referencing) their class.

Instead, they're shared between all classes that need them (within
an interpreter).
The `__objclass__` ol the descriptors is set to `object`, since these
descriptors work with *any* object. (The appropriate checks were already
made in the get/set code, so the `__objclass__` check was redundant.)

The repr of these descriptors (and any others whose `__objclass__` is `object`)
now doesn't mention the objclass.

This change required adjustment of introspection code that checks
`__objclass__` to determine an object's “own” (i.e. not inherited) `__dict__`.
Third-party code that does similar introspection of the internals will also
need adjusting.


Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2025-08-18 14:25:51 +02:00
..
_contextvars.c.h gh-128384: Use a context variable for warnings.catch_warnings (gh-130010) 2025-04-09 16:18:54 -07:00
_warnings.c.h gh-131525: Cache the result of tuple_hash (#131529) 2025-03-27 09:57:06 -04:00
bltinmodule.c.h gh-137668: Document that ord() supports also bytes and bytearray (GH-137669) 2025-08-13 12:12:16 +03:00
context.c.h gh-111178: Change Argument Clinic signature for METH_O (#130682) 2025-03-11 16:33:36 +01:00
import.c.h gh-131525: Cache the result of tuple_hash (#131529) 2025-03-27 09:57:06 -04:00
instruction_sequence.c.h gh-131525: Cache the result of tuple_hash (#131529) 2025-03-27 09:57:06 -04:00
instrumentation.c.h gh-116750: Add clear_tool_id function to unregister events and callbacks (#124568) 2024-10-01 13:32:55 -04:00
marshal.c.h gh-131525: Cache the result of tuple_hash (#131529) 2025-03-27 09:57:06 -04:00
Python-tokenize.c.h gh-131525: Cache the result of tuple_hash (#131529) 2025-03-27 09:57:06 -04:00
sysmodule.c.h gh-135228: Create __dict__ and __weakref__ descriptors for object (GH-136966) 2025-08-18 14:25:51 +02:00
traceback.c.h gh-131525: Cache the result of tuple_hash (#131529) 2025-03-27 09:57:06 -04:00