[pypy-svn] r25682 - pypy/dist/pypy/objspace/flow
tismer at codespeak.net
tismer at codespeak.net
Tue Apr 11 01:55:13 CEST 2006
Author: tismer
Date: Tue Apr 11 01:55:11 2006
New Revision: 25682
Modified:
pypy/dist/pypy/objspace/flow/specialcase.py
Log:
rewrote the import special case logic. It uses the new delayed constantness feature of flow space.
Modified: pypy/dist/pypy/objspace/flow/specialcase.py
==============================================================================
--- pypy/dist/pypy/objspace/flow/specialcase.py (original)
+++ pypy/dist/pypy/objspace/flow/specialcase.py Tue Apr 11 01:55:11 2006
@@ -6,19 +6,21 @@
def sc_import(space, fn, args):
w_name, w_glob, w_loc, w_frm = args.fixedunpack(4)
- try:
- name, glob, loc, frm = (space.unwrap(w_name), space.unwrap(w_glob),
- space.unwrap(w_loc), space.unwrap(w_frm))
- except UnwrapException:
+ if not isinstance(w_loc, Constant):
# import * in a function gives us the locals as Variable
- # we forbid it as a SyntaxError
+ # we always forbid it as a SyntaxError
raise SyntaxError, "RPython: import * is not allowed in functions"
if space.do_imports_immediately:
+ name, glob, loc, frm = (space.unwrap(w_name), space.unwrap(w_glob),
+ space.unwrap(w_loc), space.unwrap(w_frm))
return space.wrap(__import__(name, glob, loc, frm))
# redirect it, but avoid exposing the globals
w_glob = Constant({})
- return space.do_operation('simple_call', Constant(__import__),
- w_name, w_glob, w_loc, w_frm)
+ w_ret = space.do_operation('simple_call', Constant(__import__),
+ w_name, w_glob, w_loc, w_frm)
+ # let the space decide later if this should be a constant import
+ space.track_possible_constant(w_ret, __import__, w_name, w_glob, w_loc, w_frm)
+ return w_ret
def sc_operator(space, fn, args):
args_w, kwds_w = args.unpack()
More information about the Pypy-commit
mailing list