summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2022-05-12 05:48:38 (GMT)
committerGitHub <noreply@github.com>2022-05-12 05:48:38 (GMT)
commitf9c9354a7a173eaca2aa19e667b5cf12167b7fed (patch)
treeeb0fdd3219f53c973f1a7dbbcb9f8b0e0babdf36 /Modules/posixmodule.c
parent68fec31364e96d122aae0571c14683b4ddb0ebd0 (diff)
downloadcpython-f9c9354a7a173eaca2aa19e667b5cf12167b7fed.zip
cpython-f9c9354a7a173eaca2aa19e667b5cf12167b7fed.tar.gz
cpython-f9c9354a7a173eaca2aa19e667b5cf12167b7fed.tar.bz2
gh-92536: PEP 623: Remove wstr and legacy APIs from Unicode (GH-92537)
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c48
1 files changed, 3 insertions, 45 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 4015889..0a72aca 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1098,11 +1098,9 @@ typedef struct {
static void
path_cleanup(path_t *path)
{
-#if !USE_UNICODE_WCHAR_CACHE
wchar_t *wide = (wchar_t *)path->wide;
path->wide = NULL;
PyMem_Free(wide);
-#endif /* USE_UNICODE_WCHAR_CACHE */
Py_CLEAR(path->object);
Py_CLEAR(path->cleanup);
}
@@ -1190,14 +1188,7 @@ path_converter(PyObject *o, void *p)
if (is_unicode) {
#ifdef MS_WINDOWS
-#if USE_UNICODE_WCHAR_CACHE
-_Py_COMP_DIAG_PUSH
-_Py_COMP_DIAG_IGNORE_DEPR_DECLS
- wide = PyUnicode_AsUnicodeAndSize(o, &length);
-_Py_COMP_DIAG_POP
-#else /* USE_UNICODE_WCHAR_CACHE */
wide = PyUnicode_AsWideCharString(o, &length);
-#endif /* USE_UNICODE_WCHAR_CACHE */
if (!wide) {
goto error_exit;
}
@@ -1213,9 +1204,7 @@ _Py_COMP_DIAG_POP
path->wide = wide;
path->narrow = FALSE;
path->fd = -1;
-#if !USE_UNICODE_WCHAR_CACHE
wide = NULL;
-#endif /* USE_UNICODE_WCHAR_CACHE */
goto success_exit;
#else
if (!PyUnicode_FSConverter(o, &bytes)) {
@@ -1291,15 +1280,8 @@ _Py_COMP_DIAG_POP
goto error_exit;
}
-#if USE_UNICODE_WCHAR_CACHE
-_Py_COMP_DIAG_PUSH
-_Py_COMP_DIAG_IGNORE_DEPR_DECLS
- wide = PyUnicode_AsUnicodeAndSize(wo, &length);
-_Py_COMP_DIAG_POP
-#else /* USE_UNICODE_WCHAR_CACHE */
wide = PyUnicode_AsWideCharString(wo, &length);
Py_DECREF(wo);
-#endif /* USE_UNICODE_WCHAR_CACHE */
if (!wide) {
goto error_exit;
}
@@ -1314,11 +1296,7 @@ _Py_COMP_DIAG_POP
path->wide = wide;
path->narrow = TRUE;
Py_DECREF(bytes);
-#if USE_UNICODE_WCHAR_CACHE
- path->cleanup = wo;
-#else /* USE_UNICODE_WCHAR_CACHE */
wide = NULL;
-#endif /* USE_UNICODE_WCHAR_CACHE */
#else
path->wide = NULL;
path->narrow = narrow;
@@ -1342,11 +1320,7 @@ _Py_COMP_DIAG_POP
Py_XDECREF(o);
Py_XDECREF(bytes);
#ifdef MS_WINDOWS
-#if USE_UNICODE_WCHAR_CACHE
- Py_XDECREF(wo);
-#else /* USE_UNICODE_WCHAR_CACHE */
PyMem_Free(wide);
-#endif /* USE_UNICODE_WCHAR_CACHE */
#endif
return 0;
}
@@ -13575,15 +13549,8 @@ DirEntry_fetch_stat(PyObject *module, DirEntry *self, int follow_symlinks)
#ifdef MS_WINDOWS
if (!PyUnicode_FSDecoder(self->path, &ub))
return NULL;
-#if USE_UNICODE_WCHAR_CACHE
-_Py_COMP_DIAG_PUSH
-_Py_COMP_DIAG_IGNORE_DEPR_DECLS
- const wchar_t *path = PyUnicode_AsUnicode(ub);
-_Py_COMP_DIAG_POP
-#else /* USE_UNICODE_WCHAR_CACHE */
wchar_t *path = PyUnicode_AsWideCharString(ub, NULL);
Py_DECREF(ub);
-#endif /* USE_UNICODE_WCHAR_CACHE */
#else /* POSIX */
if (!PyUnicode_FSConverter(self->path, &ub))
return NULL;
@@ -13616,11 +13583,11 @@ _Py_COMP_DIAG_POP
}
Py_END_ALLOW_THREADS
}
-#if defined(MS_WINDOWS) && !USE_UNICODE_WCHAR_CACHE
+#if defined(MS_WINDOWS)
PyMem_Free(path);
-#else /* USE_UNICODE_WCHAR_CACHE */
+#else
Py_DECREF(ub);
-#endif /* USE_UNICODE_WCHAR_CACHE */
+#endif
if (result != 0)
return path_object_error(self->path);
@@ -13814,19 +13781,10 @@ os_DirEntry_inode_impl(DirEntry *self)
if (!PyUnicode_FSDecoder(self->path, &unicode))
return NULL;
-#if USE_UNICODE_WCHAR_CACHE
-_Py_COMP_DIAG_PUSH
-_Py_COMP_DIAG_IGNORE_DEPR_DECLS
- const wchar_t *path = PyUnicode_AsUnicode(unicode);
- result = LSTAT(path, &stat);
- Py_DECREF(unicode);
-_Py_COMP_DIAG_POP
-#else /* USE_UNICODE_WCHAR_CACHE */
wchar_t *path = PyUnicode_AsWideCharString(unicode, NULL);
Py_DECREF(unicode);
result = LSTAT(path, &stat);
PyMem_Free(path);
-#endif /* USE_UNICODE_WCHAR_CACHE */
if (result != 0)
return path_object_error(self->path);