[pypy-svn] r9985 - pypy/dist/pypy/interpreter
rxe at codespeak.net
rxe at codespeak.net
Mon Mar 21 15:36:55 CET 2005
Author: rxe
Date: Mon Mar 21 15:36:55 2005
New Revision: 9985
Modified:
pypy/dist/pypy/interpreter/executioncontext.py
pypy/dist/pypy/interpreter/gateway.py
pypy/dist/pypy/interpreter/miscutils.py
pypy/dist/pypy/interpreter/pycode.py
Log:
Added applevel to code objects, to identity code which will be translated wasy (such
as exception code) to hide these unexpectedly appearing in settrace() when
running in CPython.
Modified: pypy/dist/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/dist/pypy/interpreter/executioncontext.py (original)
+++ pypy/dist/pypy/interpreter/executioncontext.py Mon Mar 21 15:36:55 2005
@@ -21,10 +21,14 @@
locals = getthreadlocals()
previous_ec = locals.executioncontext
locals.executioncontext = self
- if self.framestack.empty():
- frame.f_back = None
+
+ for ff in self.framestack:
+ if not frame.code.getapplevel():
+ frame.f_back = ff
+ break
else:
- frame.f_back = self.framestack.top()
+ frame.f_back = None
+
self.framestack.push(frame)
return previous_ec
@@ -147,6 +151,9 @@
self.w_tracefunc = w_func
def _trace(self, frame, event, w_arg):
+ if frame.code.getapplevel():
+ return
+
if event == 'call':
w_callback = self.w_tracefunc
else:
Modified: pypy/dist/pypy/interpreter/gateway.py
==============================================================================
--- pypy/dist/pypy/interpreter/gateway.py (original)
+++ pypy/dist/pypy/interpreter/gateway.py Mon Mar 21 15:36:55 2005
@@ -493,7 +493,7 @@
self.code = py.code.Source(source).compile()
else:
self.code = compile(source, filename, 'exec')
-
+
def getwdict(self, space):
return space.loadfromcache(self, applevel._builddict,
space._gatewaycache)
@@ -504,8 +504,11 @@
def _builddict(self, space):
"NOT_RPYTHON"
+
+ from pypy.interpreter.pycode import PyCode
+ code = PyCode(space)._from_code(self.code, applevel=True)
w_glob = space.newdict([])
- space.exec_(self.code, w_glob, w_glob)
+ space.exec_(code, w_glob, w_glob)
return w_glob
def wget(self, space, name):
Modified: pypy/dist/pypy/interpreter/miscutils.py
==============================================================================
--- pypy/dist/pypy/interpreter/miscutils.py (original)
+++ pypy/dist/pypy/interpreter/miscutils.py Mon Mar 21 15:36:55 2005
@@ -42,6 +42,10 @@
def empty(self):
return not self.items
+ def __iter__(self):
+ # Walk the stack backwards
+ for ii in self.items[::-1]:
+ yield ii
class InitializedClass(type):
"""NOT_RPYTHON. A meta-class that allows a class to initialize itself (or
Modified: pypy/dist/pypy/interpreter/pycode.py
==============================================================================
--- pypy/dist/pypy/interpreter/pycode.py (original)
+++ pypy/dist/pypy/interpreter/pycode.py Mon Mar 21 15:36:55 2005
@@ -96,13 +96,15 @@
#self.co_name (in base class)# string: name, for reference
self.co_firstlineno = 0 # first source line number
self.co_lnotab = "" # string: encoding addr<->lineno mapping
+ self.applevel = False
- def _from_code(self, code):
+ def _from_code(self, code, applevel=False):
""" Initialize the code object from a real (CPython) one.
This is just a hack, until we have our own compile.
At the moment, we just fake this.
This method is called by our compile builtin function.
"""
+ self.applevel = applevel
import types
assert isinstance(code, types.CodeType)
# simply try to suck in all attributes we know of
@@ -140,7 +142,7 @@
newconsts_w = []
for const in code.co_consts:
if isinstance(const, types.CodeType):
- const = PyCode(space)._from_code(const)
+ const = PyCode(space)._from_code(const, applevel=applevel)
newconsts_w.append(space.wrap(const))
self.co_consts_w = newconsts_w
return self
@@ -160,6 +162,9 @@
signature = cpython_code_signature
+ def getapplevel(self):
+ return self.applevel
+
def getvarnames(self):
return self.co_varnames
More information about the Pypy-commit
mailing list