mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +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:
parent
5ebff7b300
commit
f4934ea77d
21 changed files with 120 additions and 75 deletions
|
@ -946,10 +946,9 @@ static const struct _frozen * find_frozen(PyObject *);
|
|||
static int
|
||||
is_builtin(PyObject *name)
|
||||
{
|
||||
int i, cmp;
|
||||
int i;
|
||||
for (i = 0; PyImport_Inittab[i].name != NULL; i++) {
|
||||
cmp = PyUnicode_CompareWithASCIIString(name, PyImport_Inittab[i].name);
|
||||
if (cmp == 0) {
|
||||
if (_PyUnicode_EqualToASCIIString(name, PyImport_Inittab[i].name)) {
|
||||
if (PyImport_Inittab[i].initfunc == NULL)
|
||||
return -1;
|
||||
else
|
||||
|
@ -1069,7 +1068,7 @@ _imp_create_builtin(PyObject *module, PyObject *spec)
|
|||
|
||||
for (p = PyImport_Inittab; p->name != NULL; p++) {
|
||||
PyModuleDef *def;
|
||||
if (PyUnicode_CompareWithASCIIString(name, p->name) == 0) {
|
||||
if (_PyUnicode_EqualToASCIIString(name, p->name)) {
|
||||
if (p->initfunc == NULL) {
|
||||
/* Cannot re-init internal module ("sys" or "builtins") */
|
||||
mod = PyImport_AddModule(namestr);
|
||||
|
@ -1115,7 +1114,7 @@ find_frozen(PyObject *name)
|
|||
for (p = PyImport_FrozenModules; ; p++) {
|
||||
if (p->name == NULL)
|
||||
return NULL;
|
||||
if (PyUnicode_CompareWithASCIIString(name, p->name) == 0)
|
||||
if (_PyUnicode_EqualToASCIIString(name, p->name))
|
||||
break;
|
||||
}
|
||||
return p;
|
||||
|
@ -1316,12 +1315,8 @@ remove_importlib_frames(void)
|
|||
int now_in_importlib;
|
||||
|
||||
assert(PyTraceBack_Check(tb));
|
||||
now_in_importlib = (PyUnicode_CompareWithASCIIString(
|
||||
code->co_filename,
|
||||
importlib_filename) == 0) ||
|
||||
(PyUnicode_CompareWithASCIIString(
|
||||
code->co_filename,
|
||||
external_filename) == 0);
|
||||
now_in_importlib = _PyUnicode_EqualToASCIIString(code->co_filename, importlib_filename) ||
|
||||
_PyUnicode_EqualToASCIIString(code->co_filename, external_filename);
|
||||
if (now_in_importlib && !in_importlib) {
|
||||
/* This is the link to this chunk of importlib tracebacks */
|
||||
outer_link = prev_link;
|
||||
|
@ -1330,8 +1325,7 @@ remove_importlib_frames(void)
|
|||
|
||||
if (in_importlib &&
|
||||
(always_trim ||
|
||||
PyUnicode_CompareWithASCIIString(code->co_name,
|
||||
remove_frames) == 0)) {
|
||||
_PyUnicode_EqualToASCIIString(code->co_name, remove_frames))) {
|
||||
PyObject *tmp = *outer_link;
|
||||
*outer_link = next;
|
||||
Py_XINCREF(next);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue