Skip to content

Commit 06fc65b

Browse files
committed
Remove USE_UNICODE_WCHAR_CACHE
1 parent f298ba1 commit 06fc65b

File tree

18 files changed

+11
-525
lines changed

18 files changed

+11
-525
lines changed

Include/cpython/unicodeobject.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111

1212
/* --- Internal Unicode Operations ---------------------------------------- */
1313

14-
#ifndef USE_UNICODE_WCHAR_CACHE
15-
# define USE_UNICODE_WCHAR_CACHE 1
16-
#endif /* USE_UNICODE_WCHAR_CACHE */
17-
1814
/* Since splitting on whitespace is an important use case, and
1915
whitespace in most situations is solely ASCII whitespace, we
2016
optimize for the common case by using a quick look-up table

Lib/test/clinic.test

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,17 +1819,11 @@ test_Py_UNICODE_converter(PyObject *module, PyObject *const *args, Py_ssize_t na
18191819

18201820
exit:
18211821
/* Cleanup for a */
1822-
#if !USE_UNICODE_WCHAR_CACHE
18231822
PyMem_Free((void *)a);
1824-
#endif /* USE_UNICODE_WCHAR_CACHE */
18251823
/* Cleanup for b */
1826-
#if !USE_UNICODE_WCHAR_CACHE
18271824
PyMem_Free((void *)b);
1828-
#endif /* USE_UNICODE_WCHAR_CACHE */
18291825
/* Cleanup for c */
1830-
#if !USE_UNICODE_WCHAR_CACHE
18311826
PyMem_Free((void *)c);
1832-
#endif /* USE_UNICODE_WCHAR_CACHE */
18331827

18341828
return return_value;
18351829
}
@@ -1839,7 +1833,7 @@ test_Py_UNICODE_converter_impl(PyObject *module, const Py_UNICODE *a,
18391833
const Py_UNICODE *b, const Py_UNICODE *c,
18401834
const Py_UNICODE *d, Py_ssize_t d_length,
18411835
const Py_UNICODE *e, Py_ssize_t e_length)
1842-
/*[clinic end generated code: output=45e92604de227552 input=064a3b68ad7f04b0]*/
1836+
/*[clinic end generated code: output=4d426808cdbb3ea3 input=064a3b68ad7f04b0]*/
18431837

18441838

18451839
/*[clinic input]

Lib/test/test_getargs2.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,14 +1255,6 @@ class Test_testcapi(unittest.TestCase):
12551255
for name in dir(_testcapi)
12561256
if name.startswith('test_') and name.endswith('_code'))
12571257

1258-
@warnings_helper.ignore_warnings(category=DeprecationWarning)
1259-
def test_u_code(self):
1260-
_testcapi.test_u_code()
1261-
1262-
@warnings_helper.ignore_warnings(category=DeprecationWarning)
1263-
def test_Z_code(self):
1264-
_testcapi.test_Z_code()
1265-
12661258

12671259
if __name__ == "__main__":
12681260
unittest.main()

Modules/_io/fileio.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,7 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
268268
if (!PyUnicode_FSDecoder(nameobj, &stringobj)) {
269269
return -1;
270270
}
271-
#if USE_UNICODE_WCHAR_CACHE
272-
_Py_COMP_DIAG_PUSH
273-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
274-
widename = PyUnicode_AsUnicode(stringobj);
275-
_Py_COMP_DIAG_POP
276-
#else /* USE_UNICODE_WCHAR_CACHE */
277271
widename = PyUnicode_AsWideCharString(stringobj, NULL);
278-
#endif /* USE_UNICODE_WCHAR_CACHE */
279272
if (widename == NULL)
280273
return -1;
281274
#else
@@ -497,9 +490,7 @@ _Py_COMP_DIAG_POP
497490

498491
done:
499492
#ifdef MS_WINDOWS
500-
#if !USE_UNICODE_WCHAR_CACHE
501493
PyMem_Free(widename);
502-
#endif /* USE_UNICODE_WCHAR_CACHE */
503494
#endif
504495
Py_CLEAR(stringobj);
505496
return ret;

Modules/_testcapimodule.c

Lines changed: 0 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,116 +1991,6 @@ parse_tuple_and_keywords(PyObject *self, PyObject *args)
19911991
return return_value;
19921992
}
19931993

1994-
static volatile int x;
1995-
1996-
#if USE_UNICODE_WCHAR_CACHE
1997-
/* Ignore use of deprecated APIs */
1998-
_Py_COMP_DIAG_PUSH
1999-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
2000-
2001-
/* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case
2002-
of an error.
2003-
*/
2004-
static PyObject *
2005-
test_u_code(PyObject *self, PyObject *Py_UNUSED(ignored))
2006-
{
2007-
PyObject *tuple, *obj;
2008-
Py_UNICODE *value;
2009-
Py_ssize_t len;
2010-
2011-
/* issue4122: Undefined reference to _Py_ascii_whitespace on Windows */
2012-
/* Just use the macro and check that it compiles */
2013-
x = Py_UNICODE_ISSPACE(25);
2014-
2015-
tuple = PyTuple_New(1);
2016-
if (tuple == NULL)
2017-
return NULL;
2018-
2019-
obj = PyUnicode_Decode("test", strlen("test"),
2020-
"ascii", NULL);
2021-
if (obj == NULL)
2022-
return NULL;
2023-
2024-
PyTuple_SET_ITEM(tuple, 0, obj);
2025-
2026-
value = 0;
2027-
if (!PyArg_ParseTuple(tuple, "u:test_u_code", &value)) {
2028-
return NULL;
2029-
}
2030-
if (value != PyUnicode_AS_UNICODE(obj))
2031-
return raiseTestError("test_u_code",
2032-
"u code returned wrong value for u'test'");
2033-
value = 0;
2034-
if (!PyArg_ParseTuple(tuple, "u#:test_u_code", &value, &len)) {
2035-
return NULL;
2036-
}
2037-
if (value != PyUnicode_AS_UNICODE(obj) ||
2038-
len != PyUnicode_GET_SIZE(obj))
2039-
return raiseTestError("test_u_code",
2040-
"u# code returned wrong values for u'test'");
2041-
2042-
Py_DECREF(tuple);
2043-
Py_RETURN_NONE;
2044-
}
2045-
2046-
/* Test Z and Z# codes for PyArg_ParseTuple */
2047-
static PyObject *
2048-
test_Z_code(PyObject *self, PyObject *Py_UNUSED(ignored))
2049-
{
2050-
PyObject *tuple, *obj;
2051-
const Py_UNICODE *value1, *value2;
2052-
Py_ssize_t len1, len2;
2053-
2054-
tuple = PyTuple_New(2);
2055-
if (tuple == NULL)
2056-
return NULL;
2057-
2058-
obj = PyUnicode_FromString("test");
2059-
PyTuple_SET_ITEM(tuple, 0, obj);
2060-
Py_INCREF(Py_None);
2061-
PyTuple_SET_ITEM(tuple, 1, Py_None);
2062-
2063-
/* swap values on purpose */
2064-
value1 = NULL;
2065-
value2 = PyUnicode_AS_UNICODE(obj);
2066-
2067-
/* Test Z for both values */
2068-
if (!PyArg_ParseTuple(tuple, "ZZ:test_Z_code", &value1, &value2)) {
2069-
return NULL;
2070-
}
2071-
if (value1 != PyUnicode_AS_UNICODE(obj))
2072-
return raiseTestError("test_Z_code",
2073-
"Z code returned wrong value for 'test'");
2074-
if (value2 != NULL)
2075-
return raiseTestError("test_Z_code",
2076-
"Z code returned wrong value for None");
2077-
2078-
value1 = NULL;
2079-
value2 = PyUnicode_AS_UNICODE(obj);
2080-
len1 = -1;
2081-
len2 = -1;
2082-
2083-
/* Test Z# for both values */
2084-
if (!PyArg_ParseTuple(tuple, "Z#Z#:test_Z_code", &value1, &len1,
2085-
&value2, &len2))
2086-
{
2087-
return NULL;
2088-
}
2089-
if (value1 != PyUnicode_AS_UNICODE(obj) ||
2090-
len1 != PyUnicode_GET_SIZE(obj))
2091-
return raiseTestError("test_Z_code",
2092-
"Z# code returned wrong values for 'test'");
2093-
if (value2 != NULL ||
2094-
len2 != 0)
2095-
return raiseTestError("test_Z_code",
2096-
"Z# code returned wrong values for None'");
2097-
2098-
Py_DECREF(tuple);
2099-
Py_RETURN_NONE;
2100-
}
2101-
_Py_COMP_DIAG_POP
2102-
#endif /* USE_UNICODE_WCHAR_CACHE */
2103-
21041994
static PyObject *
21051995
test_widechar(PyObject *self, PyObject *Py_UNUSED(ignored))
21061996
{
@@ -2151,35 +2041,7 @@ test_widechar(PyObject *self, PyObject *Py_UNUSED(ignored))
21512041
else
21522042
return raiseTestError("test_widechar",
21532043
"PyUnicode_FromWideChar(L\"\\U00110000\", 1) didn't fail");
2154-
2155-
#if USE_UNICODE_WCHAR_CACHE
2156-
/* Ignore use of deprecated APIs */
2157-
_Py_COMP_DIAG_PUSH
2158-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
2159-
wide = PyUnicode_FromUnicode(invalid, 1);
2160-
if (wide == NULL)
2161-
PyErr_Clear();
2162-
else
2163-
return raiseTestError("test_widechar",
2164-
"PyUnicode_FromUnicode(L\"\\U00110000\", 1) didn't fail");
2165-
2166-
wide = PyUnicode_FromUnicode(NULL, 1);
2167-
if (wide == NULL)
2168-
return NULL;
2169-
PyUnicode_AS_UNICODE(wide)[0] = invalid[0];
2170-
if (_PyUnicode_Ready(wide) < 0) {
2171-
Py_DECREF(wide);
2172-
PyErr_Clear();
2173-
}
2174-
else {
2175-
Py_DECREF(wide);
2176-
return raiseTestError("test_widechar",
2177-
"PyUnicode_Ready() didn't fail");
2178-
}
2179-
_Py_COMP_DIAG_POP
2180-
#endif /* USE_UNICODE_WCHAR_CACHE */
21812044
#endif
2182-
21832045
Py_RETURN_NONE;
21842046
}
21852047

@@ -2357,36 +2219,6 @@ unicode_copycharacters(PyObject *self, PyObject *args)
23572219
return Py_BuildValue("(Nn)", to_copy, copied);
23582220
}
23592221

2360-
#if USE_UNICODE_WCHAR_CACHE
2361-
/* Ignore use of deprecated APIs */
2362-
_Py_COMP_DIAG_PUSH
2363-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
2364-
2365-
static PyObject *
2366-
unicode_legacy_string(PyObject *self, PyObject *args)
2367-
{
2368-
Py_UNICODE *data;
2369-
Py_ssize_t len;
2370-
PyObject *u;
2371-
2372-
if (!PyArg_ParseTuple(args, "u#", &data, &len))
2373-
return NULL;
2374-
2375-
u = PyUnicode_FromUnicode(NULL, len);
2376-
if (u == NULL)
2377-
return NULL;
2378-
2379-
memcpy(PyUnicode_AS_UNICODE(u), data, len * sizeof(Py_UNICODE));
2380-
2381-
if (len > 0) { /* The empty string is always ready. */
2382-
assert(!PyUnicode_IS_READY(u));
2383-
}
2384-
2385-
return u;
2386-
}
2387-
_Py_COMP_DIAG_POP
2388-
#endif /* USE_UNICODE_WCHAR_CACHE */
2389-
23902222
static PyObject *
23912223
getargs_w_star(PyObject *self, PyObject *args)
23922224
{
@@ -6092,10 +5924,6 @@ static PyMethodDef TestMethods[] = {
60925924
{"codec_incrementaldecoder",
60935925
(PyCFunction)codec_incrementaldecoder, METH_VARARGS},
60945926
{"test_s_code", test_s_code, METH_NOARGS},
6095-
#if USE_UNICODE_WCHAR_CACHE
6096-
{"test_u_code", test_u_code, METH_NOARGS},
6097-
{"test_Z_code", test_Z_code, METH_NOARGS},
6098-
#endif /* USE_UNICODE_WCHAR_CACHE */
60995927
{"test_widechar", test_widechar, METH_NOARGS},
61005928
{"unicode_aswidechar", unicode_aswidechar, METH_VARARGS},
61015929
{"unicode_aswidecharstring",unicode_aswidecharstring, METH_VARARGS},
@@ -6104,9 +5932,6 @@ static PyMethodDef TestMethods[] = {
61045932
{"unicode_asutf8andsize", unicode_asutf8andsize, METH_VARARGS},
61055933
{"unicode_findchar", unicode_findchar, METH_VARARGS},
61065934
{"unicode_copycharacters", unicode_copycharacters, METH_VARARGS},
6107-
#if USE_UNICODE_WCHAR_CACHE
6108-
{"unicode_legacy_string", unicode_legacy_string, METH_VARARGS},
6109-
#endif /* USE_UNICODE_WCHAR_CACHE */
61105935
{"_test_thread_state", test_thread_state, METH_VARARGS},
61115936
{"_pending_threadfunc", pending_threadfunc, METH_VARARGS},
61125937
#ifdef HAVE_GETTIMEOFDAY

Modules/clinic/_winapi.c.h

Lines changed: 1 addition & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)