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
{{ message }}
Repository navigation
ast.AST.__repr__ can crash on missing _fields #156909
Just a null pointer access with no realistic occurence risk. However, it's trivial, so it's worth a fix for correctness so it can't escalate to sth realistic.
importastclassFieldsMissingMeta(type):
def__getattribute__(self, name):
ifarmedandname=='_fields':
# PyObject_GetOptionalAttr() returns 0 now, *fields is NULL.# The returned sentinel 0 is not handled.raiseAttributeErrorreturntype.__getattribute__(self, name)
classFieldsMissing(ast.Del, metaclass=FieldsMissingMeta):
passarmed=False# don't raise during constructionf=FieldsMissing()
armed=True# raise in repr()repr(f) # problem is in ast_repr_max_depth()
I'll send a patch.
CPython versions tested on:
3.14, 3.15, 3.16, CPython main branch
Operating systems tested on:
macOS
Output from running 'python -VV' on the command line:
Activity
gh-156909: Fix `AST.__repr__` call getting the `_fields` attribute (G…
[3.15] gh-156909: Fix `AST.__repr__` call getting the `_fields` attri…