summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-11-16 18:02:44 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-11-16 18:02:44 (GMT)
commita83a6a3275f7dc748db3a237bbf4b05fcf76a85f (patch)
tree588566d665728b8b8453f4f00517f1420b8ede51 /Objects
parentecbca357c95ff1808fd3cca30253af3f34bc6ffa (diff)
downloadcpython-a83a6a3275f7dc748db3a237bbf4b05fcf76a85f.zip
cpython-a83a6a3275f7dc748db3a237bbf4b05fcf76a85f.tar.gz
cpython-a83a6a3275f7dc748db3a237bbf4b05fcf76a85f.tar.bz2
Issue #28701: _PyUnicode_EqualToASCIIId and _PyUnicode_EqualToASCIIString now
require ASCII right argument and assert this condition in debug build.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 293b5c4..02aaf6e 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -11081,6 +11081,12 @@ _PyUnicode_EqualToASCIIString(PyObject *unicode, const char *str)
{
size_t len;
assert(_PyUnicode_CHECK(unicode));
+ assert(str);
+#ifndef NDEBUG
+ for (const char *p = str; *p; p++) {
+ assert((unsigned char)*p < 128);
+ }
+#endif
if (PyUnicode_READY(unicode) == -1) {
/* Memory error or bad data */
PyErr_Clear();
@@ -11101,6 +11107,11 @@ _PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
assert(_PyUnicode_CHECK(left));
assert(right->string);
+#ifndef NDEBUG
+ for (const char *p = right->string; *p; p++) {
+ assert((unsigned char)*p < 128);
+ }
+#endif
if (PyUnicode_READY(left) == -1) {
/* memory error or bad data */