[pypy-svn] r12706 - in pypy/dist/pypy: interpreter translator
arigo at codespeak.net
arigo at codespeak.net
Sat May 21 13:42:24 CEST 2005
Author: arigo
Date: Sat May 21 13:42:24 2005
New Revision: 12706
Modified:
pypy/dist/pypy/interpreter/gateway.py
pypy/dist/pypy/translator/geninterplevel.py
Log:
Port the bugfix 0.6 -> 0.6.1 to the trunk.
Modified: pypy/dist/pypy/interpreter/gateway.py
==============================================================================
--- pypy/dist/pypy/interpreter/gateway.py (original)
+++ pypy/dist/pypy/interpreter/gateway.py Sat May 21 13:42:24 2005
@@ -7,7 +7,7 @@
"""
-import types, sys, md5, os
+import types, sys, md5, os, autopath
NoneNotWrapped = object()
@@ -595,32 +595,38 @@
cls._setup()
from pypy.translator.geninterplevel import translate_as_module
- scramble = md5.new(cls.seed)
- scramble.update(self.source)
- key = scramble.hexdigest()
- initfunc = cls.known_source.get(key)
- if not initfunc:
- # try to get it from file
- name = key
- if self.filename:
- prename = os.path.splitext(os.path.basename(self.filename))[0]
- else:
- prename = 'zznoname'
- name = "%s_%s" % (prename, name)
- try:
- __import__("pypy._cache."+name)
- except ImportError, x:
- # print x
- pass
- else:
- initfunc = cls.known_source[key]
- if not initfunc:
- # build it and put it into a file
- initfunc, newsrc = translate_as_module(
- self.source, self.filename, self.modname)
- fname = cls.cache_path.join(name+".py").strpath
- f = file(fname, "w")
- print >> f, """\
+
+ # XXX HACK HACK HACK XXX
+ # XXX allow the app-level code to contain e.g. "import _formatting"
+ libdir = os.path.join(autopath.pypydir, "lib")
+ sys.path.append(libdir)
+ try:
+ scramble = md5.new(cls.seed)
+ scramble.update(self.source)
+ key = scramble.hexdigest()
+ initfunc = cls.known_source.get(key)
+ if not initfunc:
+ # try to get it from file
+ name = key
+ if self.filename:
+ prename = os.path.splitext(os.path.basename(self.filename))[0]
+ else:
+ prename = 'zznoname'
+ name = "%s_%s" % (prename, name)
+ try:
+ __import__("pypy._cache."+name)
+ except ImportError, x:
+ # print x
+ pass
+ else:
+ initfunc = cls.known_source[key]
+ if not initfunc:
+ # build it and put it into a file
+ initfunc, newsrc = translate_as_module(
+ self.source, self.filename, self.modname)
+ fname = cls.cache_path.join(name+".py").strpath
+ f = file(fname, "w")
+ print >> f, """\
# self-destruct on double-click:
if __name__ == "__main__":
from pypy import _cache
@@ -631,11 +637,14 @@
os.unlink(namestart+ending)
except os.error:
pass""" % name
- print >> f
- print >> f, newsrc
- print >> f, "from pypy._cache import known_source"
- print >> f, "known_source[%r] = %s" % (key, initfunc.__name__)
- w_glob = initfunc(space)
+ print >> f
+ print >> f, newsrc
+ print >> f, "from pypy._cache import known_source"
+ print >> f, "known_source[%r] = %s" % (key, initfunc.__name__)
+ w_glob = initfunc(space)
+ finally:
+ if libdir in sys.path:
+ sys.path.remove(libdir)
return w_glob
build_applevelinterp_dict = classmethod(build_applevelinterp_dict)
Modified: pypy/dist/pypy/translator/geninterplevel.py
==============================================================================
--- pypy/dist/pypy/translator/geninterplevel.py (original)
+++ pypy/dist/pypy/translator/geninterplevel.py Sat May 21 13:42:24 2005
@@ -1326,15 +1326,7 @@
dic = {'__name__': modname}
if filename:
dic['__file__'] = filename
-
- # XXX allow the app-level code to contain e.g. "import _formatting"
- libdir = os.path.join(pypy.__path__[0], "lib")
- hold = sys.path[:]
- sys.path.insert(0, libdir)
- try:
- exec code in dic
- finally:
- sys.path[:] = hold
+ exec code in dic
entrypoint = dic
t = Translator(None, verbose=False, simplifying=needed_passes,
More information about the Pypy-commit
mailing list