mirror of
https://github.com/python/cpython
synced 2026-09-29 10:15:30 +03: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
1a73bf365e
22 changed files with 125 additions and 80 deletions
|
|
@ -1023,7 +1023,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
|
|||
else if (PyUnicode_Check(res)) {
|
||||
const encodefuncentry *e = encodefuncs;
|
||||
while (e->name != NULL) {
|
||||
if (!PyUnicode_CompareWithASCIIString(res, e->name)) {
|
||||
if (_PyUnicode_EqualToASCIIString(res, e->name)) {
|
||||
self->encodefunc = e->encodefunc;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,11 +93,11 @@ char _PyIO_get_console_type(PyObject *path_or_fd) {
|
|||
}
|
||||
|
||||
char m = '\0';
|
||||
if (PyUnicode_CompareWithASCIIString(decoded_upper, "CONIN$") == 0) {
|
||||
if (_PyUnicode_EqualToASCIIString(decoded_upper, "CONIN$")) {
|
||||
m = 'r';
|
||||
} else if (PyUnicode_CompareWithASCIIString(decoded_upper, "CONOUT$") == 0) {
|
||||
} else if (_PyUnicode_EqualToASCIIString(decoded_upper, "CONOUT$")) {
|
||||
m = 'w';
|
||||
} else if (PyUnicode_CompareWithASCIIString(decoded_upper, "CON") == 0) {
|
||||
} else if (_PyUnicode_EqualToASCIIString(decoded_upper, "CON")) {
|
||||
m = 'x';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue