mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #28701: _PyUnicode_EqualToASCIIId and _PyUnicode_EqualToASCIIString now
require ASCII right argument and assert this condition in debug build.
This commit is contained in:
commit
27b74244fb
2 changed files with 13 additions and 2 deletions
|
@ -11062,6 +11062,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();
|
||||
|
@ -11082,6 +11088,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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue