summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-06-01 23:33:17 (GMT)
committerGitHub <noreply@github.com>2023-06-01 23:33:17 (GMT)
commitef300937c2a1b3ebe19c2835f3b46585825c1e1f (patch)
tree34f151a390fb946ff985ed98e6c1bd096c4d090b /Modules/_io
parentcbb9ba844f15f2b8127028e6dfd4681b2cb2376f (diff)
downloadcpython-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 'Modules/_io')
-rw-r--r--Modules/_io/stringio.c6
-rw-r--r--Modules/_io/textio.c13
2 files changed, 1 insertions, 18 deletions
diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c
index 3eb2570..d402845 100644
--- a/Modules/_io/stringio.c
+++ b/Modules/_io/stringio.c
@@ -200,10 +200,6 @@ write_str(stringio *self, PyObject *obj)
return -1;
assert(PyUnicode_Check(decoded));
- if (PyUnicode_READY(decoded)) {
- Py_DECREF(decoded);
- return -1;
- }
len = PyUnicode_GET_LENGTH(decoded);
assert(len >= 0);
@@ -542,8 +538,6 @@ _io_StringIO_write(stringio *self, PyObject *obj)
Py_TYPE(obj)->tp_name);
return NULL;
}
- if (PyUnicode_READY(obj))
- return NULL;
CHECK_CLOSED(self);
size = PyUnicode_GET_LENGTH(obj);
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 46411c7..0ea7458 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -288,10 +288,6 @@ check_decoded(PyObject *decoded)
Py_DECREF(decoded);
return -1;
}
- if (PyUnicode_READY(decoded) < 0) {
- Py_DECREF(decoded);
- return -1;
- }
return 0;
}
@@ -1611,9 +1607,6 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text)
int haslf = 0;
int needflush = 0, text_needflush = 0;
- if (PyUnicode_READY(text) == -1)
- return NULL;
-
CHECK_ATTACHED(self);
CHECK_CLOSED(self);
@@ -1972,8 +1965,6 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
result = textiowrapper_get_decoded_chars(self, n);
if (result == NULL)
goto fail;
- if (PyUnicode_READY(result) == -1)
- goto fail;
remaining -= PyUnicode_GET_LENGTH(result);
/* Keep reading chunks until we have n characters to return */
@@ -2185,8 +2176,6 @@ _textiowrapper_readline(textio *self, Py_ssize_t limit)
Py_CLEAR(remaining);
if (line == NULL)
goto error;
- if (PyUnicode_READY(line) == -1)
- goto error;
}
ptr = PyUnicode_DATA(line);
@@ -3106,7 +3095,7 @@ textiowrapper_iternext(textio *self)
}
}
- if (line == NULL || PyUnicode_READY(line) == -1)
+ if (line == NULL)
return NULL;
if (PyUnicode_GET_LENGTH(line) == 0) {