diff options
Diffstat (limited to 'Objects/intobject.c')
-rw-r--r-- | Objects/intobject.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c index b97e2bc..47acbff 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -278,7 +278,6 @@ PyInt_FromString(char *s, char **pend, int base) char *end; long x; char buffer[256]; /* For errors */ - int warn = 0; if ((base != 0 && base < 2) || base > 36) { PyErr_SetString(PyExc_ValueError, @@ -292,7 +291,7 @@ PyInt_FromString(char *s, char **pend, int base) if (base == 0 && s[0] == '0') { x = (long) PyOS_strtoul(s, &end, base); if (x < 0) - warn = 1; + return PyLong_FromString(s, pend, base); } else x = PyOS_strtol(s, &end, base); @@ -312,11 +311,6 @@ PyInt_FromString(char *s, char **pend, int base) return NULL; return PyLong_FromString(s, pend, base); } - if (warn) { - if (PyErr_Warn(PyExc_FutureWarning, - "int('0...', 0): sign will change in Python 2.4") < 0) - return NULL; - } if (pend) *pend = end; return PyInt_FromLong(x); @@ -766,18 +760,13 @@ int_lshift(PyIntObject *v, PyIntObject *w) if (a == 0 || b == 0) return int_pos(v); if (b >= LONG_BIT) { - if (PyErr_Warn(PyExc_FutureWarning, - "x<<y losing bits or changing sign " - "will return a long in Python 2.4 and up") < 0) - return NULL; - return PyInt_FromLong(0L); + return PyNumber_Lshift(PyLong_FromLong(PyInt_AS_LONG(v)), + PyLong_FromLong(PyInt_AS_LONG(w))); } c = a << b; if (a != Py_ARITHMETIC_RIGHT_SHIFT(long, c, b)) { - if (PyErr_Warn(PyExc_FutureWarning, - "x<<y losing bits or changing sign " - "will return a long in Python 2.4 and up") < 0) - return NULL; + return PyNumber_Lshift(PyLong_FromLong(PyInt_AS_LONG(v)), + PyLong_FromLong(PyInt_AS_LONG(w))); } return PyInt_FromLong(c); } @@ -868,13 +857,9 @@ int_oct(PyIntObject *v) { char buf[100]; long x = v -> ob_ival; - if (x < 0) { - if (PyErr_Warn(PyExc_FutureWarning, - "hex()/oct() of negative int will return " - "a signed string in Python 2.4 and up") < 0) - return NULL; - } - if (x == 0) + if (x < 0) + PyOS_snprintf(buf, sizeof(buf), "-0%lo", -x); + else if (x == 0) strcpy(buf, "0"); else PyOS_snprintf(buf, sizeof(buf), "0%lo", x); @@ -886,13 +871,10 @@ int_hex(PyIntObject *v) { char buf[100]; long x = v -> ob_ival; - if (x < 0) { - if (PyErr_Warn(PyExc_FutureWarning, - "hex()/oct() of negative int will return " - "a signed string in Python 2.4 and up") < 0) - return NULL; - } - PyOS_snprintf(buf, sizeof(buf), "0x%lx", x); + if (x < 0) + PyOS_snprintf(buf, sizeof(buf), "-0x%lx", -x); + else + PyOS_snprintf(buf, sizeof(buf), "0x%lx", x); return PyString_FromString(buf); } |