[pypy-svn] r69236 - in pypy/branch/faster-raise/pypy/objspace/std: . test
fijal at codespeak.net
fijal at codespeak.net
Thu Nov 12 18:52:28 CET 2009
Author: fijal
Date: Thu Nov 12 18:52:28 2009
New Revision: 69236
Modified:
pypy/branch/faster-raise/pypy/objspace/std/test/test_proxy_internals.py
pypy/branch/faster-raise/pypy/objspace/std/transparent.py
Log:
(arigo, pedronis, fijal)
Make sure we don't get None out of __pypy__.tproxy, test it
Modified: pypy/branch/faster-raise/pypy/objspace/std/test/test_proxy_internals.py
==============================================================================
--- pypy/branch/faster-raise/pypy/objspace/std/test/test_proxy_internals.py (original)
+++ pypy/branch/faster-raise/pypy/objspace/std/test/test_proxy_internals.py Thu Nov 12 18:52:28 2009
@@ -1,7 +1,8 @@
""" test proxy internals like code, traceback, frame
"""
-from pypy.conftest import gettestobjspace
+import py
+from pypy.conftest import gettestobjspace, option
class AppProxy(object):
def setup_class(cls):
@@ -21,6 +22,28 @@
return get_proxy
""")
+class AppTestProxyInterpOnly(AppProxy):
+ def setup_class(cls):
+ if option.runappdirect:
+ py.test.skip("interp only test")
+ from pypy.interpreter.typedef import TypeDef, interp2app
+ from pypy.interpreter.baseobjspace import Wrappable
+
+ class W_Stuff(Wrappable):
+ pass
+
+ def descr_new(space, w_subtype):
+ return W_Stuff()
+
+ W_Stuff.typedef = TypeDef(
+ 'Stuff',
+ __new__ = interp2app(descr_new),
+ )
+ cls.w_Stuff = cls.space.gettypefor(W_Stuff)
+
+ def test_unproxyable(self):
+ raises(TypeError, self.get_proxy, self.Stuff())
+
class AppTestProxyInternals(AppProxy):
def test_traceback_basic(self):
try:
@@ -31,7 +54,7 @@
tb = self.get_proxy(e[2])
assert tb.tb_frame is e[2].tb_frame
-
+
def test_traceback_catch(self):
try:
try:
Modified: pypy/branch/faster-raise/pypy/objspace/std/transparent.py
==============================================================================
--- pypy/branch/faster-raise/pypy/objspace/std/transparent.py (original)
+++ pypy/branch/faster-raise/pypy/objspace/std/transparent.py Thu Nov 12 18:52:28 2009
@@ -26,7 +26,6 @@
completely controlled by the controller."""
from pypy.interpreter.typedef import Function, PyTraceback, PyFrame, \
PyCode, GeneratorIterator
-
if not space.is_true(space.callable(w_controller)):
raise OperationError(space.w_TypeError, space.wrap("controller should be function"))
@@ -49,14 +48,12 @@
return W_Transparent(space, w_type, w_controller)
else:
raise OperationError(space.w_TypeError, space.wrap("type expected as first argument"))
- try:
- w_lookup = w_type or w_type.w_besttype
- for k, v in type_cache.cache:
- if w_lookup == k:
- return v(space, w_type, w_controller)
- except KeyError:
- raise OperationError(space.w_TypeError, space.wrap("Object type %s could not "\
- "be wrapped (YET)" % w_type.getname(space, "?")))
+ w_lookup = w_type
+ for k, v in type_cache.cache:
+ if w_lookup == k:
+ return v(space, w_type, w_controller)
+ raise OperationError(space.w_TypeError, space.wrap("Object type %s could not "\
+ "be wrapped (YET)" % w_type.getname(space, "?")))
def register_proxyable(space, cls):
tpdef = cls.typedef
More information about the Pypy-commit
mailing list