Author: Ronan Lamy <[email protected]>
Branch: translation-cleanup
Changeset: r57017:8c757c2be925
Date: 2012-08-24 14:14 +0100
http://bitbucket.org/pypy/pypy/changeset/8c757c2be925/
Log: Remove ObjSpace logic from .find_global()
diff --git a/pypy/objspace/flow/objspace.py b/pypy/objspace/flow/objspace.py
--- a/pypy/objspace/flow/objspace.py
+++ b/pypy/objspace/flow/objspace.py
@@ -484,14 +484,16 @@
raise operation.ImplicitOperationError(w_exc_cls, w_exc_value)
def find_global(self, w_globals, varname):
- w_value = self.finditem_str(w_globals, varname)
- if w_value is None:
+ try:
+ value = self.unwrap(w_globals)[varname]
+ except KeyError:
# not in the globals, now look in the built-ins
- w_value = self.builtin.getdictvalue(self, varname)
- if w_value is None:
+ try:
+ value = self.unwrap(self.builtin.w_dict)[varname]
+ except KeyError:
message = "global name '%s' is not defined" % varname
raise OperationError(self.w_NameError, self.wrap(message))
- return w_value
+ return self.wrap(value)
def w_KeyboardInterrupt(self):
# the reason to do this is: if you interrupt the flowing of a function
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit