[Python-checkins] cpython (merge 3.5 -> default): Issue #25221: merge from 3.5.

mark.dickinson python-checkins at python.org
Sat Sep 10 15:20:20 EDT 2016


https://hg.python.org/cpython/rev/c7b48798dbaa
changeset:   103579:c7b48798dbaa
parent:      103577:b9bb77dd71b3
parent:      103578:9eb0f7762999
user:        Mark Dickinson <dickinsm at gmail.com>
date:        Sat Sep 10 20:20:08 2016 +0100
summary:
  Issue #25221: merge from 3.5.

files:
  Misc/NEWS            |  3 +++
  Objects/longobject.c |  3 ++-
  2 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #25221: Fix corrupted result from PyLong_FromLong(0) when Python
+  is compiled with NSMALLPOSINTS = 0.
+
 - Issue #27080: Implement formatting support for PEP 515.  Initial patch
   by Chris Angelico.
 
diff --git a/Objects/longobject.c b/Objects/longobject.c
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -234,7 +234,7 @@
     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 @@
     }
     else {
         abs_ival = (unsigned long)ival;
+        sign = ival == 0 ? 0 : 1;
     }
 
     /* Fast path for single-digit ints */

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list