[pypy-dev] Findings in the Cython test suite
Stefan Behnel
stefan_ml at behnel.de
Tue Apr 3 21:21:57 CEST 2012
Stefan Behnel, 02.04.2012 10:35:
> There is one major problem that accounts for the bulk of the test failures,
> somehow related to frame handling. You can tell by the huge amount of long
> traceback sequences that run into StackOverflowErrors and equivalent
> RuntimeErrors.
I found one test that, when run all by itself, triggers a RuntimeError,
boldly claiming that it reached the maximum recursion depth after a couple
of calls. There do not seem to be any frames or tracebacks involved up to
that point.
The test executes a C representation of the following code, run as a doctest:
'''
class A:
def append(self, x):
print u"appending"
return x
def test_append(L):
"""
>>> test_append(A())
"""
print L.append(1)
'''
(The background is that Cython optimistically replaces calls to
obj.append() by code that assumes that obj is a list, so this tests the
failure of that assumption)
It gives me this error:
"""
Traceback (most recent call last):
File ".../pypy/lib-python/2.7/doctest.py", line 1254, in __run
compileflags, 1) in test.globs
File "<doctest append.__test__.test_append (line 11)[1]>", line 1, in
<module>
_ = test_append(A())
File "append.pyx", line 34, in append.test_append (append.c:930)
RuntimeError: maximum recursion depth exceeded
"""
The same happens when I call it manually, i.e.
import append; append.test_append(append.A())
The basic C code that gets executed in the test_append() function is simply
PyObject* m = PyObject_GetAttrString(L, "append");
r = PyObject_CallFunctionObjArgs(m, x, NULL);
And that's where the error gets raised (returning r==NULL). Specifically,
it does not enter into the actual append() method but fails before that,
right at the call.
I put a copy of the generated C file here:
http://consulting.behnel.de/append.tgz
Could someone shed some light on this?
Stefan
More information about the pypy-dev
mailing list