mirror of
https://github.com/python/cpython.git
synced 2025-11-14 07:49:28 +00:00
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>
This commit is contained in:
parent
7595e6743a
commit
6f1d448bc1
42 changed files with 2464 additions and 1140 deletions
|
|
@ -551,12 +551,10 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_setcomp));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_string));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_unknown));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(close_br));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_close_br));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_open_br));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_percent));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(defaults));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dot));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dot_locals));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(empty));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(format));
|
||||
|
|
@ -564,9 +562,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(json_decoder));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(kwdefaults));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(list_err));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(newline));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(open_br));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(percent));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(type_params));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(utf_8));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(CANCELLED));
|
||||
|
|
@ -578,7 +573,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(TextIOWrapper));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(True));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(WarningMessage));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_WindowsConsoleIO));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__IOBase_closed));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__abc_tpflags__));
|
||||
|
|
@ -772,6 +766,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_lock_unlock_module));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_loop));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_needs_com_addref_));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_only_immortal));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_pack_));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_restype_));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_showwarnmsg));
|
||||
|
|
@ -784,7 +779,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_uninitialized_submodules));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_warn_unawaited_coroutine));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_xoptions));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(a));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(abs_tol));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(access));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(aclose));
|
||||
|
|
@ -808,7 +802,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(attribute));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(authorizer_callback));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(autocommit));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(b));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(backtick));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(base));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(before));
|
||||
|
|
@ -826,7 +819,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(byteorder));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(bytes));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(bytes_per_sep));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(c));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(c_call));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(c_exception));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(c_return));
|
||||
|
|
@ -882,7 +874,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(count));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(covariant));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(cwd));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(d));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(data));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(database));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(day));
|
||||
|
|
@ -911,7 +902,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dont_inherit));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dst));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dst_dir_fd));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(e));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(eager_start));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(effective_ids));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(element_factory));
|
||||
|
|
@ -935,7 +925,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(exp));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(extend));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(extra_tokens));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(f));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(facility));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(factory));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(false));
|
||||
|
|
@ -968,7 +957,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fset));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(func));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(future));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(g));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(generation));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(genexpr));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(get));
|
||||
|
|
@ -982,7 +970,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(globals));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(groupindex));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(groups));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(h));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(handle));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(handle_seq));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(has_location));
|
||||
|
|
@ -1093,7 +1080,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(msg));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mutex));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mycmp));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n_arg));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n_fields));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n_sequence_fields));
|
||||
|
|
@ -1139,7 +1125,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(outgoing));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(overlapped));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(owner));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(p));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(pages));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(parent));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(password));
|
||||
|
|
@ -1167,7 +1152,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ps2));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(query));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(quotetabs));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(r));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(raw));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(read));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(read1));
|
||||
|
|
@ -1191,7 +1175,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(return));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reverse));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reversed));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(s));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(salt));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(sched_priority));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(scheduler));
|
||||
|
|
@ -1298,7 +1281,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(writable));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(write));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(write_through));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(x));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(year));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(zdict));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[0]);
|
||||
|
|
|
|||
|
|
@ -37,12 +37,10 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_STR(anon_setcomp, "<setcomp>")
|
||||
STRUCT_FOR_STR(anon_string, "<string>")
|
||||
STRUCT_FOR_STR(anon_unknown, "<unknown>")
|
||||
STRUCT_FOR_STR(close_br, "}")
|
||||
STRUCT_FOR_STR(dbl_close_br, "}}")
|
||||
STRUCT_FOR_STR(dbl_open_br, "{{")
|
||||
STRUCT_FOR_STR(dbl_percent, "%%")
|
||||
STRUCT_FOR_STR(defaults, ".defaults")
|
||||
STRUCT_FOR_STR(dot, ".")
|
||||
STRUCT_FOR_STR(dot_locals, ".<locals>")
|
||||
STRUCT_FOR_STR(empty, "")
|
||||
STRUCT_FOR_STR(format, ".format")
|
||||
|
|
@ -50,9 +48,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_STR(json_decoder, "json.decoder")
|
||||
STRUCT_FOR_STR(kwdefaults, ".kwdefaults")
|
||||
STRUCT_FOR_STR(list_err, "list index out of range")
|
||||
STRUCT_FOR_STR(newline, "\n")
|
||||
STRUCT_FOR_STR(open_br, "{")
|
||||
STRUCT_FOR_STR(percent, "%")
|
||||
STRUCT_FOR_STR(type_params, ".type_params")
|
||||
STRUCT_FOR_STR(utf_8, "utf-8")
|
||||
} literals;
|
||||
|
|
@ -67,7 +62,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(TextIOWrapper)
|
||||
STRUCT_FOR_ID(True)
|
||||
STRUCT_FOR_ID(WarningMessage)
|
||||
STRUCT_FOR_ID(_)
|
||||
STRUCT_FOR_ID(_WindowsConsoleIO)
|
||||
STRUCT_FOR_ID(__IOBase_closed)
|
||||
STRUCT_FOR_ID(__abc_tpflags__)
|
||||
|
|
@ -261,6 +255,7 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(_lock_unlock_module)
|
||||
STRUCT_FOR_ID(_loop)
|
||||
STRUCT_FOR_ID(_needs_com_addref_)
|
||||
STRUCT_FOR_ID(_only_immortal)
|
||||
STRUCT_FOR_ID(_pack_)
|
||||
STRUCT_FOR_ID(_restype_)
|
||||
STRUCT_FOR_ID(_showwarnmsg)
|
||||
|
|
@ -273,7 +268,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(_uninitialized_submodules)
|
||||
STRUCT_FOR_ID(_warn_unawaited_coroutine)
|
||||
STRUCT_FOR_ID(_xoptions)
|
||||
STRUCT_FOR_ID(a)
|
||||
STRUCT_FOR_ID(abs_tol)
|
||||
STRUCT_FOR_ID(access)
|
||||
STRUCT_FOR_ID(aclose)
|
||||
|
|
@ -297,7 +291,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(attribute)
|
||||
STRUCT_FOR_ID(authorizer_callback)
|
||||
STRUCT_FOR_ID(autocommit)
|
||||
STRUCT_FOR_ID(b)
|
||||
STRUCT_FOR_ID(backtick)
|
||||
STRUCT_FOR_ID(base)
|
||||
STRUCT_FOR_ID(before)
|
||||
|
|
@ -315,7 +308,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(byteorder)
|
||||
STRUCT_FOR_ID(bytes)
|
||||
STRUCT_FOR_ID(bytes_per_sep)
|
||||
STRUCT_FOR_ID(c)
|
||||
STRUCT_FOR_ID(c_call)
|
||||
STRUCT_FOR_ID(c_exception)
|
||||
STRUCT_FOR_ID(c_return)
|
||||
|
|
@ -371,7 +363,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(count)
|
||||
STRUCT_FOR_ID(covariant)
|
||||
STRUCT_FOR_ID(cwd)
|
||||
STRUCT_FOR_ID(d)
|
||||
STRUCT_FOR_ID(data)
|
||||
STRUCT_FOR_ID(database)
|
||||
STRUCT_FOR_ID(day)
|
||||
|
|
@ -400,7 +391,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(dont_inherit)
|
||||
STRUCT_FOR_ID(dst)
|
||||
STRUCT_FOR_ID(dst_dir_fd)
|
||||
STRUCT_FOR_ID(e)
|
||||
STRUCT_FOR_ID(eager_start)
|
||||
STRUCT_FOR_ID(effective_ids)
|
||||
STRUCT_FOR_ID(element_factory)
|
||||
|
|
@ -424,7 +414,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(exp)
|
||||
STRUCT_FOR_ID(extend)
|
||||
STRUCT_FOR_ID(extra_tokens)
|
||||
STRUCT_FOR_ID(f)
|
||||
STRUCT_FOR_ID(facility)
|
||||
STRUCT_FOR_ID(factory)
|
||||
STRUCT_FOR_ID(false)
|
||||
|
|
@ -457,7 +446,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(fset)
|
||||
STRUCT_FOR_ID(func)
|
||||
STRUCT_FOR_ID(future)
|
||||
STRUCT_FOR_ID(g)
|
||||
STRUCT_FOR_ID(generation)
|
||||
STRUCT_FOR_ID(genexpr)
|
||||
STRUCT_FOR_ID(get)
|
||||
|
|
@ -471,7 +459,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(globals)
|
||||
STRUCT_FOR_ID(groupindex)
|
||||
STRUCT_FOR_ID(groups)
|
||||
STRUCT_FOR_ID(h)
|
||||
STRUCT_FOR_ID(handle)
|
||||
STRUCT_FOR_ID(handle_seq)
|
||||
STRUCT_FOR_ID(has_location)
|
||||
|
|
@ -582,7 +569,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(msg)
|
||||
STRUCT_FOR_ID(mutex)
|
||||
STRUCT_FOR_ID(mycmp)
|
||||
STRUCT_FOR_ID(n)
|
||||
STRUCT_FOR_ID(n_arg)
|
||||
STRUCT_FOR_ID(n_fields)
|
||||
STRUCT_FOR_ID(n_sequence_fields)
|
||||
|
|
@ -628,7 +614,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(outgoing)
|
||||
STRUCT_FOR_ID(overlapped)
|
||||
STRUCT_FOR_ID(owner)
|
||||
STRUCT_FOR_ID(p)
|
||||
STRUCT_FOR_ID(pages)
|
||||
STRUCT_FOR_ID(parent)
|
||||
STRUCT_FOR_ID(password)
|
||||
|
|
@ -656,7 +641,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(ps2)
|
||||
STRUCT_FOR_ID(query)
|
||||
STRUCT_FOR_ID(quotetabs)
|
||||
STRUCT_FOR_ID(r)
|
||||
STRUCT_FOR_ID(raw)
|
||||
STRUCT_FOR_ID(read)
|
||||
STRUCT_FOR_ID(read1)
|
||||
|
|
@ -680,7 +664,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(return)
|
||||
STRUCT_FOR_ID(reverse)
|
||||
STRUCT_FOR_ID(reversed)
|
||||
STRUCT_FOR_ID(s)
|
||||
STRUCT_FOR_ID(salt)
|
||||
STRUCT_FOR_ID(sched_priority)
|
||||
STRUCT_FOR_ID(scheduler)
|
||||
|
|
@ -787,7 +770,6 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(writable)
|
||||
STRUCT_FOR_ID(write)
|
||||
STRUCT_FOR_ID(write_through)
|
||||
STRUCT_FOR_ID(x)
|
||||
STRUCT_FOR_ID(year)
|
||||
STRUCT_FOR_ID(zdict)
|
||||
} identifiers;
|
||||
|
|
@ -810,6 +792,10 @@ struct _Py_global_strings {
|
|||
(_Py_SINGLETON(strings.identifiers._py_ ## NAME._ascii.ob_base))
|
||||
#define _Py_STR(NAME) \
|
||||
(_Py_SINGLETON(strings.literals._py_ ## NAME._ascii.ob_base))
|
||||
#define _Py_LATIN1_CHR(CH) \
|
||||
((CH) < 128 \
|
||||
? (PyObject*)&_Py_SINGLETON(strings).ascii[(CH)] \
|
||||
: (PyObject*)&_Py_SINGLETON(strings).latin1[(CH) - 128])
|
||||
|
||||
/* _Py_DECLARE_STR() should precede all uses of _Py_STR() in a function.
|
||||
|
||||
|
|
|
|||
20
Include/internal/pycore_runtime_init_generated.h
generated
20
Include/internal/pycore_runtime_init_generated.h
generated
|
|
@ -546,12 +546,10 @@ extern "C" {
|
|||
INIT_STR(anon_setcomp, "<setcomp>"), \
|
||||
INIT_STR(anon_string, "<string>"), \
|
||||
INIT_STR(anon_unknown, "<unknown>"), \
|
||||
INIT_STR(close_br, "}"), \
|
||||
INIT_STR(dbl_close_br, "}}"), \
|
||||
INIT_STR(dbl_open_br, "{{"), \
|
||||
INIT_STR(dbl_percent, "%%"), \
|
||||
INIT_STR(defaults, ".defaults"), \
|
||||
INIT_STR(dot, "."), \
|
||||
INIT_STR(dot_locals, ".<locals>"), \
|
||||
INIT_STR(empty, ""), \
|
||||
INIT_STR(format, ".format"), \
|
||||
|
|
@ -559,9 +557,6 @@ extern "C" {
|
|||
INIT_STR(json_decoder, "json.decoder"), \
|
||||
INIT_STR(kwdefaults, ".kwdefaults"), \
|
||||
INIT_STR(list_err, "list index out of range"), \
|
||||
INIT_STR(newline, "\n"), \
|
||||
INIT_STR(open_br, "{"), \
|
||||
INIT_STR(percent, "%"), \
|
||||
INIT_STR(type_params, ".type_params"), \
|
||||
INIT_STR(utf_8, "utf-8"), \
|
||||
}
|
||||
|
|
@ -576,7 +571,6 @@ extern "C" {
|
|||
INIT_ID(TextIOWrapper), \
|
||||
INIT_ID(True), \
|
||||
INIT_ID(WarningMessage), \
|
||||
INIT_ID(_), \
|
||||
INIT_ID(_WindowsConsoleIO), \
|
||||
INIT_ID(__IOBase_closed), \
|
||||
INIT_ID(__abc_tpflags__), \
|
||||
|
|
@ -770,6 +764,7 @@ extern "C" {
|
|||
INIT_ID(_lock_unlock_module), \
|
||||
INIT_ID(_loop), \
|
||||
INIT_ID(_needs_com_addref_), \
|
||||
INIT_ID(_only_immortal), \
|
||||
INIT_ID(_pack_), \
|
||||
INIT_ID(_restype_), \
|
||||
INIT_ID(_showwarnmsg), \
|
||||
|
|
@ -782,7 +777,6 @@ extern "C" {
|
|||
INIT_ID(_uninitialized_submodules), \
|
||||
INIT_ID(_warn_unawaited_coroutine), \
|
||||
INIT_ID(_xoptions), \
|
||||
INIT_ID(a), \
|
||||
INIT_ID(abs_tol), \
|
||||
INIT_ID(access), \
|
||||
INIT_ID(aclose), \
|
||||
|
|
@ -806,7 +800,6 @@ extern "C" {
|
|||
INIT_ID(attribute), \
|
||||
INIT_ID(authorizer_callback), \
|
||||
INIT_ID(autocommit), \
|
||||
INIT_ID(b), \
|
||||
INIT_ID(backtick), \
|
||||
INIT_ID(base), \
|
||||
INIT_ID(before), \
|
||||
|
|
@ -824,7 +817,6 @@ extern "C" {
|
|||
INIT_ID(byteorder), \
|
||||
INIT_ID(bytes), \
|
||||
INIT_ID(bytes_per_sep), \
|
||||
INIT_ID(c), \
|
||||
INIT_ID(c_call), \
|
||||
INIT_ID(c_exception), \
|
||||
INIT_ID(c_return), \
|
||||
|
|
@ -880,7 +872,6 @@ extern "C" {
|
|||
INIT_ID(count), \
|
||||
INIT_ID(covariant), \
|
||||
INIT_ID(cwd), \
|
||||
INIT_ID(d), \
|
||||
INIT_ID(data), \
|
||||
INIT_ID(database), \
|
||||
INIT_ID(day), \
|
||||
|
|
@ -909,7 +900,6 @@ extern "C" {
|
|||
INIT_ID(dont_inherit), \
|
||||
INIT_ID(dst), \
|
||||
INIT_ID(dst_dir_fd), \
|
||||
INIT_ID(e), \
|
||||
INIT_ID(eager_start), \
|
||||
INIT_ID(effective_ids), \
|
||||
INIT_ID(element_factory), \
|
||||
|
|
@ -933,7 +923,6 @@ extern "C" {
|
|||
INIT_ID(exp), \
|
||||
INIT_ID(extend), \
|
||||
INIT_ID(extra_tokens), \
|
||||
INIT_ID(f), \
|
||||
INIT_ID(facility), \
|
||||
INIT_ID(factory), \
|
||||
INIT_ID(false), \
|
||||
|
|
@ -966,7 +955,6 @@ extern "C" {
|
|||
INIT_ID(fset), \
|
||||
INIT_ID(func), \
|
||||
INIT_ID(future), \
|
||||
INIT_ID(g), \
|
||||
INIT_ID(generation), \
|
||||
INIT_ID(genexpr), \
|
||||
INIT_ID(get), \
|
||||
|
|
@ -980,7 +968,6 @@ extern "C" {
|
|||
INIT_ID(globals), \
|
||||
INIT_ID(groupindex), \
|
||||
INIT_ID(groups), \
|
||||
INIT_ID(h), \
|
||||
INIT_ID(handle), \
|
||||
INIT_ID(handle_seq), \
|
||||
INIT_ID(has_location), \
|
||||
|
|
@ -1091,7 +1078,6 @@ extern "C" {
|
|||
INIT_ID(msg), \
|
||||
INIT_ID(mutex), \
|
||||
INIT_ID(mycmp), \
|
||||
INIT_ID(n), \
|
||||
INIT_ID(n_arg), \
|
||||
INIT_ID(n_fields), \
|
||||
INIT_ID(n_sequence_fields), \
|
||||
|
|
@ -1137,7 +1123,6 @@ extern "C" {
|
|||
INIT_ID(outgoing), \
|
||||
INIT_ID(overlapped), \
|
||||
INIT_ID(owner), \
|
||||
INIT_ID(p), \
|
||||
INIT_ID(pages), \
|
||||
INIT_ID(parent), \
|
||||
INIT_ID(password), \
|
||||
|
|
@ -1165,7 +1150,6 @@ extern "C" {
|
|||
INIT_ID(ps2), \
|
||||
INIT_ID(query), \
|
||||
INIT_ID(quotetabs), \
|
||||
INIT_ID(r), \
|
||||
INIT_ID(raw), \
|
||||
INIT_ID(read), \
|
||||
INIT_ID(read1), \
|
||||
|
|
@ -1189,7 +1173,6 @@ extern "C" {
|
|||
INIT_ID(return), \
|
||||
INIT_ID(reverse), \
|
||||
INIT_ID(reversed), \
|
||||
INIT_ID(s), \
|
||||
INIT_ID(salt), \
|
||||
INIT_ID(sched_priority), \
|
||||
INIT_ID(scheduler), \
|
||||
|
|
@ -1296,7 +1279,6 @@ extern "C" {
|
|||
INIT_ID(writable), \
|
||||
INIT_ID(write), \
|
||||
INIT_ID(write_through), \
|
||||
INIT_ID(x), \
|
||||
INIT_ID(year), \
|
||||
INIT_ID(zdict), \
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ extern "C" {
|
|||
#include "pycore_fileutils.h" // _Py_error_handler
|
||||
#include "pycore_identifier.h" // _Py_Identifier
|
||||
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
|
||||
#include "pycore_global_objects.h" // _Py_SINGLETON
|
||||
|
||||
/* --- Characters Type APIs ----------------------------------------------- */
|
||||
|
||||
|
|
@ -33,6 +34,7 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
|
|||
|
||||
PyAPI_FUNC(void) _PyUnicode_ExactDealloc(PyObject *op);
|
||||
extern Py_ssize_t _PyUnicode_InternedSize(void);
|
||||
extern Py_ssize_t _PyUnicode_InternedSize_Immortal(void);
|
||||
|
||||
// Get a copy of a Unicode string.
|
||||
// Export for '_datetime' shared extension.
|
||||
|
|
@ -275,6 +277,18 @@ extern void _PyUnicode_FiniTypes(PyInterpreterState *);
|
|||
|
||||
extern PyTypeObject _PyUnicodeASCIIIter_Type;
|
||||
|
||||
/* --- Interning ---------------------------------------------------------- */
|
||||
|
||||
// All these are "ref-neutral", like the public PyUnicode_InternInPlace.
|
||||
|
||||
// Explicit interning routines:
|
||||
PyAPI_FUNC(void) _PyUnicode_InternMortal(PyInterpreterState *interp, PyObject **);
|
||||
PyAPI_FUNC(void) _PyUnicode_InternImmortal(PyInterpreterState *interp, PyObject **);
|
||||
// Left here to help backporting:
|
||||
PyAPI_FUNC(void) _PyUnicode_InternInPlace(PyInterpreterState *interp, PyObject **p);
|
||||
// Only for singletons in the _PyRuntime struct:
|
||||
extern void _PyUnicode_InternStatic(PyInterpreterState *interp, PyObject **);
|
||||
|
||||
/* --- Other API ---------------------------------------------------------- */
|
||||
|
||||
struct _Py_unicode_runtime_ids {
|
||||
|
|
@ -311,7 +325,6 @@ struct _Py_unicode_state {
|
|||
struct _Py_unicode_ids ids;
|
||||
};
|
||||
|
||||
extern void _PyUnicode_InternInPlace(PyInterpreterState *interp, PyObject **p);
|
||||
extern void _PyUnicode_ClearInterned(PyInterpreterState *interp);
|
||||
|
||||
// Like PyUnicode_AsUTF8(), but check for embedded null characters.
|
||||
|
|
|
|||
2288
Include/internal/pycore_unicodeobject_generated.h
generated
2288
Include/internal/pycore_unicodeobject_generated.h
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue