cpython/Modules
Petr Viktorin dcaf33a41d
gh-114314: ctypes: remove stgdict and switch to heap types (GH-116458)
Before this change, ctypes classes used a custom dict subclass, `StgDict`,
as their `tp_dict`. This acts like a regular dict but also includes extra information
about the type.

This replaces stgdict by `StgInfo`, a C struct on the type, accessed by
`PyObject_GetTypeData()` (PEP-697).
All usage of `StgDict` (mainly variables named `stgdict`, `dict`, `edict` etc.) is
converted to `StgInfo` (named `stginfo`, `info`, `einfo`, etc.).
Where the dict is actually used for class attributes (as a regular PyDict), it's now
called `attrdict`.

This change -- not overriding `tp_dict` -- is made to make me comfortable with
the next part of this PR: moving the initialization logic from `tp_new` to `tp_init`.

The `StgInfo` is set up in `__init__` of each class, with a guard that prevents
calling `__init__` more than once. Note that abstract classes (like `Array` or
`Structure`) are created using `PyType_FromMetaclass` and do not have
`__init__` called.
Previously, this was done in `__new__`, which also wasn't called for abstract
classes.
Since `__init__` can be called from Python code or skipped, there is a tested
guard to ensure `StgInfo` is initialized exactly once before it's used.

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-03-20 17:33:08 +01:00
..
_blake2 gh-116116: Backport blake2 change to fix building with clang-cl on windows-i686 (GH-116117) 2024-03-04 16:59:57 +00:00
_ctypes gh-114314: ctypes: remove stgdict and switch to heap types (GH-116458) 2024-03-20 17:33:08 +01:00
_decimal gh-115119: Switch Windows build to mpdecimal external (GH-115182) 2024-03-18 12:07:25 -05:00
_hacl
_io gh-115538: Emit warning when use bool as fd in _io.WindowsConsoleIO (GH-116925) 2024-03-18 11:48:50 +00:00
_multiprocessing gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610) 2024-03-11 22:42:18 +00:00
_sqlite gh-111140: Adds PyLong_AsNativeBytes and PyLong_FromNative[Unsigned]Bytes functions (GH-114886) 2024-02-12 20:13:13 +00:00
_sre
_ssl
_testcapi gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064) 2024-03-20 15:39:53 +02:00
_testinternalcapi gh-110850: Cleanup PyTime API: PyTime_t are nanoseconds (#115753) 2024-02-21 11:46:00 +01:00
_testlimitedcapi gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064) 2024-03-20 15:39:53 +02:00
_xxtestfuzz
cjkcodecs gh-85287: Change codecs to raise precise UnicodeEncodeError and UnicodeDecodeError (#113674) 2024-03-17 04:58:42 +00:00
clinic gh-85283: Build _statistics extension with the limited C API (#116927) 2024-03-17 18:59:02 +01:00
expat gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) 2024-02-29 14:52:50 -08:00
_abc.c gh-113743: Make the MRO cache thread-safe in free-threaded builds (#113930) 2024-02-15 10:54:57 -08:00
_asynciomodule.c gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438) 2024-03-07 11:21:08 +02:00
_bisectmodule.c
_bz2module.c
_codecsmodule.c
_collectionsmodule.c gh-112050: Make collections.deque thread-safe in free-threaded builds (#113830) 2024-02-15 09:22:47 +01:00
_contextvarsmodule.c
_csv.c gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438) 2024-03-07 11:21:08 +02:00
_curses_panel.c
_cursesmodule.c
_datetimemodule.c gh-110850: Use public PyTime functions (#115746) 2024-02-20 23:31:30 +00:00
_dbmmodule.c
_elementtree.c gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438) 2024-03-07 11:21:08 +02:00
_functoolsmodule.c gh-111696, PEP 737: Add PyType_GetModuleName() function (#116824) 2024-03-14 18:17:43 +00:00
_gdbmmodule.c
_hashopenssl.c
_heapqmodule.c
_interpreters_common.h gh-76785: Minor Improvements to "interpreters" Module (gh-116328) 2024-03-05 08:54:46 -07:00
_json.c
_localemodule.c
_lsprof.c gh-103092: Add a mutex to make the PRNG state of rotatingtree concurrent-safe (#115301) 2024-03-01 00:04:16 +01:00
_lzmamodule.c
_math.h
_opcode.c
_operator.c
_pickle.c gh-111140: Adds PyLong_AsNativeBytes and PyLong_FromNative[Unsigned]Bytes functions (GH-114886) 2024-02-12 20:13:13 +00:00
_posixsubprocess.c gh-113964: Don't prevent new threads until all non-daemon threads exit (#116677) 2024-03-19 14:40:20 -04:00
_queuemodule.c gh-110850: Use public PyTime functions (#115746) 2024-02-20 23:31:30 +00:00
_randommodule.c gh-110850: Use public PyTime functions (#115746) 2024-02-20 23:31:30 +00:00
_scproxy.c gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610) 2024-03-11 22:42:18 +00:00
_ssl.c gh-110850: Cleanup pycore_time.h includes (#115724) 2024-02-20 16:50:43 +00:00
_ssl.h
_ssl_data_31.h
_ssl_data_111.h
_ssl_data_300.h
_stat.c gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610) 2024-03-11 22:42:18 +00:00
_statisticsmodule.c gh-85283: Build _statistics extension with the limited C API (#116927) 2024-03-17 18:59:02 +01:00
_struct.c gh-111140: Adds PyLong_AsNativeBytes and PyLong_FromNative[Unsigned]Bytes functions (GH-114886) 2024-02-12 20:13:13 +00:00
_suggestions.c
_sysconfig.c
_testbuffer.c gh-114670: Fix _testbuffer module initialization (#114672) 2024-02-11 00:48:28 +03:00
_testcapi_feature_macros.inc
_testcapimodule.c gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064) 2024-03-20 15:39:53 +02:00
_testclinic.c
_testclinic_limited.c gh-116646: Add limited C API support to AC fildes converter (#116769) 2024-03-14 10:28:58 +01:00
_testexternalinspection.c gh-114099 - Add iOS testbed, plus Makefile target to invoke it. (gh-115930) 2024-03-06 23:24:52 -05:00
_testimportmultiple.c gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610) 2024-03-11 22:42:18 +00:00
_testinternalcapi.c GH-112536: Add more TSan tests (#116911) 2024-03-17 09:47:14 +01:00
_testlimitedcapi.c gh-116417: Move limited C API complex.c tests to _testlimitedcapi (#117014) 2024-03-19 17:23:12 +01:00
_testmultiphase.c
_testsinglephase.c gh-110850: Use public PyTime functions (#115746) 2024-02-20 23:31:30 +00:00
_threadmodule.c gh-113964: Don't prevent new threads until all non-daemon threads exit (#116677) 2024-03-19 14:40:20 -04:00
_tkinter.c gh-111140: Adds PyLong_AsNativeBytes and PyLong_FromNative[Unsigned]Bytes functions (GH-114886) 2024-02-12 20:13:13 +00:00
_tracemalloc.c
_typingmodule.c
_uuidmodule.c gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610) 2024-03-11 22:42:18 +00:00
_weakref.c
_winapi.c gh-114570: Add PythonFinalizationError exception (#115352) 2024-02-14 23:35:06 +01:00
_xxinterpchannelsmodule.c gh-76785: Minor Improvements to "interpreters" Module (gh-116328) 2024-03-05 08:54:46 -07:00
_xxinterpqueuesmodule.c gh-116386: Fix format string "%ld" warning in _xxinterpqueuesmodule (#116387) 2024-03-07 09:44:26 +03:00
_xxsubinterpretersmodule.c gh-76785: Update test.support.interpreters to Align With PEP 734 (gh-115566) 2024-02-28 16:08:08 -07:00
_zoneinfo.c
addrinfo.h
arraymodule.c gh-116447: Fix possible UB in arraymodule and getargs (#116459) 2024-03-08 13:49:52 +03:00
atexitmodule.c
binascii.c
cmathmodule.c
config.c.in
errnomodule.c gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610) 2024-03-11 22:42:18 +00:00
faulthandler.c gh-110850: Cleanup pycore_time.h includes (#115724) 2024-02-20 16:50:43 +00:00
fcntlmodule.c gh-85283: Build fcntl extension with the limited C API (#116791) 2024-03-14 12:01:13 +00:00
gc_weakref.txt
gcmodule.c GH-108362: Incremental Cycle GC (GH-116206) 2024-03-20 08:54:42 +00:00
getaddrinfo.c
getbuildinfo.c
getnameinfo.c
getpath.c
getpath.py
getpath_noop.c
grpmodule.c gh-85283: Convert grp extension to the limited C API (#116611) 2024-03-12 00:46:53 +00:00
hashlib.h
itertoolsmodule.c gh-115874: Don't use module state in teedataobject tp_dealloc (#116204) 2024-03-18 13:24:24 +01:00
ld_so_aix.in
main.c
makesetup gh-111225: Link extension modules against libpython on Android (#115780) 2024-02-21 23:18:57 +00:00
makexp_aix
mathmodule.c gh-73468: Add math.fma() function (#116667) 2024-03-17 13:58:26 +00:00
md5module.c
mmapmodule.c
overlapped.c gh-116773: Ensure overlapped objects on Windows are not deallocated too early by asyncio (GH-116774) 2024-03-20 14:33:28 +00:00
posixmodule.c gh-113964: Don't prevent new threads until all non-daemon threads exit (#116677) 2024-03-19 14:40:20 -04:00
posixmodule.h gh-85283: Convert grp extension to the limited C API (#116611) 2024-03-12 00:46:53 +00:00
pwdmodule.c gh-85283: Build pwd extension with the limited C API (#116841) 2024-03-15 08:49:58 +01:00
pyexpat.c gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) 2024-02-29 14:52:50 -08:00
readline.c
README
resource.c gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610) 2024-03-11 22:42:18 +00:00
rotatingtree.c gh-103092: Add a mutex to make the PRNG state of rotatingtree concurrent-safe (#115301) 2024-03-01 00:04:16 +01:00
rotatingtree.h
selectmodule.c gh-110850: Use public PyTime functions (#115746) 2024-02-20 23:31:30 +00:00
Setup gh-115773: Add tests to exercise the _Py_DebugOffsets structure (#115774) 2024-02-28 10:17:34 +00:00
Setup.bootstrap.in
Setup.stdlib.in gh-116417: Move limited C API complex.c tests to _testlimitedcapi (#117014) 2024-03-19 17:23:12 +01:00
sha1module.c
sha2module.c
sha3module.c
signalmodule.c gh-110850: Cleanup pycore_time.h includes (#115724) 2024-02-20 16:50:43 +00:00
socketmodule.c gh-116616: Use relaxed atomic ops to access socket module defaulttimeout (#116623) 2024-03-12 14:44:39 +01:00
socketmodule.h gh-110850: Cleanup pycore_time.h includes (#115724) 2024-02-20 16:50:43 +00:00
symtablemodule.c
syslogmodule.c
termios.c gh-85283: Build termios extension with the limited C API (#116928) 2024-03-17 15:12:29 +00:00
timemodule.c gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438) 2024-03-07 11:21:08 +02:00
tkappinit.c
tkinter.h
unicodedata.c
unicodedata_db.h
unicodename_db.h
winreparse.h
xxlimited.c gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610) 2024-03-11 22:42:18 +00:00
xxlimited_35.c gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610) 2024-03-11 22:42:18 +00:00
xxmodule.c
xxsubtype.c
zlibmodule.c

Source files for standard library extension modules,
and former extension modules that are now builtin modules.