summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-09-08 07:43:54 (GMT)
committerGitHub <noreply@github.com>2017-09-08 07:43:54 (GMT)
commitddb536ba7b7c6022424e39d666c3cc81772645c0 (patch)
tree48ba8d3f97ac4b4b060c910db81cf48bb16ba896 /Modules
parent9f2b3d4c2899f9caea2e47063061a76e460ac618 (diff)
downloadcpython-ddb536ba7b7c6022424e39d666c3cc81772645c0.zip
cpython-ddb536ba7b7c6022424e39d666c3cc81772645c0.tar.gz
cpython-ddb536ba7b7c6022424e39d666c3cc81772645c0.tar.bz2
[3.6] bpo-31393: Fix the use of PyUnicode_READY(). (GH-3451). (#3453)
(cherry picked from commit e3b2b4b8d9e751b49e3550cb83ba39b54fdc377c)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index d006bd4..a351faa 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1464,7 +1464,10 @@ idna_converter(PyObject *obj, struct maybe_idna *data)
len = PyByteArray_Size(obj);
}
else if (PyUnicode_Check(obj)) {
- if (PyUnicode_READY(obj) == 0 && PyUnicode_IS_COMPACT_ASCII(obj)) {
+ if (PyUnicode_READY(obj) == -1) {
+ return 0;
+ }
+ if (PyUnicode_IS_COMPACT_ASCII(obj)) {
data->buf = PyUnicode_DATA(obj);
len = PyUnicode_GET_LENGTH(obj);
}