cpython/Lib/test/libregrtest
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
..
__init__.py gh-109162: libregrtest: use relative imports (#109250) 2023-09-11 07:02:35 +00:00
cmdline.py gh-119727: Add --single-process option to regrtest (#119728) 2024-06-03 16:34:36 +00:00
filter.py gh-110918: Fix side effects of regrtest test_match_tests() (#116718) 2024-03-13 14:20:33 +01:00
findtests.py gh-108303: Move all `pydoc` related test files to new `test.test_pydoc` package (#114506) 2024-02-13 11:40:40 +01:00
logger.py Add support.MS_WINDOWS constant (#110446) 2023-10-06 02:37:28 +02:00
main.py gh-119727: Add --single-process option to regrtest (#119728) 2024-06-03 16:34:36 +00:00
mypy.ini gh-109413: libregrtest: enable mypy's `--strict-optional` check on most files (#112586) 2023-12-01 14:54:33 +00:00
pgo.py gh-110276: Run `test_str`, not `test_unicode`, as part of the PGO build (#110277) 2023-10-03 13:54:21 +01:00
refleak.py gh-113993: Allow interned strings to be mortal, and fix related issues (GH-120520) 2024-06-21 17:19:31 +02:00
result.py gh-110722: Make `-m test -T -j` use sys.monitoring (GH-111710) 2023-11-10 18:17:45 +01:00
results.py gh-119050: Add type hints to libregrtest/results.py (#119144) 2024-05-18 16:21:05 -04:00
run_workers.py gh-119273: Don't run test_ioctl in a process group (#119275) 2024-05-29 12:44:09 +00:00
runtests.py gh-115122: Add --bisect option to regrtest (#115123) 2024-02-18 20:06:39 +00:00
save_env.py gh-109276: libregrtest only checks saved_test_environment() once (#109278) 2023-09-12 05:01:33 +02:00
setup.py gh-109413: Run mypy on `libregrtest` in CI (#112558) 2023-11-30 23:00:14 +00:00
single.py gh-119050: Add XML support to libregrtest refleak checker (#119148) 2024-05-20 17:05:39 -04:00
testresult.py gh-111165: Move test running code from test.support to libregrtest (GH-111166) 2023-10-25 12:41:21 +03:00
tsan.py GH-112536: Add more TSan tests (#116911) 2024-03-17 09:47:14 +01:00
utils.py gh-118013: Use weakrefs for the cache key in `inspect._shadowed_dict` (#118202) 2024-04-24 15:55:02 +01:00
win_utils.py gh-116103: Prevent error in WindowsLoadTracker.__del__ on permission error (GH-116105) 2024-02-29 11:40:18 +01:00
worker.py gh-119727: Add --single-process option to regrtest (#119728) 2024-06-03 16:34:36 +00:00