New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify and optimize the helper for getting a builtin object #79625
Comments
_PyIter_GetBuiltin() was introduced in bpo-14288 (31668b8). This was used for getting references to the builtin "iter" and "reverse". It was renamed to _PyObject_GetBuiltin() in a701388. There is other code that gets references to the builtin "getattr" using PyEval_GetBuiltins(). It is more efficient, but contains bugs. The proposed PR unifies getting references to builtins:
An example of an error in current code: >>> import builtins
>>> del builtins.getattr
>>> int.bit_length.__reduce__()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: NULL object passed to Py_BuildValue |
I reopen the issuue. Commit bb86bf4 introduced a new compiler warning: gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall -O0 -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Objects/object.o Objects/object.c In file included from ./Include/object.h:715,
from ./Include/pytime.h:6,
from ./Include/Python.h:75,
from Objects/object.c:4:
./Include/cpython/object.h:37:51: warning: 'PyId_builtins' defined but not used [-Wunused-variable]
#define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname)
^~~~~
./Include/cpython/object.h:36:66: note: in definition of macro '_Py_static_string'
#define _Py_static_string(varname, value) static _Py_Identifier varname = _Py_static_string_init(value)
^~~~~~~
Objects/object.c:20:1: note: in expansion of macro '_Py_IDENTIFIER'
_Py_IDENTIFIER(builtins);
^~~~~~~~~~~~~~ |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: