aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-01-12 10:29:45 +0100
committerGitHub <noreply@github.com>2021-01-12 10:29:45 +0100
commit44bf57aca627bd11a08b12fe4e4b6a0e1d268862 (patch)
tree8a4fd654a088bf39e0cc1cf21f799c05ee5b2bd3 /Include
parentbpo-42870: Document change in argparse help output. (GH-24190) (diff)
downloadcpython-44bf57aca627bd11a08b12fe4e4b6a0e1d268862.tar.gz
cpython-44bf57aca627bd11a08b12fe4e4b6a0e1d268862.tar.bz2
cpython-44bf57aca627bd11a08b12fe4e4b6a0e1d268862.zip
bpo-42882: _PyRuntimeState_Init() leaves unicode next_index unchanged (GH-24193)
Fix the _PyUnicode_FromId() function (_Py_IDENTIFIER(var) API) when Py_Initialize() / Py_Finalize() is called multiple times: preserve _PyRuntime.unicode_ids.next_index value. Use _PyRuntimeState_INIT macro instead memset(0) to reset _PyRuntimeState members to zero.
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_runtime.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Include/internal/pycore_runtime.h b/Include/internal/pycore_runtime.h
index 8c54abbb069..bcd710c4496 100644
--- a/Include/internal/pycore_runtime.h
+++ b/Include/internal/pycore_runtime.h
@@ -51,6 +51,8 @@ typedef struct _Py_AuditHookEntry {
struct _Py_unicode_runtime_ids {
PyThread_type_lock lock;
+ // next_index value must be preserved when Py_Initialize()/Py_Finalize()
+ // is called multiple times: see _PyUnicode_FromId() implementation.
Py_ssize_t next_index;
};
@@ -107,6 +109,8 @@ typedef struct pyruntimestate {
PyPreConfig preconfig;
+ // Audit values must be preserved when Py_Initialize()/Py_Finalize()
+ // is called multiple times.
Py_OpenCodeHookFunction open_code_hook;
void *open_code_userdata;
_Py_AuditHookEntry *audit_hook_head;