cname, type = definition
self.declare_var(name, type, None, cname)
+ def lookup(self, name, language_level=None):
+ # 'language_level' is passed by ModuleScope
+ if language_level == 3:
+ if name == 'str':
+ name = 'unicode'
+ return Scope.lookup(self, name)
+
def declare_builtin(self, name, pos):
if not hasattr(builtins, name):
if self.outer_scope is not None:
def global_scope(self):
return self
+ def lookup(self, name):
+ entry = self.lookup_here(name)
+ if entry is not None:
+ return entry
+ return self.outer_scope.lookup(name, language_level = self.context.language_level)
+
def declare_builtin(self, name, pos):
if not hasattr(builtins, name) and name != 'xrange':
# 'xrange' is special cased in Code.py
print(isinstance(ustring, unicode) or type(ustring))
return ustring
+def str_type_is_unicode():
+ """
+ >>> str_type, s = str_type_is_unicode()
+ >>> isinstance(s, type(ustring)) or (s, str_type)
+ True
+ >>> isinstance(s, str_type) or (s, str_type)
+ True
+ >>> isinstance(ustring, str_type) or str_type
+ True
+ """
+ cdef str s = 'abc'
+ return str, s
+
def list_comp():
"""
>>> list_comp()