bpo-39487: Merge duplicated _Py_IDENTIFIER identifiers in C code (GH-18254)
Moving repetitive `_Py_IDENTIFIER` instances to a global location helps identify them more easily in regards to sub-interpreter support.
This commit is contained in:
parent
c232c9110c
commit
46874c26ee
|
@ -25,6 +25,8 @@ Py_ssize_t _Py_null_strings, _Py_one_strings;
|
||||||
static PyBytesObject *characters[UCHAR_MAX + 1];
|
static PyBytesObject *characters[UCHAR_MAX + 1];
|
||||||
static PyBytesObject *nullstring;
|
static PyBytesObject *nullstring;
|
||||||
|
|
||||||
|
_Py_IDENTIFIER(__bytes__);
|
||||||
|
|
||||||
/* PyBytesObject_SIZE gives the basic size of a string; any memory allocation
|
/* PyBytesObject_SIZE gives the basic size of a string; any memory allocation
|
||||||
for a string of length n should request PyBytesObject_SIZE + n bytes.
|
for a string of length n should request PyBytesObject_SIZE + n bytes.
|
||||||
|
|
||||||
|
@ -543,7 +545,6 @@ static PyObject *
|
||||||
format_obj(PyObject *v, const char **pbuf, Py_ssize_t *plen)
|
format_obj(PyObject *v, const char **pbuf, Py_ssize_t *plen)
|
||||||
{
|
{
|
||||||
PyObject *func, *result;
|
PyObject *func, *result;
|
||||||
_Py_IDENTIFIER(__bytes__);
|
|
||||||
/* is it a bytes object? */
|
/* is it a bytes object? */
|
||||||
if (PyBytes_Check(v)) {
|
if (PyBytes_Check(v)) {
|
||||||
*pbuf = PyBytes_AS_STRING(v);
|
*pbuf = PyBytes_AS_STRING(v);
|
||||||
|
@ -2485,7 +2486,6 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
Py_ssize_t size;
|
Py_ssize_t size;
|
||||||
static char *kwlist[] = {"source", "encoding", "errors", 0};
|
static char *kwlist[] = {"source", "encoding", "errors", 0};
|
||||||
_Py_IDENTIFIER(__bytes__);
|
|
||||||
|
|
||||||
if (type != &PyBytes_Type)
|
if (type != &PyBytes_Type)
|
||||||
return bytes_subtype_new(type, args, kwds);
|
return bytes_subtype_new(type, args, kwds);
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include "pycore_tupleobject.h"
|
#include "pycore_tupleobject.h"
|
||||||
#include "structmember.h" /* Why is this not included in Python.h? */
|
#include "structmember.h" /* Why is this not included in Python.h? */
|
||||||
|
|
||||||
|
_Py_IDENTIFIER(getattr);
|
||||||
|
|
||||||
/*[clinic input]
|
/*[clinic input]
|
||||||
class mappingproxy "mappingproxyobject *" "&PyDictProxy_Type"
|
class mappingproxy "mappingproxyobject *" "&PyDictProxy_Type"
|
||||||
class property "propertyobject *" "&PyProperty_Type"
|
class property "propertyobject *" "&PyProperty_Type"
|
||||||
|
@ -571,7 +573,6 @@ descr_get_qualname(PyDescrObject *descr, void *Py_UNUSED(ignored))
|
||||||
static PyObject *
|
static PyObject *
|
||||||
descr_reduce(PyDescrObject *descr, PyObject *Py_UNUSED(ignored))
|
descr_reduce(PyDescrObject *descr, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(getattr);
|
|
||||||
return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_getattr),
|
return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_getattr),
|
||||||
PyDescr_TYPE(descr), PyDescr_NAME(descr));
|
PyDescr_TYPE(descr), PyDescr_NAME(descr));
|
||||||
}
|
}
|
||||||
|
@ -1240,7 +1241,6 @@ wrapper_repr(wrapperobject *wp)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
wrapper_reduce(wrapperobject *wp, PyObject *Py_UNUSED(ignored))
|
wrapper_reduce(wrapperobject *wp, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(getattr);
|
|
||||||
return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_getattr),
|
return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_getattr),
|
||||||
wp->self, PyDescr_NAME(wp->descr));
|
wp->self, PyDescr_NAME(wp->descr));
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
_Py_IDENTIFIER(open);
|
||||||
|
|
||||||
/* External C interface */
|
/* External C interface */
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
|
@ -32,7 +34,6 @@ PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, const c
|
||||||
const char *errors, const char *newline, int closefd)
|
const char *errors, const char *newline, int closefd)
|
||||||
{
|
{
|
||||||
PyObject *io, *stream;
|
PyObject *io, *stream;
|
||||||
_Py_IDENTIFIER(open);
|
|
||||||
|
|
||||||
/* import _io in case we are being used to open io.py */
|
/* import _io in case we are being used to open io.py */
|
||||||
io = PyImport_ImportModule("_io");
|
io = PyImport_ImportModule("_io");
|
||||||
|
@ -547,7 +548,6 @@ PyObject *
|
||||||
PyFile_OpenCodeObject(PyObject *path)
|
PyFile_OpenCodeObject(PyObject *path)
|
||||||
{
|
{
|
||||||
PyObject *iomod, *f = NULL;
|
PyObject *iomod, *f = NULL;
|
||||||
_Py_IDENTIFIER(open);
|
|
||||||
|
|
||||||
if (!PyUnicode_Check(path)) {
|
if (!PyUnicode_Check(path)) {
|
||||||
PyErr_Format(PyExc_TypeError, "'path' must be 'str', not '%.200s'",
|
PyErr_Format(PyExc_TypeError, "'path' must be 'str', not '%.200s'",
|
||||||
|
|
|
@ -11,6 +11,8 @@ typedef struct {
|
||||||
PyObject *it_seq; /* Set to NULL when iterator is exhausted */
|
PyObject *it_seq; /* Set to NULL when iterator is exhausted */
|
||||||
} seqiterobject;
|
} seqiterobject;
|
||||||
|
|
||||||
|
_Py_IDENTIFIER(iter);
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PySeqIter_New(PyObject *seq)
|
PySeqIter_New(PyObject *seq)
|
||||||
{
|
{
|
||||||
|
@ -104,7 +106,6 @@ PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(
|
||||||
static PyObject *
|
static PyObject *
|
||||||
iter_reduce(seqiterobject *it, PyObject *Py_UNUSED(ignored))
|
iter_reduce(seqiterobject *it, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(iter);
|
|
||||||
if (it->it_seq != NULL)
|
if (it->it_seq != NULL)
|
||||||
return Py_BuildValue("N(O)n", _PyEval_GetBuiltinId(&PyId_iter),
|
return Py_BuildValue("N(O)n", _PyEval_GetBuiltinId(&PyId_iter),
|
||||||
it->it_seq, it->it_index);
|
it->it_seq, it->it_index);
|
||||||
|
@ -244,7 +245,6 @@ calliter_iternext(calliterobject *it)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
calliter_reduce(calliterobject *it, PyObject *Py_UNUSED(ignored))
|
calliter_reduce(calliterobject *it, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(iter);
|
|
||||||
if (it->it_callable != NULL && it->it_sentinel != NULL)
|
if (it->it_callable != NULL && it->it_sentinel != NULL)
|
||||||
return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_iter),
|
return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_iter),
|
||||||
it->it_callable, it->it_sentinel);
|
it->it_callable, it->it_sentinel);
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
|
|
||||||
static Py_ssize_t max_module_number;
|
static Py_ssize_t max_module_number;
|
||||||
|
|
||||||
|
_Py_IDENTIFIER(__doc__);
|
||||||
|
_Py_IDENTIFIER(__name__);
|
||||||
|
_Py_IDENTIFIER(__spec__);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
PyObject *md_dict;
|
PyObject *md_dict;
|
||||||
|
@ -58,11 +62,8 @@ static int
|
||||||
module_init_dict(PyModuleObject *mod, PyObject *md_dict,
|
module_init_dict(PyModuleObject *mod, PyObject *md_dict,
|
||||||
PyObject *name, PyObject *doc)
|
PyObject *name, PyObject *doc)
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(__name__);
|
|
||||||
_Py_IDENTIFIER(__doc__);
|
|
||||||
_Py_IDENTIFIER(__package__);
|
_Py_IDENTIFIER(__package__);
|
||||||
_Py_IDENTIFIER(__loader__);
|
_Py_IDENTIFIER(__loader__);
|
||||||
_Py_IDENTIFIER(__spec__);
|
|
||||||
|
|
||||||
if (md_dict == NULL)
|
if (md_dict == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -461,7 +462,6 @@ int
|
||||||
PyModule_SetDocString(PyObject *m, const char *doc)
|
PyModule_SetDocString(PyObject *m, const char *doc)
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
_Py_IDENTIFIER(__doc__);
|
|
||||||
|
|
||||||
v = PyUnicode_FromString(doc);
|
v = PyUnicode_FromString(doc);
|
||||||
if (v == NULL || _PyObject_SetAttrId(m, &PyId___doc__, v) != 0) {
|
if (v == NULL || _PyObject_SetAttrId(m, &PyId___doc__, v) != 0) {
|
||||||
|
@ -488,7 +488,6 @@ PyModule_GetDict(PyObject *m)
|
||||||
PyObject*
|
PyObject*
|
||||||
PyModule_GetNameObject(PyObject *m)
|
PyModule_GetNameObject(PyObject *m)
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(__name__);
|
|
||||||
PyObject *d;
|
PyObject *d;
|
||||||
PyObject *name;
|
PyObject *name;
|
||||||
if (!PyModule_Check(m)) {
|
if (!PyModule_Check(m)) {
|
||||||
|
@ -741,10 +740,8 @@ module_getattro(PyModuleObject *m, PyObject *name)
|
||||||
if (getattr) {
|
if (getattr) {
|
||||||
return _PyObject_CallOneArg(getattr, name);
|
return _PyObject_CallOneArg(getattr, name);
|
||||||
}
|
}
|
||||||
_Py_IDENTIFIER(__name__);
|
|
||||||
mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__);
|
mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__);
|
||||||
if (mod_name && PyUnicode_Check(mod_name)) {
|
if (mod_name && PyUnicode_Check(mod_name)) {
|
||||||
_Py_IDENTIFIER(__spec__);
|
|
||||||
Py_INCREF(mod_name);
|
Py_INCREF(mod_name);
|
||||||
PyObject *spec = _PyDict_GetItemId(m->md_dict, &PyId___spec__);
|
PyObject *spec = _PyDict_GetItemId(m->md_dict, &PyId___spec__);
|
||||||
Py_XINCREF(spec);
|
Py_XINCREF(spec);
|
||||||
|
|
|
@ -526,6 +526,8 @@ struct _odictnode {
|
||||||
#define _odict_FOREACH(od, node) \
|
#define _odict_FOREACH(od, node) \
|
||||||
for (node = _odict_FIRST(od); node != NULL; node = _odictnode_NEXT(node))
|
for (node = _odict_FIRST(od); node != NULL; node = _odictnode_NEXT(node))
|
||||||
|
|
||||||
|
_Py_IDENTIFIER(items);
|
||||||
|
|
||||||
/* Return the index into the hash table, regardless of a valid node. */
|
/* Return the index into the hash table, regardless of a valid node. */
|
||||||
static Py_ssize_t
|
static Py_ssize_t
|
||||||
_odict_get_index_raw(PyODictObject *od, PyObject *key, Py_hash_t hash)
|
_odict_get_index_raw(PyODictObject *od, PyObject *key, Py_hash_t hash)
|
||||||
|
@ -896,7 +898,6 @@ static PyObject *
|
||||||
odict_reduce(register PyODictObject *od, PyObject *Py_UNUSED(ignored))
|
odict_reduce(register PyODictObject *od, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(__dict__);
|
_Py_IDENTIFIER(__dict__);
|
||||||
_Py_IDENTIFIER(items);
|
|
||||||
PyObject *dict = NULL, *result = NULL;
|
PyObject *dict = NULL, *result = NULL;
|
||||||
PyObject *items_iter, *items, *args = NULL;
|
PyObject *items_iter, *items, *args = NULL;
|
||||||
|
|
||||||
|
@ -1375,7 +1376,6 @@ static PyObject *
|
||||||
odict_repr(PyODictObject *self)
|
odict_repr(PyODictObject *self)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
_Py_IDENTIFIER(items);
|
|
||||||
PyObject *pieces = NULL, *result = NULL;
|
PyObject *pieces = NULL, *result = NULL;
|
||||||
|
|
||||||
if (PyODict_SIZE(self) == 0)
|
if (PyODict_SIZE(self) == 0)
|
||||||
|
@ -2195,7 +2195,6 @@ mutablemapping_update(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
_Py_IDENTIFIER(items);
|
|
||||||
_Py_IDENTIFIER(keys);
|
_Py_IDENTIFIER(keys);
|
||||||
|
|
||||||
/* first handle args, if any */
|
/* first handle args, if any */
|
||||||
|
|
|
@ -18,6 +18,8 @@ typedef struct {
|
||||||
PyObject *length;
|
PyObject *length;
|
||||||
} rangeobject;
|
} rangeobject;
|
||||||
|
|
||||||
|
_Py_IDENTIFIER(iter);
|
||||||
|
|
||||||
/* Helper function for validating step. Always returns a new reference or
|
/* Helper function for validating step. Always returns a new reference or
|
||||||
NULL on error.
|
NULL on error.
|
||||||
*/
|
*/
|
||||||
|
@ -757,7 +759,6 @@ PyDoc_STRVAR(length_hint_doc,
|
||||||
static PyObject *
|
static PyObject *
|
||||||
rangeiter_reduce(rangeiterobject *r, PyObject *Py_UNUSED(ignored))
|
rangeiter_reduce(rangeiterobject *r, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(iter);
|
|
||||||
PyObject *start=NULL, *stop=NULL, *step=NULL;
|
PyObject *start=NULL, *stop=NULL, *step=NULL;
|
||||||
PyObject *range;
|
PyObject *range;
|
||||||
|
|
||||||
|
@ -915,7 +916,6 @@ longrangeiter_len(longrangeiterobject *r, PyObject *no_args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
longrangeiter_reduce(longrangeiterobject *r, PyObject *Py_UNUSED(ignored))
|
longrangeiter_reduce(longrangeiterobject *r, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(iter);
|
|
||||||
PyObject *product, *stop=NULL;
|
PyObject *product, *stop=NULL;
|
||||||
PyObject *range;
|
PyObject *range;
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@ _Py_IDENTIFIER(__new__);
|
||||||
_Py_IDENTIFIER(__set_name__);
|
_Py_IDENTIFIER(__set_name__);
|
||||||
_Py_IDENTIFIER(__setitem__);
|
_Py_IDENTIFIER(__setitem__);
|
||||||
_Py_IDENTIFIER(builtins);
|
_Py_IDENTIFIER(builtins);
|
||||||
|
_Py_IDENTIFIER(mro);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
|
slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
|
||||||
|
@ -310,7 +311,6 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (custom) {
|
if (custom) {
|
||||||
_Py_IDENTIFIER(mro);
|
|
||||||
mro_meth = lookup_maybe_method(
|
mro_meth = lookup_maybe_method(
|
||||||
(PyObject *)type, &PyId_mro, &unbound);
|
(PyObject *)type, &PyId_mro, &unbound);
|
||||||
if (mro_meth == NULL)
|
if (mro_meth == NULL)
|
||||||
|
@ -1891,7 +1891,6 @@ mro_invoke(PyTypeObject *type)
|
||||||
int custom = (Py_TYPE(type) != &PyType_Type);
|
int custom = (Py_TYPE(type) != &PyType_Type);
|
||||||
|
|
||||||
if (custom) {
|
if (custom) {
|
||||||
_Py_IDENTIFIER(mro);
|
|
||||||
int unbound;
|
int unbound;
|
||||||
PyObject *mro_meth = lookup_method((PyObject *)type, &PyId_mro,
|
PyObject *mro_meth = lookup_method((PyObject *)type, &PyId_mro,
|
||||||
&unbound);
|
&unbound);
|
||||||
|
|
|
@ -24,6 +24,8 @@ typedef struct _warnings_runtime_state WarningsState;
|
||||||
/* Forward declaration of the _warnings module definition. */
|
/* Forward declaration of the _warnings module definition. */
|
||||||
static struct PyModuleDef warningsmodule;
|
static struct PyModuleDef warningsmodule;
|
||||||
|
|
||||||
|
_Py_IDENTIFIER(__name__);
|
||||||
|
|
||||||
/* Given a module object, get its per-module state. */
|
/* Given a module object, get its per-module state. */
|
||||||
static WarningsState *
|
static WarningsState *
|
||||||
_Warnings_GetState()
|
_Warnings_GetState()
|
||||||
|
@ -484,7 +486,6 @@ show_warning(PyObject *filename, int lineno, PyObject *text,
|
||||||
PyObject *f_stderr;
|
PyObject *f_stderr;
|
||||||
PyObject *name;
|
PyObject *name;
|
||||||
char lineno_str[128];
|
char lineno_str[128];
|
||||||
_Py_IDENTIFIER(__name__);
|
|
||||||
|
|
||||||
PyOS_snprintf(lineno_str, sizeof(lineno_str), ":%d: ", lineno);
|
PyOS_snprintf(lineno_str, sizeof(lineno_str), ":%d: ", lineno);
|
||||||
|
|
||||||
|
@ -818,7 +819,6 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
|
||||||
PyObject **module, PyObject **registry)
|
PyObject **module, PyObject **registry)
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(__warningregistry__);
|
_Py_IDENTIFIER(__warningregistry__);
|
||||||
_Py_IDENTIFIER(__name__);
|
|
||||||
PyObject *globals;
|
PyObject *globals;
|
||||||
|
|
||||||
/* Setup globals, filename and lineno. */
|
/* Setup globals, filename and lineno. */
|
||||||
|
@ -969,7 +969,6 @@ get_source_line(PyObject *module_globals, int lineno)
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(get_source);
|
_Py_IDENTIFIER(get_source);
|
||||||
_Py_IDENTIFIER(__loader__);
|
_Py_IDENTIFIER(__loader__);
|
||||||
_Py_IDENTIFIER(__name__);
|
|
||||||
PyObject *loader;
|
PyObject *loader;
|
||||||
PyObject *module_name;
|
PyObject *module_name;
|
||||||
PyObject *get_source;
|
PyObject *get_source;
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
# error "ceval.c must be build with Py_BUILD_CORE define for best performance"
|
# error "ceval.c must be build with Py_BUILD_CORE define for best performance"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
_Py_IDENTIFIER(__name__);
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
Py_LOCAL_INLINE(PyObject *) call_function(
|
Py_LOCAL_INLINE(PyObject *) call_function(
|
||||||
|
@ -5032,7 +5033,6 @@ static PyObject *
|
||||||
import_from(PyThreadState *tstate, PyObject *v, PyObject *name)
|
import_from(PyThreadState *tstate, PyObject *v, PyObject *name)
|
||||||
{
|
{
|
||||||
PyObject *x;
|
PyObject *x;
|
||||||
_Py_IDENTIFIER(__name__);
|
|
||||||
PyObject *fullmodname, *pkgname, *pkgpath, *pkgname_or_unknown, *errmsg;
|
PyObject *fullmodname, *pkgname, *pkgpath, *pkgname_or_unknown, *errmsg;
|
||||||
|
|
||||||
if (_PyObject_LookupAttr(v, name, &x) != 0) {
|
if (_PyObject_LookupAttr(v, name, &x) != 0) {
|
||||||
|
@ -5108,7 +5108,6 @@ import_all_from(PyThreadState *tstate, PyObject *locals, PyObject *v)
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(__all__);
|
_Py_IDENTIFIER(__all__);
|
||||||
_Py_IDENTIFIER(__dict__);
|
_Py_IDENTIFIER(__dict__);
|
||||||
_Py_IDENTIFIER(__name__);
|
|
||||||
PyObject *all, *dict, *name, *value;
|
PyObject *all, *dict, *name, *value;
|
||||||
int skip_leading_underscores = 0;
|
int skip_leading_underscores = 0;
|
||||||
int pos, err;
|
int pos, err;
|
||||||
|
|
|
@ -24,11 +24,11 @@ extern char *strerror(int);
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
_Py_IDENTIFIER(__module__);
|
||||||
_Py_IDENTIFIER(builtins);
|
_Py_IDENTIFIER(builtins);
|
||||||
_Py_IDENTIFIER(stderr);
|
_Py_IDENTIFIER(stderr);
|
||||||
_Py_IDENTIFIER(flush);
|
_Py_IDENTIFIER(flush);
|
||||||
|
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_PyErr_FormatV(PyThreadState *tstate, PyObject *exception,
|
_PyErr_FormatV(PyThreadState *tstate, PyObject *exception,
|
||||||
|
@ -1009,7 +1009,6 @@ PyObject *
|
||||||
PyErr_NewException(const char *name, PyObject *base, PyObject *dict)
|
PyErr_NewException(const char *name, PyObject *base, PyObject *dict)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
_Py_IDENTIFIER(__module__);
|
|
||||||
PyObject *modulename = NULL;
|
PyObject *modulename = NULL;
|
||||||
PyObject *classname = NULL;
|
PyObject *classname = NULL;
|
||||||
PyObject *mydict = NULL;
|
PyObject *mydict = NULL;
|
||||||
|
@ -1235,7 +1234,6 @@ write_unraisable_exc_file(PyThreadState *tstate, PyObject *exc_type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_Py_IDENTIFIER(__module__);
|
|
||||||
PyObject *moduleName = _PyObject_GetAttrId(exc_type, &PyId___module__);
|
PyObject *moduleName = _PyObject_GetAttrId(exc_type, &PyId___module__);
|
||||||
if (moduleName == NULL || !PyUnicode_Check(moduleName)) {
|
if (moduleName == NULL || !PyUnicode_Check(moduleName)) {
|
||||||
Py_XDECREF(moduleName);
|
Py_XDECREF(moduleName);
|
||||||
|
|
|
@ -39,6 +39,9 @@ extern struct _inittab _PyImport_Inittab[];
|
||||||
struct _inittab *PyImport_Inittab = _PyImport_Inittab;
|
struct _inittab *PyImport_Inittab = _PyImport_Inittab;
|
||||||
static struct _inittab *inittab_copy = NULL;
|
static struct _inittab *inittab_copy = NULL;
|
||||||
|
|
||||||
|
_Py_IDENTIFIER(__path__);
|
||||||
|
_Py_IDENTIFIER(__spec__);
|
||||||
|
|
||||||
/*[clinic input]
|
/*[clinic input]
|
||||||
module _imp
|
module _imp
|
||||||
[clinic start generated code]*/
|
[clinic start generated code]*/
|
||||||
|
@ -383,7 +386,6 @@ import_ensure_initialized(PyThreadState *tstate, PyObject *mod, PyObject *name)
|
||||||
PyInterpreterState *interp = tstate->interp;
|
PyInterpreterState *interp = tstate->interp;
|
||||||
PyObject *spec;
|
PyObject *spec;
|
||||||
|
|
||||||
_Py_IDENTIFIER(__spec__);
|
|
||||||
_Py_IDENTIFIER(_lock_unlock_module);
|
_Py_IDENTIFIER(_lock_unlock_module);
|
||||||
|
|
||||||
/* Optimization: only call _bootstrap._lock_unlock_module() if
|
/* Optimization: only call _bootstrap._lock_unlock_module() if
|
||||||
|
@ -1566,9 +1568,7 @@ done:
|
||||||
static PyObject *
|
static PyObject *
|
||||||
resolve_name(PyThreadState *tstate, PyObject *name, PyObject *globals, int level)
|
resolve_name(PyThreadState *tstate, PyObject *name, PyObject *globals, int level)
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(__spec__);
|
|
||||||
_Py_IDENTIFIER(__package__);
|
_Py_IDENTIFIER(__package__);
|
||||||
_Py_IDENTIFIER(__path__);
|
|
||||||
_Py_IDENTIFIER(__name__);
|
_Py_IDENTIFIER(__name__);
|
||||||
_Py_IDENTIFIER(parent);
|
_Py_IDENTIFIER(parent);
|
||||||
PyObject *abs_name;
|
PyObject *abs_name;
|
||||||
|
@ -1930,7 +1930,6 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_Py_IDENTIFIER(__path__);
|
|
||||||
PyObject *path;
|
PyObject *path;
|
||||||
if (_PyObject_LookupAttrId(mod, &PyId___path__, &path) < 0) {
|
if (_PyObject_LookupAttrId(mod, &PyId___path__, &path) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
|
|
Loading…
Reference in New Issue