[pypy-svn] r16281 - pypy/dist/pypy/interpreter
tismer at codespeak.net
tismer at codespeak.net
Tue Aug 23 16:57:13 CEST 2005
Author: tismer
Date: Tue Aug 23 16:57:12 2005
New Revision: 16281
Modified:
pypy/dist/pypy/interpreter/pycompiler.py
Log:
needed to move the applevel stuff into the __init__ context.
Otherwise, the annotator would complain.
Modified: pypy/dist/pypy/interpreter/pycompiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/pycompiler.py (original)
+++ pypy/dist/pypy/interpreter/pycompiler.py Tue Aug 23 16:57:12 2005
@@ -240,26 +240,29 @@
PythonCompiler.__init__(self, space)
debug_print("importing the 'compiler' package at app-level...",
newline=False)
- self._load_compiler('single')
+ self._load_compilers()
debug_print(" done")
- def _load_compiler(self, mode):
- if mode == 'single':
- self.w_applevelcompile = self.space.appexec([], r'''():
- from _stablecompiler import apphook
+ def _load_compilers(self):
+ comp1 = self.space.appexec([], r'''():
+ from _stablecompiler import apphook
+ return apphook.applevelcompile
+ ''')
+ comp2 = self.w_applevelcompile = self.space.appexec([], r'''():
+ import os
+ from _stablecompiler import apphook
+ if os.path.exists('fakecompiler.py'):
+ print "faking compiler, because fakecompiler.py is in the current dir"
+ import fakecompiler
+ return fakecompiler.fakeapplevelcompile
+ else:
return apphook.applevelcompile
- ''')
- else:
- self.w_applevelcompile = self.space.appexec([], r'''():
- import os
- from _stablecompiler import apphook
- if os.path.exists('fakecompiler.py'):
- print "faking compiler, because fakecompiler.py is in the current dir"
- import fakecompiler
- return fakecompiler.fakeapplevelcompile
- else:
- return apphook.applevelcompile
- ''')
+ ''')
+ self.applevelcompile_w = {
+ 'single': compile1,
+ 'eval': compile2,
+ 'exec': compile2,
+ }
def compile_parse_result(self, parse_result, filename, mode):
space = self.space
@@ -279,8 +282,7 @@
w_nested_tuples,
space.wrap(source_encoding)])
- self._load_compiler(mode)
- w_code = space.call_function(self.w_applevelcompile,
+ w_code = space.call_function(self.applevelcompile_w[mode],
w_nested_tuples,
space.wrap(filename),
space.wrap(mode))
More information about the Pypy-commit
mailing list