Yaroslav Halchenko schrieb am 21.09.2015 um 16:26:
> was reported in Debian against 0.23.2 so tried blindly freshier snapshot
> from 0.23.x branch and that one is no go too:
>
> ======================================================================
> FAIL: large_nums (line 95) (ct_DEF.__test__)
> Doctest: ct_DEF.__test__.large_nums (line 95)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/usr/lib/python2.7/doctest.py", line 2226, in runTest
> raise self.failureException(self.format_failure(new.getvalue()))
> AssertionError: Failed doctest test for ct_DEF.__test__.large_nums (line 95)
> File
> "/tmp/buildd/cython-0.23.2+git12-g2c9d175/build/work-dir/run/cpp/ct_DEF/ct_DEF.so",
> line unknown line number, in large_nums (line 95)
>
> ----------------------------------------------------------------------
> File
> "/tmp/buildd/cython-0.23.2+git12-g2c9d175/build/work-dir/run/cpp/ct_DEF/ct_DEF.so",
> line ?, in ct_DEF.__test__.large_nums (line 95)
> Failed example:
> print_large_number(n64)
> Expected:
> -4294967295
> Got:
> 1
I cannot reproduce this locally (even tried a 32bit docker container), so I
blindly changed a couple of minor things in that branch. Could you give it
another try?
If that didn't help, here is a patch that adds a longness suffix to plain
integer literals based on their type (e.g. found after coercions). I'm not
sure yet if that's really a good idea, but would be helpful to know if it
fixes this test. Could you try both and report back?
Thanks!
Stefan
diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py
index 2984215..230cf47 100644
--- a/Cython/Compiler/ExprNodes.py
+++ b/Cython/Compiler/ExprNodes.py
@@ -1238,7 +1238,15 @@ class IntNode(ConstNode):
self.result_code = self.get_constant_c_result_code()
def get_constant_c_result_code(self):
- return self.value_as_c_integer_string() + self.unsigned + self.longness
+ unsigned, longness = self.unsigned, self.longness
+ literal = self.value_as_c_integer_string()
+ if not (unsigned or longness) and self.type.is_int and literal[0] == '-' and literal[1] != '0':
+ # negative decimal literal => guess longness from type to prevent wrap-around
+ if self.type.rank >= PyrexTypes.c_longlong_type.rank:
+ longness = 'LL'
+ elif self.type.rank >= PyrexTypes.c_long_type.rank:
+ longness = 'L'
+ return literal + unsigned + longness
def value_as_c_integer_string(self):
value = self.value
_______________________________________________
cython-devel mailing list
[email protected]
https://mail.python.org/mailman/listinfo/cython-devel