mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
Issue #28701: Replace PyUnicode_CompareWithASCIIString with _PyUnicode_EqualToASCIIString.
The latter function is more readable, faster and doesn't raise exceptions.
This commit is contained in:
commit
3b73ea1278
22 changed files with 125 additions and 80 deletions
|
@ -934,12 +934,12 @@ forbidden_name(struct compiling *c, identifier name, const node *n,
|
|||
int full_checks)
|
||||
{
|
||||
assert(PyUnicode_Check(name));
|
||||
if (PyUnicode_CompareWithASCIIString(name, "__debug__") == 0) {
|
||||
if (_PyUnicode_EqualToASCIIString(name, "__debug__")) {
|
||||
ast_error(c, n, "assignment to keyword");
|
||||
return 1;
|
||||
}
|
||||
if (PyUnicode_CompareWithASCIIString(name, "async") == 0 ||
|
||||
PyUnicode_CompareWithASCIIString(name, "await") == 0)
|
||||
if (_PyUnicode_EqualToASCIIString(name, "async") ||
|
||||
_PyUnicode_EqualToASCIIString(name, "await"))
|
||||
{
|
||||
PyObject *message = PyUnicode_FromString(
|
||||
"'async' and 'await' will become reserved keywords"
|
||||
|
@ -963,7 +963,7 @@ forbidden_name(struct compiling *c, identifier name, const node *n,
|
|||
if (full_checks) {
|
||||
const char * const *p;
|
||||
for (p = FORBIDDEN; *p; p++) {
|
||||
if (PyUnicode_CompareWithASCIIString(name, *p) == 0) {
|
||||
if (_PyUnicode_EqualToASCIIString(name, *p)) {
|
||||
ast_error(c, n, "assignment to keyword");
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue