gh-99139: Improve NameError error suggestion for instances (#99140)

This commit is contained in:
Pablo Galindo Salgado 2022-11-06 13:52:06 +00:00 committed by GitHub
parent a0bc75e2fd
commit 99e2e60cb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 92 additions and 0 deletions

View file

@ -600,6 +600,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(seek)
STRUCT_FOR_ID(seekable)
STRUCT_FOR_ID(selectors)
STRUCT_FOR_ID(self)
STRUCT_FOR_ID(send)
STRUCT_FOR_ID(sep)
STRUCT_FOR_ID(sequence)

View file

@ -1109,6 +1109,7 @@ extern "C" {
INIT_ID(seek), \
INIT_ID(seekable), \
INIT_ID(selectors), \
INIT_ID(self), \
INIT_ID(send), \
INIT_ID(sep), \
INIT_ID(sequence), \
@ -2567,6 +2568,8 @@ _PyUnicode_InitStaticStrings(void) {
PyUnicode_InternInPlace(&string);
string = &_Py_ID(selectors);
PyUnicode_InternInPlace(&string);
string = &_Py_ID(self);
PyUnicode_InternInPlace(&string);
string = &_Py_ID(send);
PyUnicode_InternInPlace(&string);
string = &_Py_ID(sep);
@ -7104,6 +7107,10 @@ _PyStaticObjects_CheckRefcnt(void) {
_PyObject_Dump((PyObject *)&_Py_ID(selectors));
Py_FatalError("immortal object has less refcnt than expected _PyObject_IMMORTAL_REFCNT");
};
if (Py_REFCNT((PyObject *)&_Py_ID(self)) < _PyObject_IMMORTAL_REFCNT) {
_PyObject_Dump((PyObject *)&_Py_ID(self));
Py_FatalError("immortal object has less refcnt than expected _PyObject_IMMORTAL_REFCNT");
};
if (Py_REFCNT((PyObject *)&_Py_ID(send)) < _PyObject_IMMORTAL_REFCNT) {
_PyObject_Dump((PyObject *)&_Py_ID(send));
Py_FatalError("immortal object has less refcnt than expected _PyObject_IMMORTAL_REFCNT");