Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita83a6a3

Browse files
Issue#28701: _PyUnicode_EqualToASCIIId and _PyUnicode_EqualToASCIIString now
require ASCII right argument and assert this condition in debug build.
1 parentecbca35 commita83a6a3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

‎Include/unicodeobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,7 +2038,7 @@ PyAPI_FUNC(int) PyUnicode_Compare(
20382038

20392039
#ifndef Py_LIMITED_API
20402040
/* Test whether a unicode is equal to ASCII identifier. Return 1 if true,
2041-
0 otherwise.Return 0 if anyargumentcontains non-ASCIIcharacters.
2041+
0 otherwise.The rightargumentmust beASCIIidentifier.
20422042
Any error occurs inside will be cleared before return.*/
20432043

20442044
PyAPI_FUNC(int) _PyUnicode_EqualToASCIIId(
@@ -2060,7 +2060,7 @@ PyAPI_FUNC(int) PyUnicode_CompareWithASCIIString(
20602060

20612061
#ifndef Py_LIMITED_API
20622062
/* Test whether a unicode is equal to ASCII string. Return 1 if true,
2063-
0 otherwise.Return 0 if anyargumentcontains non-ASCII characters.
2063+
0 otherwise.The rightargumentmust beASCII-encoded string.
20642064
Any error occurs inside will be cleared before return.*/
20652065

20662066
PyAPI_FUNC(int) _PyUnicode_EqualToASCIIString(

‎Objects/unicodeobject.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11081,6 +11081,12 @@ _PyUnicode_EqualToASCIIString(PyObject *unicode, const char *str)
1108111081
{
1108211082
size_tlen;
1108311083
assert(_PyUnicode_CHECK(unicode));
11084+
assert(str);
11085+
#ifndefNDEBUG
11086+
for (constchar*p=str;*p;p++) {
11087+
assert((unsignedchar)*p<128);
11088+
}
11089+
#endif
1108411090
if (PyUnicode_READY(unicode)==-1) {
1108511091
/* Memory error or bad data */
1108611092
PyErr_Clear();
@@ -11101,6 +11107,11 @@ _PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
1110111107

1110211108
assert(_PyUnicode_CHECK(left));
1110311109
assert(right->string);
11110+
#ifndefNDEBUG
11111+
for (constchar*p=right->string;*p;p++) {
11112+
assert((unsignedchar)*p<128);
11113+
}
11114+
#endif
1110411115

1110511116
if (PyUnicode_READY(left)==-1) {
1110611117
/* memory error or bad data */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp