Commit Graph

4515 Commits

Author SHA1 Message Date
Bénédikt Tran 4d8e7c40a0
gh-123961: Add a global state to _curses (#124729) 2024-09-29 15:17:20 +00:00
Bénédikt Tran c00964ecd5
gh-124665: Add `_PyCodec_UnregisterError` and `_codecs._unregister_error` (#124677) 2024-09-29 02:25:23 +02:00
Jelle Zijlstra 25189188bf
generate_global_objects.py: Fix name of macro in error message (#124464)
_PyID does not exist but _Py_ID does.
2024-09-26 21:37:21 -07:00
Savannah Ostrowski 65f1237098
GH-123516: Improve JIT memory consumption by invalidating cold executors (GH-124443)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-09-27 00:35:42 +00:00
Brett Cannon 66cc6d4c50
Remove some unused files related to WASM/WASI (GH-124635) 2024-09-26 21:23:41 +00:00
Irit Katriel 78aeb38f7d
gh-124285: Fix bug where bool() is called multiple times for the same part of a boolean expression (#124394) 2024-09-25 15:51:25 +01:00
Savannah Ostrowski b6471f4a39
GH-124408: Temporarily skip test_strftime_y2k for emulated Linux JIT CI (GH-124466) 2024-09-24 18:09:50 -07:00
Sam Gross f4997bb3ac
gh-123923: Defer refcounting for `f_funcobj` in `_PyInterpreterFrame` (#124026)
Use a `_PyStackRef` and defer the reference to `f_funcobj` when
possible. This avoids some reference count contention in the common case
of executing the same code object from multiple threads concurrently in
the free-threaded build.
2024-09-24 20:08:18 +00:00
Jason Fried d87482bc4e
gh-119333: Add C api to have contextvar enter/exit callbacks (#119335)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-09-23 20:40:17 -07:00
Hugo van Kemenade e256a7590a
Lint and format Tools/build/check-warnings.py (#124382) 2024-09-24 02:47:05 +03:00
Wulian 27a62e7371
gh-124102: Update internal PCbuild docs to accurately list build dependencies (GH-124103) 2024-09-23 23:09:22 +00:00
Mark Shannon c87b0e4a46
GH-124284: Add stats for refcount operations on immortal objects (GH-124288) 2024-09-23 19:10:55 +01:00
Steve Dower df7228ce14
gh-124254: Detect freethreaded MSI component when doing an upgrade on Windows (GH-124279) 2024-09-23 16:27:46 +01:00
Petr Viktorin aee219f455
gh-123880: Allow recursive import of single-phase-init modules (GH-123950)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Brett Cannon <brett@python.org>
2024-09-20 10:27:34 +02:00
Nate Ohlson 81480e6edb
gh-124190: Ignore files directories check warning tooling (#124193)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-09-18 10:49:43 +03:00
Nate Ohlson 29a1a6e3ed
gh-124191: Disable -Wconversion in enable safety (gh-124192) 2024-09-18 12:55:09 +09:00
Victor Stinner 3aff1d0260
gh-124064: Fix -Wconversion warnings in Parser/pegen.c (#124181) 2024-09-17 15:58:43 +00:00
Victor Stinner ec08aa1fe4
gh-124064: Fix -Wconversion warnings in pycore_{long,object}.h (#124177)
Change also the fix for pycore_gc.h and pycore_stackref.h:
declare constants as uintptr_t, rather than casting constants.
2024-09-17 15:35:40 +00:00
Victor Stinner 98f93a32f3
gh-124064: Fix -Wconversion warnings in pycore_{gc,list,stackref}.h (#124174) 2024-09-17 14:43:39 +00:00
Petr Viktorin 4d09719341
Tools/build/stable_abi.py: Improve ergonomics (GH-105355)
* Tools/build/stable_abi.py: Improve ergonomics

- Make the manifest file argument optional
- Output resolved paths with --list (getting rid of `../../`)
- Mention --all or --generate-all if no actions are specified

* Don't hardcode Misc/stable_abi.toml in Makefile, rely on the default
2024-09-17 14:32:04 +02:00
Nate Ohlson 44052b5f18
gh-124064: Make warning emitting compiler options opt-in (#124070)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-09-16 20:22:30 +03:00
Hugo van Kemenade ea77973718
Revert "gh-112301: Enable warning emitting options and ignore warnings in CI (#123020)" (#124065) 2024-09-13 22:47:12 +03:00
Benjamin Peterson bb904e063d
closes gh-124016: update Unicode to 16.0.0 (#124017) 2024-09-13 07:47:04 -07:00
Nate Ohlson cfe6074d1f
gh-112301: Enable warning emitting options and ignore warnings in CI (#123020)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-09-13 13:40:04 +00:00
Bénédikt Tran acb3f875fb
gh-123961: Add `curses` prefix to global variables in `_cursesmodule.c` (#124047)
Use the `const char*` type instead of a `const *` for the encoding name.
2024-09-13 12:43:06 +00:00
Bénédikt Tran 403f3ddedc
gh-123961: Remove global variable `ModDict` in `_cursesmodule.c` (#123962) 2024-09-13 10:33:13 +00:00
Sam Gross b2afe2aae4
gh-123923: Defer refcounting for `f_executable` in `_PyInterpreterFrame` (#123924)
Use a `_PyStackRef` and defer the reference to `f_executable` when
possible. This avoids some reference count contention in the common case
of executing the same code object from multiple threads concurrently in
the free-threaded build.
2024-09-12 12:37:06 -04:00
Mark Shannon 4ed7d1d6ac
GH-123996: Explicitly mark 'self_or_null' as an array of size 1 to ensure that it is kept in memory for calls (GH-124003) 2024-09-12 15:32:45 +01:00
adang1345 00ffdf2736
gh-123915: Ensure that Windows AMD64 and ARM64 release builds use different directories (GH-123918) 2024-09-10 19:52:49 +00:00
Victor Stinner fb1b51a58d
gh-123892: Add "_wmi" to sys.stdlib_module_names (#123893) 2024-09-10 09:54:17 +00:00
Irit Katriel 1a9d8917a3
gh-121404: split compile.c into compile.c and codegen.c (#123651) 2024-09-09 18:21:51 +01:00
algonell 9017b95ff2
Fix typos (#123775) 2024-09-09 14:58:26 +02:00
Nadeshiko Manju 8a46a2ec50
gh-117657: Fix file descriptor race in test_socket.py (#123697) 2024-09-06 15:00:28 -04:00
Zachary Ware d83e30cadd
gh-123700: Update OpenSSL versions in multissltests and CI (#123701)
Remove EOL 1.1.1w from CI and move it to the 'old' set in multissltests,
add latest 3.3.2 to both CI and multissltests.
2024-09-04 14:29:41 -05:00
Zachary Ware 56b00f4705
gh-123418: Update CI to use fresh OpenSSL releases (GH-123675)
Also adds openssl/openssl GitHub URL template for newer OpenSSL downloads
2024-09-04 13:16:53 -05:00
Victor Stinner 33b790978d
gh-107954, PEP 741: Add PyConfig_Get()/Set() functions (#123472)
Add PyConfig_Get(), PyConfig_GetInt(), PyConfig_Set() and
PyConfig_Names() functions to get and set the current runtime Python
configuration.

Add visibility and "sys spec" to config and preconfig specifications.

_PyConfig_AsDict() now converts PyConfig.xoptions as a dictionary.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-09-02 23:25:08 +02:00
Seth Michael Larson db42934270
gh-123458: Skip SBOM generation if no git repository is detected (#123507) 2024-09-02 22:35:30 +03:00
dependabot[bot] 88210c295d
build(deps): bump hypothesis from 6.108.10 to 6.111.2 in /Tools (#123567)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-02 08:04:50 +03:00
dependabot[bot] 64af2b29d2
Bump types-setuptools from 71.1.0.20240726 to 74.0.0.20240831 in /Tools (#123565)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-01 10:38:58 +00:00
dependabot[bot] d9439a205a
Bump mypy from 1.11.1 to 1.11.2 in /Tools (#123566)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-01 10:10:10 +00:00
dependabot[bot] bb6fe14921
Bump types-psutil from 6.0.0.20240621 to 6.0.0.20240901 in /Tools (#123564)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-01 11:09:51 +01:00
Mark Shannon a4fd7aa4a6
GH-115776: Allow any fixed sized object to have inline values (GH-123192) 2024-08-21 15:52:04 +01:00
Mark Shannon bb1d30336e
GH-118093: Make `CALL_ALLOC_AND_ENTER_INIT` suitable for tier 2. (GH-123140)
* Convert CALL_ALLOC_AND_ENTER_INIT to micro-ops such that tier 2 supports it

* Allow inexact arguments for CALL_ALLOC_AND_ENTER_INIT.
2024-08-20 16:52:58 +01:00
Brett Cannon b15b81ed4f
GH-121634: have `wasi.py` accept the host target triple as an argument (GH-123030) 2024-08-15 10:30:08 -07:00
Nate Ohlson 1cf624be6d
gh-112301: Add warning count to warning check tooling (#122711)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-08-15 00:03:53 +03:00
Brandt Bucher 51185923a8
GH-113464: Speed up JIT builds (GH-122839) 2024-08-14 07:53:46 -07:00
Mark Shannon eec7bdaf01
GH-120024: Remove `CHECK_EVAL_BREAKER` macro. (GH-122968)
* Factor some instructions into micro-ops to isolate CHECK_EVAL_BREAKER for escape analysis

* Eliminate CHECK_EVAL_BREAKER macro
2024-08-14 12:04:05 +01:00
Bénédikt Tran 7b8328b6b3
GH-121723: Skip test_config_queue_handler_multiprocessing_context in emulated JIT CI (#122969) 2024-08-13 16:25:36 -07:00
Jonathan Protzenko 325e9b8ef4
gh-99108: Add HACL* Blake2 implementation to hashlib (GH-119316)
This replaces the existing hashlib Blake2 module with a single implementation that uses HACL\*'s Blake2b/Blake2s implementations. We added support for all the modes exposed by the Python API, including tree hashing, leaf nodes, and so on. We ported and merged all of these changes upstream in HACL\*, added test vectors based on Python's existing implementation, and exposed everything needed for hashlib.

This was joint work done with @R1kM.

See the PR for much discussion and benchmarking details.   TL;DR: On many systems, 8-50% faster (!) than `libb2`, on some systems it appeared 10-20% slower than `libb2`.
2024-08-13 21:42:19 +00:00
Eric Snow ee1b8ce26e
gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952)
As of 529a160 (gh-118204), building with HAVE_DYNAMIC_LOADING stopped working.  This is a minimal fix just to get builds working again.  There are actually a number of long-standing deficiencies with HAVE_DYNAMIC_LOADING builds that need to be resolved separately.
2024-08-13 14:44:57 -06:00
Mark Shannon 7a65439b93
GH-122390: Replace `_Py_GetbaseOpcode` with `_Py_GetBaseCodeUnit` (GH-122942) 2024-08-13 14:22:57 +01:00
Sam Gross ab094d1b2b
gh-117139: Replace _PyList_FromArraySteal with stack ref variant (#122830)
This replaces `_PyList_FromArraySteal` with `_PyList_FromStackRefSteal`.
It's functionally equivalent, but takes a `_PyStackRef` array instead of
an array of `PyObject` pointers.

Co-authored-by: Ken Jin <kenjin@python.org>
2024-08-12 14:49:49 -04:00
Serhiy Storchaka 8393608dd9
gh-122688: Fix support of var-positional parameter in Argument Clinic (GH-122689)
* Parameters after the var-positional parameter are now keyword-only
  instead of positional-or-keyword.
* Correctly calculate min_kw_only.
* Raise errors for invalid combinations of the var-positional parameter
  with "*", "/" and deprecation markers.
2024-08-09 09:22:41 +00:00
Mark Shannon 81c739e2dc
GH-120024: Tidy up case generator code a bit. (GH-122780) 2024-08-08 10:57:59 +01:00
Sam Gross 3e753c689a
gh-118926: Spill deferred references to stack in cases generator (#122748)
This automatically spills the results from `_PyStackRef_FromPyObjectNew`
to the in-memory stack so that the deferred references are visible to
the GC before we make any possibly escaping call.

Co-authored-by: Ken Jin <kenjin@python.org>
2024-08-07 13:23:53 -04:00
dependabot[bot] 19dd2dcbde
Bump types-setuptools to 71.1.0.20240726 in /Tools (#122551) 2024-08-07 16:20:37 +01:00
Nate Ohlson 58be1c270f
gh-112301: Add macOS warning tracking tooling (#122211)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-08-06 20:26:37 +03:00
Sergey B Kirpichev 6ff82fdb56
gh-122686: bump hypothesis from 6.104.2 to 6.108.10 in Tools (#122729)
This drops attrs pinning.
2024-08-06 14:37:07 +02:00
Mark Shannon fbfab4f88c
GH-120024: Refactor code generators to uses classes for emitting code. (GH-122730) 2024-08-06 13:04:33 +01:00
Jelle Zijlstra b72c748d7f
Fix syntax in generate_re_casefix.py (#122699)
This was broken in gh-97963.
2024-08-05 23:16:29 -07:00
Sergey B Kirpichev 35ae4aab1a
gh-122686: Pin attrs package (for Hypothesis workflow) (#122687)
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-08-06 06:56:50 +03:00
Miro Hrončok 44659d3927
GH-118943: Handle races when moving jit_stencils.h (GH-120690)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-08-05 16:10:40 -07:00
dependabot[bot] 5207adf228
build(deps-dev): bump mypy from 1.10.1 to 1.11.1 in /Tools (#122550)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
2024-08-05 09:03:14 +00:00
Adam Turner cc6839a181
GH-109408: Stop running patchcheck in CI (#109895) 2024-08-03 12:52:21 +01:00
Mark Shannon a9d56e38a0
GH-122155: Track local variables between pops and pushes in cases generator (GH-122286) 2024-08-01 09:27:26 +01:00
Nate Ohlson 1cac0908fb
gh-112301: Add argument aliases and tee compiler output for check warnings (GH-122465)
Also remove superfluous shebang from the warning check script
2024-07-30 14:49:15 -05:00
Sam Gross 2b163aa9e7
gh-117657: Avoid race in `PAUSE_ADAPTIVE_COUNTER` in free-threaded build (#122190)
The adaptive counter doesn't do anything currently in the free-threaded
build and TSan reports a data race due to concurrent modifications to
the counter.
2024-07-30 13:53:47 -04:00
Seth Michael Larson 4e04d1a3d2
gh-122044: Don't error during gitignore filtering with no files (#122045) 2024-07-27 14:10:05 +03:00
Nate Ohlson 8ac5565be2
gh-112301: Compiler warning management tooling (#121730)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-07-27 09:57:44 +00:00
Sam Gross c557ae97d6
gh-122201: Lock mutex when setting handling_thread to NULL (#122204)
In the free-threaded build, we need to lock pending->mutex when clearing
the handling_thread in order not to race with a concurrent
make_pending_calls in the same interpreter.
2024-07-26 13:06:07 -04:00
Mark Shannon afb0aa6ed2
GH-121131: Clean up and fix some instrumented instructions. (GH-121132)
* Add support for 'prev_instr' to code generator and refactor some INSTRUMENTED instructions
2024-07-26 12:24:12 +01:00
Serhiy Storchaka 6c09b8de5c
gh-122270: Fix typos in the Py_DEBUG macro name (GH-122271) 2024-07-25 14:04:22 +03:00
Mark Shannon 624bda7638
GH-122155: Fix cases generator to correctly compute 'peek' offset for error handling (GH-122158) 2024-07-23 14:12:06 +01:00
Adam Turner 22c9d9c1fc
GH-121970: Rewrite the C-API annotations extension (#121985)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-07-19 12:21:56 +00:00
Mark Shannon 3eacfc1a4d
GH-121784: Generate an error during code gen if a variable is marked `unused`, but is used and thus cached in a prior uop. (#121788)
* Reject uop definitions that declare values as 'unused' that are already cached by prior uops

* Track which variables are defined and only load from memory when needed

* Support explicit `flush` in macro definitions. 

* Make sure stack is flushed in where needed.
2024-07-18 12:49:24 +01:00
Savannah Ostrowski f113c1a2a9
Add note about PYTHON_JIT environment variable to JIT README (GH-121635) 2024-07-17 15:17:47 -07:00
Brett Cannon f589f263bc
GH-120371: Add WASI SDK 22 support (GH-121870)
Required disabling stub functions now provided by wasi-libc.
2024-07-16 20:00:39 +00:00
Sam Gross 7641743d48
gh-117657: Remove TSAN suppressions for _abc.c (#121508)
The functions look thread-safe and I haven't seen any warnings issued
when running the tests locally.
2024-07-10 17:08:10 -04:00
Sam Gross 3ec719fabf
gh-117657: Fix TSan race in _PyDict_CheckConsistency (#121551)
The only remaining race in dictobject.c was in _PyDict_CheckConsistency
when the dictionary has shared keys.
2024-07-10 14:04:12 -04:00
Brett Cannon f62161837e
GH-121521: Detect when wasmtime is not installed in `Tools/wasm/wasi.py` (GH-121522) 2024-07-09 15:08:01 -07:00
Sam Gross 9c08f40a61
gh-117657: Fix TSAN races in setobject.c (#121511)
The `used` field must be written using atomic stores because `set_len`
and iterators may access the field concurrently without holding the
per-object lock.
2024-07-09 12:11:43 -04:00
Mark Shannon bf8686e1ea
GH-118926: Better distinguish between pointer and arrays in interpreter generator (GH-121496) 2024-07-09 11:33:56 +01:00
Diego Russo 84512c0e7f
GH-119726: Emit AArch64 trampolines out-of-line (GH-121280) 2024-07-03 06:22:21 -07:00
dependabot[bot] f49c83aa66
build(deps): bump hypothesis from 6.100.2 to 6.104.2 in /Tools (#121218)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.100.2 to 6.104.2.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.100.2...hypothesis-python-6.104.2)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-03 13:22:59 +05:30
Sam Gross 8e8d202f55
gh-117139: Add _PyTuple_FromStackRefSteal and use it (#121244)
Avoids the extra conversion from stack refs to PyObjects.
2024-07-02 12:30:14 -04:00
Diego Russo 966260841b
GH-119726: Use LDR for AArch64 trampolines (GH-121001) 2024-07-01 15:52:33 -07:00
Brandt Bucher 33903c53db
GH-116017: Get rid of _COLD_EXITs (GH-120960) 2024-07-01 13:17:40 -07:00
AN Long 294e724964
gh-117657: Fix data races reported by TSAN in some set methods (#120914)
Refactor the fast Unicode hash check into `_PyObject_HashFast` and use relaxed
atomic loads in the free-threaded build.

After this change, the TSAN doesn't report data races for this method.
2024-07-01 15:11:39 -04:00
AN Long 8a5176772c
gh-117657: Use critical section to make _socket.socket.close thread safe (GH-120490) 2024-07-01 16:38:30 +02:00
dependabot[bot] 8d0cafd6f2
build(deps-dev): bump types-setuptools from 70.0.0.20240524 to 70.1.0.20240627 in /Tools (#121217)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-01 10:42:46 +00:00
dependabot[bot] c9302e814a
build(deps-dev): bump mypy from 1.10.0 to 1.10.1 in /Tools (#121216)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-01 10:15:53 +00:00
dependabot[bot] 7e8f334f90
build(deps-dev): bump types-psutil from 5.9.5.20240516 to 6.0.0.20240621 in /Tools (#121215)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-01 10:15:25 +00:00
Sergey B Kirpichev 6988ff02a5
gh-61103: Support double complex (_Complex) type in ctypes (#120894)
Example:

```pycon
>>> import ctypes
>>> ctypes.__STDC_IEC_559_COMPLEX__
1
>>> libm = ctypes.CDLL('libm.so.6')
>>> libm.clog.argtypes = [ctypes.c_double_complex]
>>> libm.clog.restype = ctypes.c_double_complex
>>> libm.clog(1+1j)
(0.34657359027997264+0.7853981633974483j)
```

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-07-01 10:54:33 +02:00
Ken Jin 22b0de2755
gh-117139: Convert the evaluation stack to stack refs (#118450)
This PR sets up tagged pointers for CPython.

The general idea is to create a separate struct _PyStackRef for everything on the evaluation stack to store the bits. This forces the C compiler to warn us if we try to cast things or pull things out of the struct directly.

Only for free threading: We tag the low bit if something is deferred - that means we skip incref and decref operations on it. This behavior may change in the future if Mark's plans to defer all objects in the interpreter loop pans out.

This implies a strict stack reference discipline is required. ALL incref and decref operations on stackrefs must use the stackref variants. It is unsafe to untag something then do normal incref/decref ops on it.

The new incref and decref variants are called dup and close. They mimic a "handle" API operating on these stackrefs.

Please read Include/internal/pycore_stackref.h for more information!

---------

Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
2024-06-27 03:10:43 +08:00
Mark Shannon 8f5a01707f
GH-120982: Add stack check assertions to generated interpreter code (GH-120992) 2024-06-25 16:42:29 +01:00
Lysandros Nikolaou 348184845a
gh-120956: Avoid comparison of int to Py_ssize_t in parser (#120959) 2024-06-24 18:13:02 +02:00
Brandt Bucher a47abdb45d
GH-117062: Make _JUMP_TO_TOP a general absolute jump (GH-120854) 2024-06-24 08:35:10 -07:00
Petr Viktorin 6f1d448bc1
gh-113993: Allow interned strings to be mortal, and fix related issues (GH-120520)
* Add an InternalDocs file describing how interning should work and how to use it.

* Add internal functions to *explicitly* request what kind of interning is done:
  - `_PyUnicode_InternMortal`
  - `_PyUnicode_InternImmortal`
  - `_PyUnicode_InternStatic`

* Switch uses of `PyUnicode_InternInPlace` to those.

* Disallow using `_Py_SetImmortal` on strings directly.
  You should use `_PyUnicode_InternImmortal` instead:
  - Strings should be interned before immortalization, otherwise you're possibly
    interning a immortalizing copy.
  - `_Py_SetImmortal` doesn't handle the `SSTATE_INTERNED_MORTAL` to
    `SSTATE_INTERNED_IMMORTAL` update, and those flags can't be changed in
    backports, as they are now part of public API and version-specific ABI.

* Add private `_only_immortal` argument for `sys.getunicodeinternedsize`, used in refleak test machinery.

* Make sure the statically allocated string singletons are unique. This means these sets are now disjoint:
  - `_Py_ID`
  - `_Py_STR` (including the empty string)
  - one-character latin-1 singletons

  Now, when you intern a singleton, that exact singleton will be interned.

* Add a `_Py_LATIN1_CHR` macro, use it instead of `_Py_ID`/`_Py_STR` for one-character latin-1 singletons everywhere (including Clinic).

* Intern `_Py_STR` singletons at startup.

* For free-threaded builds, intern `_Py_LATIN1_CHR` singletons at startup.

* Beef up the tests. Cover internal details (marked with `@cpython_only`).

* Add lots of assertions

Co-Authored-By: Eric Snow <ericsnowcurrently@gmail.com>
2024-06-21 17:19:31 +02:00
Xarblu 285f42c850
GH-120602: Support LLVM_VERSION_SUFFIX for JIT builds (GH-120604) 2024-06-19 17:48:00 -07:00
yf-yang ace2045ea6
Fix types in pegen parser generator (GH-120720) 2024-06-19 16:12:40 +02:00