mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-36346: Make using the legacy Unicode C API optional (GH-21437)
Add compile time option USE_UNICODE_WCHAR_CACHE. Setting it to 0 makes the interpreter not using the wchar_t cache and the legacy Unicode C API.
This commit is contained in:
parent
9650fe0197
commit
4c8f09d7ce
17 changed files with 360 additions and 99 deletions
|
@ -270,7 +270,14 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
|
|||
if (!PyUnicode_FSDecoder(nameobj, &stringobj)) {
|
||||
return -1;
|
||||
}
|
||||
#if USE_UNICODE_WCHAR_CACHE
|
||||
_Py_COMP_DIAG_PUSH
|
||||
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
|
||||
widename = PyUnicode_AsUnicode(stringobj);
|
||||
_Py_COMP_DIAG_POP
|
||||
#else /* USE_UNICODE_WCHAR_CACHE */
|
||||
widename = PyUnicode_AsWideCharString(stringobj, NULL);
|
||||
#endif /* USE_UNICODE_WCHAR_CACHE */
|
||||
if (widename == NULL)
|
||||
return -1;
|
||||
#else
|
||||
|
@ -491,6 +498,11 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
|
|||
internal_close(self);
|
||||
|
||||
done:
|
||||
#ifdef MS_WINDOWS
|
||||
#if !USE_UNICODE_WCHAR_CACHE
|
||||
PyMem_Free(widename);
|
||||
#endif /* USE_UNICODE_WCHAR_CACHE */
|
||||
#endif
|
||||
Py_CLEAR(stringobj);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue