[pypy-commit] pypy default: Tentative: make sure that all PyFrame instances are actually
arigo
noreply at buildbot.pypy.org
Wed Aug 17 14:38:27 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r46559:0641fdee2d47
Date: 2011-08-17 14:42 +0200
http://bitbucket.org/pypy/pypy/changeset/0641fdee2d47/
Log: Tentative: make sure that all PyFrame instances are actually
instances of the (same) subclass.
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -52,6 +52,9 @@
escaped = False # see mark_as_escaped()
def __init__(self, space, code, w_globals, closure):
+ if not we_are_translated():
+ assert type(self) in (space.FrameClass, CPythonFrame), (
+ "use space.FrameClass(), not directly PyFrame()")
self = hint(self, access_directly=True, fresh_virtualizable=True)
assert isinstance(code, pycode.PyCode)
self.pycode = code
diff --git a/pypy/module/cpyext/frameobject.py b/pypy/module/cpyext/frameobject.py
--- a/pypy/module/cpyext/frameobject.py
+++ b/pypy/module/cpyext/frameobject.py
@@ -57,7 +57,7 @@
code = space.interp_w(PyCode, w_code)
w_globals = from_ref(space, py_frame.c_f_globals)
- frame = PyFrame(space, code, w_globals, closure=None)
+ frame = space.FrameClass(space, code, w_globals, closure=None)
frame.f_lineno = py_frame.c_f_lineno
w_obj = space.wrap(frame)
track_reference(space, py_obj, w_obj)
diff --git a/pypy/tool/pytest/test/test_pytestsupport.py b/pypy/tool/pytest/test/test_pytestsupport.py
--- a/pypy/tool/pytest/test/test_pytestsupport.py
+++ b/pypy/tool/pytest/test/test_pytestsupport.py
@@ -2,7 +2,6 @@
from pypy.interpreter.gateway import app2interp_temp
from pypy.interpreter.argument import Arguments
from pypy.interpreter.pycode import PyCode
-from pypy.interpreter.pyframe import PyFrame
from pypy.tool.pytest.appsupport import (AppFrame, build_pytest_assertion,
AppExceptionInfo, interpret)
import py
@@ -20,7 +19,7 @@
def test_AppFrame(space):
import sys
co = PyCode._from_code(space, somefunc.func_code)
- pyframe = PyFrame(space, co, space.newdict(), None)
+ pyframe = space.FrameClass(space, co, space.newdict(), None)
runner = AppFrame(space, pyframe)
interpret("f = lambda x: x+1", runner, should_fail=False)
msg = interpret("assert isinstance(f(2), float)", runner)
More information about the pypy-commit
mailing list