[pypy-svn] r34335 - in pypy/dist/pypy: . annotation module/_stackless/test
arigo at codespeak.net
arigo at codespeak.net
Tue Nov 7 16:32:26 CET 2006
Author: arigo
Date: Tue Nov 7 16:32:23 2006
New Revision: 34335
Modified:
pypy/dist/pypy/annotation/builtin.py
pypy/dist/pypy/conftest.py
pypy/dist/pypy/module/_stackless/test/test_composable_coroutine.py
Log:
Small fixes. Now all the app-level _stackless tests work on top of a
compiled pypy-c-stackless with py.test -A.
Modified: pypy/dist/pypy/annotation/builtin.py
==============================================================================
--- pypy/dist/pypy/annotation/builtin.py (original)
+++ pypy/dist/pypy/annotation/builtin.py Tue Nov 7 16:32:23 2006
@@ -376,8 +376,12 @@
OSError_init)
BUILTIN_ANALYZERS[sys.getdefaultencoding] = conf
-import unicodedata
-BUILTIN_ANALYZERS[unicodedata.decimal] = unicodedata_decimal # xxx
+try:
+ import unicodedata
+except ImportError:
+ pass
+else:
+ BUILTIN_ANALYZERS[unicodedata.decimal] = unicodedata_decimal # xxx
# object - just ignore object.__init__
BUILTIN_ANALYZERS[object.__init__] = object_init
Modified: pypy/dist/pypy/conftest.py
==============================================================================
--- pypy/dist/pypy/conftest.py (original)
+++ pypy/dist/pypy/conftest.py Tue Nov 7 16:32:23 2006
@@ -3,7 +3,7 @@
from pypy.interpreter.error import OperationError
from pypy.tool.pytest import appsupport
from pypy.tool.option import make_config
-from inspect import isclass
+from inspect import isclass, getmro
rootdir = py.magic.autopath().dirpath()
@@ -199,6 +199,16 @@
py.test.skip("need translated pypy with: %s, got %s"
%(ropts,options))
+def getwithoutbinding(x, name):
+ try:
+ return x.__dict__[name]
+ except (AttributeError, KeyError):
+ for cls in getmro(x.__class__):
+ if name in cls.__dict__:
+ return cls.__dict__[name]
+ # uh? not found anywhere, fall back (which might raise AttributeError)
+ return getattr(x, name)
+
class LazyObjSpaceGetter(object):
def __get__(self, obj, cls=None):
space = gettestobjspace()
@@ -280,7 +290,10 @@
for name in dir(instance):
if name.startswith('w_'):
if option.runappdirect:
- setattr(w_instance, name[2:], getattr(instance, name))
+ # if the value is a function living on the class,
+ # don't turn it into a bound method here
+ obj = getwithoutbinding(instance, name)
+ setattr(w_instance, name[2:], obj)
else:
space.setattr(w_instance, space.wrap(name[2:]),
getattr(instance, name))
Modified: pypy/dist/pypy/module/_stackless/test/test_composable_coroutine.py
==============================================================================
--- pypy/dist/pypy/module/_stackless/test/test_composable_coroutine.py (original)
+++ pypy/dist/pypy/module/_stackless/test/test_composable_coroutine.py Tue Nov 7 16:32:23 2006
@@ -54,6 +54,7 @@
g.gi_caller.switch()
generator.Yield = Yield
+ generator._costate = generators_costate
return generator
""")
@@ -96,6 +97,8 @@
import _stackless
generator = self.generator
+ # you can see how it fails if we don't have two different costates
+ # by setting compute_costate to generator._costate instead
compute_costate = _stackless.usercostate()
compute_main = compute_costate.getcurrent()
lst = []
More information about the Pypy-commit
mailing list