Author: Armin Rigo <[email protected]>
Branch:
Changeset: r64699:fe0866846c4b
Date: 2013-06-01 12:10 +0200
http://bitbucket.org/pypy/pypy/changeset/fe0866846c4b/
Log: Yay, found the source of one occasional crash we get on buildbot.
diff --git a/rpython/translator/c/test/test_genc.py
b/rpython/translator/c/test/test_genc.py
--- a/rpython/translator/c/test/test_genc.py
+++ b/rpython/translator/c/test/test_genc.py
@@ -37,7 +37,7 @@
if isinstance(v, float):
from rpython.rlib.rfloat import formatd, DTSF_ADD_DOT_0
return formatd(v, 'r', 0, DTSF_ADD_DOT_0)
- return v
+ return str(v) # always return a string, to get consistent types
def parse_longlong(a):
p0, p1 = a.split(":")
@@ -205,6 +205,28 @@
py.test.raises(Exception, f1, "world") # check that it's really typed
+def test_int_becomes_float():
+ # used to crash "very often": the long chain of mangle() calls end
+ # up converting the return value of f() from an int to a float, but
+ # if blocks are followed in random order by the annotator, it will
+ # very likely first follow the call to llrepr_out() done after the
+ # call to f(), getting an int first (and a float only later).
+ @specialize.arg(1)
+ def mangle(x, chain):
+ if chain:
+ return mangle(x, chain[1:])
+ return x - 0.5
+ def f(x):
+ if x > 10:
+ x = mangle(x, (1,1,1,1,1,1,1,1,1,1))
+ return x + 1
+
+ f1 = compile(f, [int])
+
+ assert f1(5) == 6
+ assert f1(12) == 12.5
+
+
def test_string_arg():
def f(s):
total = 0
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit