[pypy-commit] pypy space-newtext: Tweak the fake objspace
arigo
pypy.commits at gmail.com
Mon Feb 13 09:23:57 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: space-newtext
Changeset: r90081:cb1017183c06
Date: 2017-02-13 15:21 +0100
http://bitbucket.org/pypy/pypy/changeset/cb1017183c06/
Log: Tweak the fake objspace
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -1057,6 +1057,8 @@
assert space._code_of_sys_exc_info is None
space._code_of_sys_exc_info = code
#
+ if hasattr(space, '_see_interp2app'):
+ space._see_interp2app(gateway) # only for fake/objspace.py
return fn
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -343,6 +343,11 @@
raise oefmt(space.w_AttributeError,
"generic property has no __objclass__")
+ def spacebind(self, space):
+ if hasattr(space, '_see_getsetproperty'):
+ space._see_getsetproperty(self) # only for fake/objspace.py
+ return self
+
def interp_attrproperty(name, cls, doc=None, wrapfn=None):
"NOT_RPYTHON: initialization-time only"
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -123,6 +123,9 @@
'unicode', 'complex', 'slice', 'bool', 'basestring', 'object',
'bytearray', 'buffer', 'set', 'frozenset']
+INTERP_TYPES = ['function', 'builtin_function', 'module', 'getset_descriptor',
+ 'instance', 'classobj']
+
class FakeObjSpace(ObjSpace):
is_fake_objspace = True
@@ -211,10 +214,8 @@
@not_rpython
def wrap(self, x):
if not we_are_translated():
- if isinstance(x, gateway.interp2app):
- self._see_interp2app(x)
- if isinstance(x, GetSetProperty):
- self._see_getsetproperty(x)
+ if isinstance(x, W_Root):
+ x.spacebind(self)
if isinstance(x, r_singlefloat):
self._wrap_not_rpython(x)
if isinstance(x, list):
@@ -225,6 +226,7 @@
@not_rpython
def _see_interp2app(self, interp2app):
+ """Called by GatewayCache.build()"""
activation = interp2app._code.activation
def check():
scope_w = [w_some_obj()] * NonConstant(42)
@@ -235,6 +237,7 @@
@not_rpython
def _see_getsetproperty(self, getsetproperty):
+ """Called by GetSetProperty.spacebind()"""
space = self
def checkprop():
getsetproperty.fget(getsetproperty, space, w_some_obj())
@@ -358,6 +361,7 @@
ann = t.buildannotator()
def _do_startup():
self.threadlocals.enter_thread(self)
+ W_SliceObject(w_some_obj(), w_some_obj(), w_some_obj())
ann.build_types(_do_startup, [], complete_now=False)
if func is not None:
ann.build_types(func, argtypes, complete_now=False)
@@ -418,7 +422,9 @@
@specialize.memo()
def see_typedef(space, typedef):
assert isinstance(typedef, TypeDef)
- if typedef.name not in BUILTIN_TYPES:
+ if typedef.name not in BUILTIN_TYPES and typedef.name not in INTERP_TYPES:
+ print
+ print '------ seeing typedef %r ------' % (typedef.name,)
for name, value in typedef.rawdict.items():
space.wrap(value)
diff --git a/pypy/objspace/fake/test/test_checkmodule.py b/pypy/objspace/fake/test/test_checkmodule.py
--- a/pypy/objspace/fake/test/test_checkmodule.py
+++ b/pypy/objspace/fake/test/test_checkmodule.py
@@ -19,7 +19,7 @@
space = FakeObjSpace()
assert len(space._seen_extras) == 0
assert len(check) == 0
- space.wrap(interp2app(lambda space: see()))
+ interp2app(lambda space: see()).spacebind(space)
assert len(space._seen_extras) == 1
assert len(check) == 0
space.translates()
More information about the pypy-commit
mailing list