mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
bpo-46765: Replace Locally Cached Strings with Statically Initialized Objects (gh-31366)
https://bugs.python.org/issue46765
This commit is contained in:
parent
cff4d5c5d2
commit
1f455361ec
22 changed files with 192 additions and 526 deletions
|
@ -768,25 +768,6 @@ warn_explicit(PyThreadState *tstate, PyObject *category, PyObject *message,
|
|||
static int
|
||||
is_internal_frame(PyFrameObject *frame)
|
||||
{
|
||||
static PyObject *importlib_string = NULL;
|
||||
static PyObject *bootstrap_string = NULL;
|
||||
int contains;
|
||||
|
||||
if (importlib_string == NULL) {
|
||||
importlib_string = PyUnicode_FromString("importlib");
|
||||
if (importlib_string == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bootstrap_string = PyUnicode_FromString("_bootstrap");
|
||||
if (bootstrap_string == NULL) {
|
||||
Py_DECREF(importlib_string);
|
||||
return 0;
|
||||
}
|
||||
Py_INCREF(importlib_string);
|
||||
Py_INCREF(bootstrap_string);
|
||||
}
|
||||
|
||||
if (frame == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -802,12 +783,12 @@ is_internal_frame(PyFrameObject *frame)
|
|||
return 0;
|
||||
}
|
||||
|
||||
contains = PyUnicode_Contains(filename, importlib_string);
|
||||
int contains = PyUnicode_Contains(filename, &_Py_ID(importlib));
|
||||
if (contains < 0) {
|
||||
return 0;
|
||||
}
|
||||
else if (contains > 0) {
|
||||
contains = PyUnicode_Contains(filename, bootstrap_string);
|
||||
contains = PyUnicode_Contains(filename, &_Py_ID(_bootstrap));
|
||||
if (contains < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue