out, err = self.run_embedded_interpreter("test_repeated_init_exec", code)
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):
maxDiff = 4096
if (_Py_IsMainInterpreter(interp)) {
// _PyUnicode_ClearInterned() must be called before _PyUnicode_Fini()
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);