mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-47182: Fix crash by named unicode characters after interpreter reinitialization (GH-32212)
Automerge-Triggered-By: GH:tiran
This commit is contained in:
parent
5458b7e39e
commit
44e915028d
3 changed files with 10 additions and 0 deletions
|
@ -343,6 +343,11 @@ class EmbeddingTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
out, err = self.run_embedded_interpreter("test_repeated_init_exec", code)
|
out, err = self.run_embedded_interpreter("test_repeated_init_exec", code)
|
||||||
self.assertEqual(out, 'Tests passed\n' * INIT_LOOPS)
|
self.assertEqual(out, 'Tests passed\n' * INIT_LOOPS)
|
||||||
|
|
||||||
|
def test_ucnhash_capi_reset(self):
|
||||||
|
# bpo-47182: unicodeobject.c:ucnhash_capi was not reset on shutdown.
|
||||||
|
code = "print('\\N{digit nine}')"
|
||||||
|
out, err = self.run_embedded_interpreter("test_repeated_init_exec", code)
|
||||||
|
self.assertEqual(out, '9\n' * INIT_LOOPS)
|
||||||
|
|
||||||
class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
maxDiff = 4096
|
maxDiff = 4096
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix a crash when using a named unicode character like ``"\N{digit nine}"``
|
||||||
|
after the main interpreter has been initialized a second time.
|
|
@ -16085,6 +16085,9 @@ _PyUnicode_Fini(PyInterpreterState *interp)
|
||||||
if (_Py_IsMainInterpreter(interp)) {
|
if (_Py_IsMainInterpreter(interp)) {
|
||||||
// _PyUnicode_ClearInterned() must be called before _PyUnicode_Fini()
|
// _PyUnicode_ClearInterned() must be called before _PyUnicode_Fini()
|
||||||
assert(interned == NULL);
|
assert(interned == NULL);
|
||||||
|
// bpo-47182: force a unicodedata CAPI capsule re-import on
|
||||||
|
// subsequent initialization of main interpreter.
|
||||||
|
ucnhash_capi = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_PyUnicode_FiniEncodings(&state->fs_codec);
|
_PyUnicode_FiniEncodings(&state->fs_codec);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue