[pypy-svn] r9911 - pypy/dist/pypy/interpreter
hpk at codespeak.net
hpk at codespeak.net
Sun Mar 20 01:11:54 CET 2005
Author: hpk
Date: Sun Mar 20 01:11:54 2005
New Revision: 9911
Modified:
pypy/dist/pypy/interpreter/gateway.py
pypy/dist/pypy/interpreter/lazymodule.py
Log:
allow applevel to directly understand that source code
comes from a specific file (improves error/py.test output)
Modified: pypy/dist/pypy/interpreter/gateway.py
==============================================================================
--- pypy/dist/pypy/interpreter/gateway.py (original)
+++ pypy/dist/pypy/interpreter/gateway.py Sun Mar 20 01:11:54 2005
@@ -487,9 +487,12 @@
NOT_RPYTHON_ATTRIBUTES = ['code']
- def __init__(self, source):
+ def __init__(self, source, filename=None):
"NOT_RPYTHON"
- self.code = py.code.Source(source).compile()
+ if filename is None:
+ self.code = py.code.Source(source).compile()
+ else:
+ self.code = compile(source, filename, 'exec')
def getwdict(self, space):
return space.loadfromcache(self, applevel._builddict,
Modified: pypy/dist/pypy/interpreter/lazymodule.py
==============================================================================
--- pypy/dist/pypy/interpreter/lazymodule.py (original)
+++ pypy/dist/pypy/interpreter/lazymodule.py Sun Mar 20 01:11:54 2005
@@ -112,4 +112,7 @@
def buildapplevelfrommodule(mod, _):
""" NOT_RPYTHON """
source = inspect.getsource(mod)
- return gateway.applevel(source)
+ fn = mod.__file__
+ if fn.endswith('.pyc'):
+ fn = fn[:-1]
+ return gateway.applevel(source, filename=fn)
More information about the Pypy-commit
mailing list