Commit 84ffbce2 authored by Stefan Behnel's avatar Stefan Behnel

treat unknown (builtin) names as potential globals instead of requiring them...

treat unknown (builtin) names as potential globals instead of requiring them to be builtins at runtime
parent da37b693
......@@ -1893,7 +1893,8 @@ class NameNode(AtomicExprNode):
code.putln(code.error_goto_if_null(self.result(), self.pos))
code.put_gotref(self.py_result())
elif entry.is_builtin:
elif entry.is_builtin and not entry.scope.is_module_scope:
# known builtin
assert entry.type.is_pyobject, "Python global or builtin not a Python object"
interned_cname = code.intern_identifier(self.entry.name)
code.globalstate.use_utility_code(
......@@ -1905,7 +1906,8 @@ class NameNode(AtomicExprNode):
code.error_goto_if_null(self.result(), self.pos)))
code.put_gotref(self.py_result())
elif entry.is_pyglobal:
elif entry.is_pyglobal or (entry.is_builtin and entry.scope.is_module_scope):
# name in class body, global name or unknown builtin
assert entry.type.is_pyobject, "Python global or builtin not a Python object"
interned_cname = code.intern_identifier(self.entry.name)
if entry.scope.is_module_scope:
......
# mode: run
# tag: allow_unknown_names
assert "NEW" not in globals()
globals().update(NEW=True)
assert "NEW" in globals()
def default_args(value=NEW):
"""
>>> default_args()
True
"""
return value
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment