[pypy-commit] pypy translation-cleanup: Remove option FlowObjSpace.do_imports_immediately
rlamy
noreply at buildbot.pypy.org
Thu Aug 30 18:38:31 CEST 2012
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r57010:89322fdf24fe
Date: 2012-08-23 03:28 +0100
http://bitbucket.org/pypy/pypy/changeset/89322fdf24fe/
Log: Remove option FlowObjSpace.do_imports_immediately
All traces of the option have been removed, imports are now always
performed immediately by the flow space.
NB: setting the option to False didn't seem to be actually
supported.
diff --git a/pypy/annotation/policy.py b/pypy/annotation/policy.py
--- a/pypy/annotation/policy.py
+++ b/pypy/annotation/policy.py
@@ -27,11 +27,6 @@
callback()
del annotator.bookkeeper.pending_specializations[:]
- def _adjust_space_config(self, space):
- # allow to override space options.
- if getattr(self, 'do_imports_immediately', None) is not None:
- space.do_imports_immediately = self.do_imports_immediately
-
class AnnotatorPolicy(BasicAnnotatorPolicy):
"""
Possibly subclass and pass an instance to the annotator to control special casing during annotation
@@ -67,7 +62,7 @@
def specialize_with_parms(funcdesc, args_s):
return specializer(funcdesc, args_s, *parms)
return specialize_with_parms
-
+
# common specializations
default_specialize = staticmethod(default)
diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -228,11 +228,9 @@
self.recorder.crnt_block.closeblock(link)
except OperationError, e:
- #print "OE", e.w_type, e.get_w_value(self.space)
- if (self.space.do_imports_immediately and
- e.w_type is self.space.w_ImportError):
- raise ImportError('import statement always raises %s' % (
- e,))
+ if e.w_type is self.space.w_ImportError:
+ msg = 'import statement always raises %s' % e
+ raise ImportError(msg)
w_value = e.get_w_value(self.space)
link = self.make_link([e.w_type, w_value], self.graph.exceptblock)
self.recorder.crnt_block.closeblock(link)
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
@@ -47,7 +47,6 @@
"""
full_exceptions = False
- do_imports_immediately = True
FrameClass = flowcontext.FlowSpaceFrame
def initialize(self):
@@ -412,19 +411,13 @@
# we always forbid it as a SyntaxError
raise SyntaxError, "RPython: import * is not allowed in functions"
- if self.do_imports_immediately:
- name, glob, loc, frm = (self.unwrap(w_name), self.unwrap(w_glob),
- self.unwrap(w_loc), self.unwrap(w_frm))
- try:
- mod = __import__(name, glob, loc, frm)
- except ImportError, e:
- raise OperationError(self.w_ImportError, self.wrap(str(e)))
- return self.wrap(mod)
-
- # redirect it, but avoid exposing the globals
- w_glob = Constant({})
- return self.do_operation('simple_call', Constant(__import__),
- w_name, w_glob, w_loc, w_frm)
+ name, glob, loc, frm = (self.unwrap(w_name), self.unwrap(w_glob),
+ self.unwrap(w_loc), self.unwrap(w_frm))
+ try:
+ mod = __import__(name, glob, loc, frm)
+ except ImportError, e:
+ raise OperationError(self.w_ImportError, self.wrap(str(e)))
+ return self.wrap(mod)
def import_from(self, w_module, w_name):
try:
diff --git a/pypy/objspace/flow/test/test_objspace.py b/pypy/objspace/flow/test/test_objspace.py
--- a/pypy/objspace/flow/test/test_objspace.py
+++ b/pypy/objspace/flow/test/test_objspace.py
@@ -997,17 +997,6 @@
assert graph.startblock.exits[0].target == graph.returnblock
-class TestFlowObjSpaceDelay(Base):
- def setup_class(cls):
- cls.space = FlowObjSpace()
- cls.space.do_imports_immediately = False
-
- def test_import_something(self):
- def f():
- from some.unknown.module import stuff
- g = self.codetest(f)
-
-
DATA = {'x': 5,
'y': 6}
diff --git a/pypy/translator/translator.py b/pypy/translator/translator.py
--- a/pypy/translator/translator.py
+++ b/pypy/translator/translator.py
@@ -66,12 +66,6 @@
log.start(nice_repr_for_func(func))
from pypy.objspace.flow.objspace import FlowObjSpace
space = FlowObjSpace(self.flowconfig)
- if self.annotator:
- # ZZZ
- self.annotator.policy._adjust_space_config(space)
- elif hasattr(self, 'no_annotator_but_do_imports_immediately'):
- space.do_imports_immediately = (
- self.no_annotator_but_do_imports_immediately)
graph = space.build_flow(func)
if self.config.translation.simplifying:
simplify.simplify_graph(graph)
More information about the pypy-commit
mailing list