diff options
author | Victor Stinner <vstinner@python.org> | 2023-06-01 23:33:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-01 23:33:17 (GMT) |
commit | ef300937c2a1b3ebe19c2835f3b46585825c1e1f (patch) | |
tree | 34f151a390fb946ff985ed98e6c1bd096c4d090b /Python | |
parent | cbb9ba844f15f2b8127028e6dfd4681b2cb2376f (diff) | |
download | cpython-ef300937c2a1b3ebe19c2835f3b46585825c1e1f.zip cpython-ef300937c2a1b3ebe19c2835f3b46585825c1e1f.tar.gz cpython-ef300937c2a1b3ebe19c2835f3b46585825c1e1f.tar.bz2 |
gh-92536: Remove PyUnicode_READY() calls (#105210)
Since Python 3.12, PyUnicode_READY() does nothing and always
returns 0.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/_warnings.c | 3 | ||||
-rw-r--r-- | Python/bltinmodule.c | 2 | ||||
-rw-r--r-- | Python/formatter_unicode.c | 2 | ||||
-rw-r--r-- | Python/getargs.c | 5 | ||||
-rw-r--r-- | Python/import.c | 7 | ||||
-rw-r--r-- | Python/intrinsics.c | 5 | ||||
-rw-r--r-- | Python/pystrhex.c | 2 |
7 files changed, 1 insertions, 25 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index 54fa5c5..69fa04e 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -533,9 +533,6 @@ show_warning(PyThreadState *tstate, PyObject *filename, int lineno, Py_UCS4 ch; PyObject *truncated; - if (PyUnicode_READY(sourceline) < 1) - goto error; - kind = PyUnicode_KIND(sourceline); data = PyUnicode_DATA(sourceline); len = PyUnicode_GET_LENGTH(sourceline); diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index ddddc03..96a7ddd 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1914,8 +1914,6 @@ builtin_ord(PyObject *module, PyObject *c) } } else if (PyUnicode_Check(c)) { - if (PyUnicode_READY(c) == -1) - return NULL; size = PyUnicode_GET_LENGTH(c); if (size == 1) { ord = (long)PyUnicode_READ_CHAR(c, 0); diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index 38e5f69..6af589f 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -982,7 +982,7 @@ format_long_internal(PyObject *value, const InternalFormatSpec *format, /* Do the hard part, converting to a string in a given base */ tmp = _PyLong_Format(value, base); - if (tmp == NULL || PyUnicode_READY(tmp) == -1) + if (tmp == NULL) goto done; inumeric_chars = 0; diff --git a/Python/getargs.c b/Python/getargs.c index 5639aba..45befab 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -824,9 +824,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, if (!PyUnicode_Check(arg)) return converterr("a unicode character", arg, msgbuf, bufsize); - if (PyUnicode_READY(arg)) - RETURN_ERR_OCCURRED; - if (PyUnicode_GET_LENGTH(arg) != 1) return converterr("a unicode character", arg, msgbuf, bufsize); @@ -1144,8 +1141,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, case 'U': { /* PyUnicode object */ PyObject **p = va_arg(*p_va, PyObject **); if (PyUnicode_Check(arg)) { - if (PyUnicode_READY(arg) == -1) - RETURN_ERR_OCCURRED; *p = arg; } else diff --git a/Python/import.c b/Python/import.c index 9e1857d..7f04b1a 100644 --- a/Python/import.c +++ b/Python/import.c @@ -2610,10 +2610,6 @@ resolve_name(PyThreadState *tstate, PyObject *name, PyObject *globals, int level if (!haspath) { Py_ssize_t dot; - if (PyUnicode_READY(package) < 0) { - goto error; - } - dot = PyUnicode_FindChar(package, '.', 0, PyUnicode_GET_LENGTH(package), -1); if (dot == -2) { @@ -2762,9 +2758,6 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals, "module name must be a string"); goto error; } - if (PyUnicode_READY(name) < 0) { - goto error; - } if (level < 0) { _PyErr_SetString(tstate, PyExc_ValueError, "level must be >= 0"); goto error; diff --git a/Python/intrinsics.c b/Python/intrinsics.c index c6f5ac5..e34a856 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -96,11 +96,6 @@ import_all_from(PyThreadState *tstate, PyObject *locals, PyObject *v) break; } if (skip_leading_underscores) { - if (PyUnicode_READY(name) == -1) { - Py_DECREF(name); - err = -1; - break; - } if (PyUnicode_READ_CHAR(name, 0) == '_') { Py_DECREF(name); continue; diff --git a/Python/pystrhex.c b/Python/pystrhex.c index e4f06d7..f798256 100644 --- a/Python/pystrhex.c +++ b/Python/pystrhex.c @@ -21,8 +21,6 @@ static PyObject *_Py_strhex_impl(const char* argbuf, const Py_ssize_t arglen, return NULL; } if (PyUnicode_Check(sep)) { - if (PyUnicode_READY(sep)) - return NULL; if (PyUnicode_KIND(sep) != PyUnicode_1BYTE_KIND) { PyErr_SetString(PyExc_ValueError, "sep must be ASCII."); return NULL; |