bpo-43687: use unicode_state empty string before unicode_init. without define WITH_DOC_STRINGS by JunyiXie · Pull Request #25129 · python/cpython (original) (raw)

without define WITH_DOC_STRINGS. use unicode_state empty string before _PyUnicode_Init.

PyType_Ready call PyUnicode_FromString, if doc string "", cause crash.

unicode_get_empty() must not be called before _PyUnicode_Init() or after _PyUnicode_Fini()

PyType_Ready

const char *old_doc = _PyType_DocWithoutSignature(type->tp_name,type->tp_doc);
PyObject *doc = PyUnicode_FromString(old_doc);

https://bugs.python.org/issue43687