New submission from Batuhan Taskaya <batuhanosmantask...@gmail.com>:

When something that isn't constant found in a ast.Constant node's body, python 
reports errors like this

>>> e = ast.Expression(body=ast.Constant(value=type))
>>> ast.fix_missing_locations(e)
<_ast.Expression object at 0x7fc2c23981c0>
>>> compile(e, "<test>", "eval")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: got an invalid type in Constant: type

But if something is part of constant tuple and frozenset isn't constant, the 
error reporting is wrong 

>>> e = ast.Expression(body=ast.Constant(value=(1,2,type)))
>>> compile(e, "<test>", "eval")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: got an invalid type in Constant: tuple

This should've been 

TypeError: got an invalid type in Constant: type

----------
messages: 364505
nosy: BTaskaya
priority: normal
severity: normal
status: open
title: Improve AST validation for Constant nodes

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40000>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to