Commit 17fabe5a authored by Robert Bradshaw's avatar Robert Bradshaw

Make raising a KeyError not the default for parsing names.

parent 82245e93
......@@ -532,12 +532,8 @@ def p_atom(s):
def p_name(s, name):
pos = s.position()
if not s.compile_time_expr:
try:
if not s.compile_time_expr and name in s.compile_time_env:
value = s.compile_time_env.lookup_here(name)
except KeyError:
pass
else:
rep = repr(value)
if isinstance(value, bool):
return ExprNodes.BoolNode(pos, value = value)
......
from Cython.Plex.Scanners cimport Scanner
cdef class CompileTimeScope:
cdef public entries
cdef public outer
cdef class PyrexScanner(Scanner):
cdef public context
cdef public list included_files
......
......@@ -176,7 +176,7 @@ resword_dict = build_resword_dict()
#------------------------------------------------------------------
class CompileTimeScope(object):
class CompileTimeScope:
def __init__(self, outer = None):
self.entries = {}
......@@ -188,6 +188,9 @@ class CompileTimeScope(object):
def lookup_here(self, name):
return self.entries[name]
def __contains__(self, name):
return name in self.entries
def lookup(self, name):
try:
return self.lookup_here(name)
......
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