Author: Ronan Lamy <[email protected]>
Branch: annotator
Changeset: r68741:bb99875af0a9
Date: 2014-01-09 17:54 +0000
http://bitbucket.org/pypy/pypy/changeset/bb99875af0a9/
Log: move import_name() out of FlowObjSpace
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -702,13 +702,19 @@
operror = self.exc_from_raise(w_type, w_None)
raise Raise(operror)
+ def import_name(self, name, glob=None, loc=None, frm=None, level=-1):
+ try:
+ mod = __import__(name, glob, loc, frm, level)
+ except ImportError as e:
+ raise Raise(const(e))
+ return const(mod)
+
def IMPORT_NAME(self, nameindex):
- space = self.space
modulename = self.getname_u(nameindex)
glob = self.w_globals.value
fromlist = self.popvalue().value
level = self.popvalue().value
- w_obj = space.import_name(modulename, glob, None, fromlist, level)
+ w_obj = self.import_name(modulename, glob, None, fromlist, level)
self.pushvalue(w_obj)
def IMPORT_FROM(self, nameindex):
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -3,7 +3,6 @@
"""
import __builtin__
-import types
from inspect import CO_NEWLOCALS
from rpython.flowspace.argument import CallSpec
@@ -18,7 +17,6 @@
from rpython.flowspace.specialcase import SPECIAL_CASES
-
def _assert_rpythonic(func):
"""Raise ValueError if ``func`` is obviously not RPython"""
if func.func_doc and func.func_doc.lstrip().startswith('NOT_RPYTHON'):
@@ -40,14 +38,6 @@
def build_flow(self, func):
return build_flow(func, self)
- # ____________________________________________________________
- def import_name(self, name, glob=None, loc=None, frm=None, level=-1):
- try:
- mod = __import__(name, glob, loc, frm, level)
- except ImportError as e:
- raise Raise(const(e))
- return const(mod)
-
def import_from(self, w_module, w_name):
assert isinstance(w_module, Constant)
assert isinstance(w_name, Constant)
diff --git a/rpython/flowspace/specialcase.py b/rpython/flowspace/specialcase.py
--- a/rpython/flowspace/specialcase.py
+++ b/rpython/flowspace/specialcase.py
@@ -19,7 +19,7 @@
assert len(args_w) > 0 and len(args_w) <= 5, 'import needs 1 to 5
arguments'
assert all(isinstance(arg, Constant) for arg in args_w)
args = [arg.value for arg in args_w]
- return space.import_name(*args)
+ return space.frame.import_name(*args)
@register_flow_sc(locals)
def sc_locals(_, *args):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit