diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2016-09-10 19:17:36 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2016-09-10 19:17:36 (GMT) |
commit | 36820dd5a90724f68d4677e6eede29995541463c (patch) | |
tree | d94150b390eb3036c6fcdbe908d50a29f93768ee /Objects | |
parent | f028d9f71a5367df6062388166ebddfa2fe4e5e1 (diff) | |
download | cpython-36820dd5a90724f68d4677e6eede29995541463c.zip cpython-36820dd5a90724f68d4677e6eede29995541463c.tar.gz cpython-36820dd5a90724f68d4677e6eede29995541463c.tar.bz2 |
Issue #25221: Fix corrupted result from PyLong_FromLong(0) when Python is compiled with NSMALLPOSINTS = 0.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/longobject.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 9b62d92..0cc850e 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -234,7 +234,7 @@ PyLong_FromLong(long ival) unsigned long abs_ival; unsigned long t; /* unsigned so >> doesn't propagate sign bit */ int ndigits = 0; - int sign = 1; + int sign; CHECK_SMALL_INT(ival); @@ -246,6 +246,7 @@ PyLong_FromLong(long ival) } else { abs_ival = (unsigned long)ival; + sign = ival == 0 ? 0 : 1; } /* Fast path for single-digit ints */ |