mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-36775: Add _Py_FORCE_UTF8_FS_ENCODING macro (GH-13056)
Add _Py_FORCE_UTF8_LOCALE and _Py_FORCE_UTF8_FS_ENCODING macros to avoid factorize "#if defined(__ANDROID__) || defined(__VXWORKS__)" and "#if defined(__APPLE__)". Cleanup also config_init_fs_encoding().
This commit is contained in:
parent
c4e78b116f
commit
e251095a3f
5 changed files with 49 additions and 58 deletions
|
@ -3506,7 +3506,7 @@ PyUnicode_EncodeFSDefault(PyObject *unicode)
|
|||
{
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
|
||||
const _PyCoreConfig *config = &interp->core_config;
|
||||
#if defined(__APPLE__)
|
||||
#ifdef _Py_FORCE_UTF8_FS_ENCODING
|
||||
return _PyUnicode_AsUTF8String(unicode, config->filesystem_errors);
|
||||
#else
|
||||
/* Bootstrap check: if the filesystem codec is implemented in Python, we
|
||||
|
@ -3730,7 +3730,7 @@ PyUnicode_DecodeFSDefaultAndSize(const char *s, Py_ssize_t size)
|
|||
{
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
|
||||
const _PyCoreConfig *config = &interp->core_config;
|
||||
#if defined(__APPLE__)
|
||||
#ifdef _Py_FORCE_UTF8_FS_ENCODING
|
||||
return PyUnicode_DecodeUTF8Stateful(s, size, config->filesystem_errors, NULL);
|
||||
#else
|
||||
/* Bootstrap check: if the filesystem codec is implemented in Python, we
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue