You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Historically the compiler (Python/compile.c and Python/symtable.c) contained a lot of code that did not check for errors after the C API calls. For example, it did not check that PyLong_AS_LONG(), PySequence_Contains(), PySet_Contains(), etc can fail, it used PyDict_GetItem() that silence errors. There were so much such cases that the code cleanup often stopped before the compiler. Finally many of such cases were gradually fixed. What's left is unchecked PyLong_AS_LONG() and some PyDict_GetItemWithItem().
The following PR adds many error checks. Some internal functions now return -1 to signal error. In most cases such checks are redundant, we know that values in the dicts are Python integers which can be converted to C long because they were created here. But it is safer to always check for errors than omit checks in "safe" case and be wrong.
Uh oh!
There was an error while loading. Please reload this page.
Historically the compiler (
Python/compile.c
andPython/symtable.c
) contained a lot of code that did not check for errors after the C API calls. For example, it did not check thatPyLong_AS_LONG()
,PySequence_Contains()
,PySet_Contains()
, etc can fail, it usedPyDict_GetItem()
that silence errors. There were so much such cases that the code cleanup often stopped before the compiler. Finally many of such cases were gradually fixed. What's left is uncheckedPyLong_AS_LONG()
and somePyDict_GetItemWithItem()
.The following PR adds many error checks. Some internal functions now return -1 to signal error. In most cases such checks are redundant, we know that values in the dicts are Python integers which can be converted to C
long
because they were created here. But it is safer to always check for errors than omit checks in "safe" case and be wrong.Linked PRs
The text was updated successfully, but these errors were encountered: