[Python-checkins] r53418 - in python/branches/int_unification: Lib/test/test_marshal.py Modules/_csv.c Modules/_ctypes/_ctypes.c Modules/_ctypes/callproc.c Modules/_cursesmodule.c Modules/_sre.c Modules/_struct.c Modules/_tkinter.c Modules/cjkcodecs/multibytecodec.c Modules/datetimemodule.c Modules/dlmodule.c Modules/posixmodule.c Modules/socketmodule.c Modules/timemodule.c Objects/complexobject.c Objects/exceptions.c Objects/fileobject.c Objects/floatobject.c Objects/frameobject.c Objects/listobject.c Objects/longobject.c Objects/stringobject.c Objects/unicodeobject.c PC/_msi.c Python/getargs.c Python/traceback.c
guido.van.rossum
python-checkins at python.org
Sun Jan 14 01:27:10 CET 2007
Author: guido.van.rossum
Date: Sun Jan 14 01:27:01 2007
New Revision: 53418
Modified:
python/branches/int_unification/Lib/test/test_marshal.py
python/branches/int_unification/Modules/_csv.c
python/branches/int_unification/Modules/_ctypes/_ctypes.c
python/branches/int_unification/Modules/_ctypes/callproc.c
python/branches/int_unification/Modules/_cursesmodule.c
python/branches/int_unification/Modules/_sre.c
python/branches/int_unification/Modules/_struct.c
python/branches/int_unification/Modules/_tkinter.c
python/branches/int_unification/Modules/cjkcodecs/multibytecodec.c
python/branches/int_unification/Modules/datetimemodule.c
python/branches/int_unification/Modules/dlmodule.c
python/branches/int_unification/Modules/posixmodule.c
python/branches/int_unification/Modules/socketmodule.c
python/branches/int_unification/Modules/timemodule.c
python/branches/int_unification/Objects/complexobject.c
python/branches/int_unification/Objects/exceptions.c
python/branches/int_unification/Objects/fileobject.c
python/branches/int_unification/Objects/floatobject.c
python/branches/int_unification/Objects/frameobject.c
python/branches/int_unification/Objects/listobject.c
python/branches/int_unification/Objects/longobject.c
python/branches/int_unification/Objects/stringobject.c
python/branches/int_unification/Objects/unicodeobject.c
python/branches/int_unification/PC/_msi.c
python/branches/int_unification/Python/getargs.c
python/branches/int_unification/Python/traceback.c
Log:
Adam Olsen's patch SF 1619846 fixes most real bugs in the int/long branch.
Modified: python/branches/int_unification/Lib/test/test_marshal.py
==============================================================================
--- python/branches/int_unification/Lib/test/test_marshal.py (original)
+++ python/branches/int_unification/Lib/test/test_marshal.py Sun Jan 14 01:27:01 2007
@@ -204,7 +204,7 @@
def test_patch_873224(self):
self.assertRaises(Exception, marshal.loads, '0')
self.assertRaises(Exception, marshal.loads, 'f')
- self.assertRaises(Exception, marshal.loads, marshal.dumps(5L)[:-1])
+ self.assertRaises(Exception, marshal.loads, marshal.dumps(2**65L)[:-1])
def test_version_argument(self):
# Python 2.4.0 crashes for any call to marshal.dumps(x, y)
Modified: python/branches/int_unification/Modules/_csv.c
==============================================================================
--- python/branches/int_unification/Modules/_csv.c (original)
+++ python/branches/int_unification/Modules/_csv.c Sun Jan 14 01:27:01 2007
@@ -219,7 +219,7 @@
if (src == NULL)
*target = dflt;
else {
- if (!PyInt_Check(src)) {
+ if (!PyInt_CheckExact(src)) {
PyErr_Format(PyExc_TypeError,
"\"%s\" must be an integer", name);
return -1;
@@ -1410,7 +1410,7 @@
if (!PyArg_UnpackTuple(args, "field_size_limit", 0, 1, &new_limit))
return NULL;
if (new_limit != NULL) {
- if (!PyInt_Check(new_limit)) {
+ if (!PyInt_CheckExact(new_limit)) {
PyErr_Format(PyExc_TypeError,
"limit must be an integer");
return NULL;
Modified: python/branches/int_unification/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/int_unification/Modules/_ctypes/_ctypes.c (original)
+++ python/branches/int_unification/Modules/_ctypes/_ctypes.c Sun Jan 14 01:27:01 2007
@@ -991,7 +991,7 @@
return NULL;
proto = PyDict_GetItemString(typedict, "_length_"); /* Borrowed ref */
- if (!proto || !PyInt_Check(proto)) {
+ if (!proto || !PyInt_CheckExact(proto)) {
PyErr_SetString(PyExc_AttributeError,
"class must define a '_length_' attribute, "
"which must be a positive integer");
Modified: python/branches/int_unification/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/int_unification/Modules/_ctypes/callproc.c (original)
+++ python/branches/int_unification/Modules/_ctypes/callproc.c Sun Jan 14 01:27:01 2007
@@ -496,12 +496,6 @@
return 0;
}
- if (PyInt_Check(obj)) {
- pa->ffi_type = &ffi_type_sint;
- pa->value.i = PyInt_AS_LONG(obj);
- return 0;
- }
-
if (PyLong_Check(obj)) {
pa->ffi_type = &ffi_type_sint;
pa->value.i = (long)PyLong_AsUnsignedLong(obj);
Modified: python/branches/int_unification/Modules/_cursesmodule.c
==============================================================================
--- python/branches/int_unification/Modules/_cursesmodule.c (original)
+++ python/branches/int_unification/Modules/_cursesmodule.c Sun Jan 14 01:27:01 2007
@@ -193,7 +193,7 @@
static int
PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
{
- if (PyInt_Check(obj)) {
+ if (PyInt_CheckExact(obj)) {
*ch = (chtype) PyInt_AsLong(obj);
} else if(PyString_Check(obj)
&& (PyString_Size(obj) == 1)) {
@@ -2360,7 +2360,7 @@
if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL;
- if (PyInt_Check(temp))
+ if (PyInt_CheckExact(temp))
ch = (chtype) PyInt_AsLong(temp);
else if (PyString_Check(temp))
ch = (chtype) *PyString_AsString(temp);
@@ -2382,7 +2382,7 @@
if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL;
- if (PyInt_Check(temp))
+ if (PyInt_CheckExact(temp))
ch = (int) PyInt_AsLong(temp);
else if (PyString_Check(temp))
ch = (int) *PyString_AsString(temp);
Modified: python/branches/int_unification/Modules/_sre.c
==============================================================================
--- python/branches/int_unification/Modules/_sre.c (original)
+++ python/branches/int_unification/Modules/_sre.c Sun Jan 14 01:27:01 2007
@@ -2673,8 +2673,7 @@
for (i = 0; i < n; i++) {
PyObject *o = PyList_GET_ITEM(code, i);
- unsigned long value = PyInt_Check(o) ? (unsigned long)PyInt_AsLong(o)
- : PyLong_AsUnsignedLong(o);
+ unsigned long value = PyLong_AsUnsignedLong(o);
self->code[i] = (SRE_CODE) value;
if ((unsigned long) self->code[i] != value) {
PyErr_SetString(PyExc_OverflowError,
Modified: python/branches/int_unification/Modules/_struct.c
==============================================================================
--- python/branches/int_unification/Modules/_struct.c (original)
+++ python/branches/int_unification/Modules/_struct.c Sun Jan 14 01:27:01 2007
@@ -118,8 +118,6 @@
PyNumberMethods *m;
assert(v != NULL);
- if (PyInt_Check(v))
- return PyLong_FromLong(PyInt_AS_LONG(v));
if (PyLong_Check(v)) {
Py_INCREF(v);
return v;
Modified: python/branches/int_unification/Modules/_tkinter.c
==============================================================================
--- python/branches/int_unification/Modules/_tkinter.c (original)
+++ python/branches/int_unification/Modules/_tkinter.c Sun Jan 14 01:27:01 2007
@@ -913,7 +913,7 @@
PyString_GET_SIZE(value));
else if (PyBool_Check(value))
return Tcl_NewBooleanObj(PyObject_IsTrue(value));
- else if (PyInt_Check(value))
+ else if (PyInt_CheckExact(value))
return Tcl_NewLongObj(PyInt_AS_LONG(value));
else if (PyFloat_Check(value))
return Tcl_NewDoubleObj(PyFloat_AS_DOUBLE(value));
Modified: python/branches/int_unification/Modules/cjkcodecs/multibytecodec.c
==============================================================================
--- python/branches/int_unification/Modules/cjkcodecs/multibytecodec.c (original)
+++ python/branches/int_unification/Modules/cjkcodecs/multibytecodec.c Sun Jan 14 01:27:01 2007
@@ -1314,6 +1314,9 @@
return NULL;
}
+ if (size == -1 && PyErr_Occurred())
+ return NULL;
+
return mbstreamreader_iread(self, "read", size);
}
@@ -1335,6 +1338,9 @@
return NULL;
}
+ if (size == -1 && PyErr_Occurred())
+ return NULL;
+
return mbstreamreader_iread(self, "readline", size);
}
@@ -1356,6 +1362,9 @@
return NULL;
}
+ if (sizehint == -1 && PyErr_Occurred())
+ return NULL;
+
r = mbstreamreader_iread(self, "read", sizehint);
if (r == NULL)
return NULL;
Modified: python/branches/int_unification/Modules/datetimemodule.c
==============================================================================
--- python/branches/int_unification/Modules/datetimemodule.c (original)
+++ python/branches/int_unification/Modules/datetimemodule.c Sun Jan 14 01:27:01 2007
@@ -1852,10 +1852,7 @@
* lose a little info.
*/
assert(PyInt_Check(factor) || PyLong_Check(factor));
- if (PyInt_Check(factor))
- dnum = (double)PyInt_AsLong(factor);
- else
- dnum = PyLong_AsDouble(factor);
+ dnum = PyLong_AsDouble(factor);
dnum *= fracpart;
fracpart = modf(dnum, &intpart);
@@ -3828,7 +3825,7 @@
Py_DECREF(obj);
return NULL;
}
- if (PyInt_Check(p))
+ if (PyInt_CheckExact(p))
ia[i] = PyInt_AsLong(p);
else
good_timetuple = 0;
Modified: python/branches/int_unification/Modules/dlmodule.c
==============================================================================
--- python/branches/int_unification/Modules/dlmodule.c (original)
+++ python/branches/int_unification/Modules/dlmodule.c Sun Jan 14 01:27:01 2007
@@ -107,9 +107,11 @@
}
for (i = 1; i < n; i++) {
PyObject *v = PyTuple_GetItem(args, i);
- if (PyInt_Check(v))
+ if (PyInt_Check(v)) {
alist[i-1] = PyInt_AsLong(v);
- else if (PyString_Check(v))
+ if (alist[i-1] == -1 && PyErr_Occurred())
+ return NULL;
+ } else if (PyString_Check(v))
alist[i-1] = (long)PyString_AsString(v);
else if (v == Py_None)
alist[i-1] = (long) ((char *)NULL);
Modified: python/branches/int_unification/Modules/posixmodule.c
==============================================================================
--- python/branches/int_unification/Modules/posixmodule.c (original)
+++ python/branches/int_unification/Modules/posixmodule.c Sun Jan 14 01:27:01 2007
@@ -5335,32 +5335,21 @@
elem = PySequence_GetItem(groups, i);
if (!elem)
return NULL;
- if (!PyInt_Check(elem)) {
- if (!PyLong_Check(elem)) {
- PyErr_SetString(PyExc_TypeError,
- "groups must be integers");
+ if (!PyLong_Check(elem)) {
+ PyErr_SetString(PyExc_TypeError,
+ "groups must be integers");
+ Py_DECREF(elem);
+ return NULL;
+ } else {
+ unsigned long x = PyLong_AsUnsignedLong(elem);
+ if (PyErr_Occurred()) {
+ PyErr_SetString(PyExc_TypeError,
+ "group id too big");
Py_DECREF(elem);
return NULL;
- } else {
- unsigned long x = PyLong_AsUnsignedLong(elem);
- if (PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "group id too big");
- Py_DECREF(elem);
- return NULL;
- }
- grouplist[i] = x;
- /* read back the value to see if it fitted in gid_t */
- if (grouplist[i] != x) {
- PyErr_SetString(PyExc_TypeError,
- "group id too big");
- Py_DECREF(elem);
- return NULL;
- }
}
- } else {
- long x = PyInt_AsLong(elem);
grouplist[i] = x;
+ /* read back the value to see if it fitted in gid_t */
if (grouplist[i] != x) {
PyErr_SetString(PyExc_TypeError,
"group id too big");
Modified: python/branches/int_unification/Modules/socketmodule.c
==============================================================================
--- python/branches/int_unification/Modules/socketmodule.c (original)
+++ python/branches/int_unification/Modules/socketmodule.c Sun Jan 14 01:27:01 2007
@@ -3490,12 +3490,7 @@
{
unsigned long x;
- if (PyInt_Check(arg)) {
- x = PyInt_AS_LONG(arg);
- if (x == (unsigned long) -1 && PyErr_Occurred())
- return NULL;
- }
- else if (PyLong_Check(arg)) {
+ if (PyLong_Check(arg)) {
x = PyLong_AsUnsignedLong(arg);
if (x == (unsigned long) -1 && PyErr_Occurred())
return NULL;
@@ -3549,12 +3544,7 @@
{
unsigned long x;
- if (PyInt_Check(arg)) {
- x = PyInt_AS_LONG(arg);
- if (x == (unsigned long) -1 && PyErr_Occurred())
- return NULL;
- }
- else if (PyLong_Check(arg)) {
+ if (PyLong_Check(arg)) {
x = PyLong_AsUnsignedLong(arg);
if (x == (unsigned long) -1 && PyErr_Occurred())
return NULL;
@@ -3834,7 +3824,7 @@
"getaddrinfo() argument 1 must be string or None");
return NULL;
}
- if (PyInt_Check(pobj)) {
+ if (PyInt_CheckExact(pobj)) {
PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj));
pptr = pbuf;
} else if (PyString_Check(pobj)) {
Modified: python/branches/int_unification/Modules/timemodule.c
==============================================================================
--- python/branches/int_unification/Modules/timemodule.c (original)
+++ python/branches/int_unification/Modules/timemodule.c Sun Jan 14 01:27:01 2007
@@ -357,7 +357,7 @@
if (y < 1900) {
PyObject *accept = PyDict_GetItemString(moddict,
"accept2dyear");
- if (accept == NULL || !PyInt_Check(accept) ||
+ if (accept == NULL || !PyInt_CheckExact(accept) ||
PyInt_AsLong(accept) == 0) {
PyErr_SetString(PyExc_ValueError,
"year >= 1900 required");
Modified: python/branches/int_unification/Objects/complexobject.c
==============================================================================
--- python/branches/int_unification/Objects/complexobject.c (original)
+++ python/branches/int_unification/Objects/complexobject.c Sun Jan 14 01:27:01 2007
@@ -349,10 +349,6 @@
PyObject *obj = *pobj;
pc->real = pc->imag = 0.0;
- if (PyInt_Check(obj)) {
- pc->real = PyInt_AS_LONG(obj);
- return 0;
- }
if (PyLong_Check(obj)) {
pc->real = PyLong_AsDouble(obj);
if (pc->real == -1.0 && PyErr_Occurred()) {
Modified: python/branches/int_unification/Objects/exceptions.c
==============================================================================
--- python/branches/int_unification/Objects/exceptions.c (original)
+++ python/branches/int_unification/Objects/exceptions.c Sun Jan 14 01:27:01 2007
@@ -1094,7 +1094,7 @@
have_filename = (self->filename != NULL) &&
PyString_Check(self->filename);
- have_lineno = (self->lineno != NULL) && PyInt_Check(self->lineno);
+ have_lineno = (self->lineno != NULL) && PyInt_CheckExact(self->lineno);
if (!have_filename && !have_lineno)
return str;
@@ -1230,9 +1230,7 @@
return -1;
}
- if (PyInt_Check(attr)) {
- *value = PyInt_AS_LONG(attr);
- } else if (PyLong_Check(attr)) {
+ if (PyLong_Check(attr)) {
*value = PyLong_AsSsize_t(attr);
if (*value == -1 && PyErr_Occurred())
return -1;
Modified: python/branches/int_unification/Objects/fileobject.c
==============================================================================
--- python/branches/int_unification/Objects/fileobject.c (original)
+++ python/branches/int_unification/Objects/fileobject.c Sun Jan 14 01:27:01 2007
@@ -2119,7 +2119,7 @@
if (v == NULL)
PyErr_Clear();
else {
- if (PyInt_Check(v))
+ if (PyInt_CheckExact(v))
oldflag = PyInt_AsLong(v);
assert(oldflag < INT_MAX);
Py_DECREF(v);
@@ -2284,6 +2284,8 @@
return -1;
}
+ if (fd == -1 && PyErr_Occurred())
+ return -1;
if (fd < 0) {
PyErr_Format(PyExc_ValueError,
"file descriptor cannot be a negative integer (%i)",
Modified: python/branches/int_unification/Objects/floatobject.c
==============================================================================
--- python/branches/int_unification/Objects/floatobject.c (original)
+++ python/branches/int_unification/Objects/floatobject.c Sun Jan 14 01:27:01 2007
@@ -277,10 +277,7 @@
{
register PyObject *obj = *v;
- if (PyInt_Check(obj)) {
- *dbl = (double)PyInt_AS_LONG(obj);
- }
- else if (PyLong_Check(obj)) {
+ if (PyLong_Check(obj)) {
*dbl = PyLong_AsDouble(obj);
if (*dbl == -1.0 && PyErr_Occurred()) {
*v = NULL;
@@ -395,32 +392,6 @@
goto Unimplemented;
}
- else if (PyInt_Check(w)) {
- long jj = PyInt_AS_LONG(w);
- /* In the worst realistic case I can imagine, C double is a
- * Cray single with 48 bits of precision, and long has 64
- * bits.
- */
-#if SIZEOF_LONG > 6
- unsigned long abs = (unsigned long)(jj < 0 ? -jj : jj);
- if (abs >> 48) {
- /* Needs more than 48 bits. Make it take the
- * PyLong path.
- */
- PyObject *result;
- PyObject *ww = PyLong_FromLong(jj);
-
- if (ww == NULL)
- return NULL;
- result = float_richcompare(v, ww, op);
- Py_DECREF(ww);
- return result;
- }
-#endif
- j = (double)jj;
- assert((long)j == jj);
- }
-
else if (PyLong_Check(w)) {
int vsign = i == 0.0 ? 0 : i < 0.0 ? -1 : 1;
int wsign = _PyLong_Sign(w);
Modified: python/branches/int_unification/Objects/frameobject.c
==============================================================================
--- python/branches/int_unification/Objects/frameobject.c (original)
+++ python/branches/int_unification/Objects/frameobject.c Sun Jan 14 01:27:01 2007
@@ -88,7 +88,7 @@
int setup_op = 0; /* (ditto) */
/* f_lineno must be an integer. */
- if (!PyInt_Check(p_new_lineno)) {
+ if (!PyInt_CheckExact(p_new_lineno)) {
PyErr_SetString(PyExc_ValueError,
"lineno must be an integer");
return -1;
Modified: python/branches/int_unification/Objects/listobject.c
==============================================================================
--- python/branches/int_unification/Objects/listobject.c (original)
+++ python/branches/int_unification/Objects/listobject.c Sun Jan 14 01:27:01 2007
@@ -950,7 +950,7 @@
Py_DECREF(args);
if (res == NULL)
return -1;
- if (!PyInt_Check(res)) {
+ if (!PyInt_CheckExact(res)) {
Py_DECREF(res);
PyErr_SetString(PyExc_TypeError,
"comparison function must return int");
Modified: python/branches/int_unification/Objects/longobject.c
==============================================================================
--- python/branches/int_unification/Objects/longobject.c (original)
+++ python/branches/int_unification/Objects/longobject.c Sun Jan 14 01:27:01 2007
@@ -48,7 +48,7 @@
#define CHECK_SMALL_INT(ival)
#endif
-#define MEDIUM_VALUE(x) ((x)->ob_size < 0 ? -(x)->ob_digit[0] : (x)->ob_digit[0])
+#define MEDIUM_VALUE(x) ((x)->ob_size < 0 ? -(x)->ob_digit[0] : ((x)->ob_size == 0 ? 0 : (x)->ob_digit[0]))
/* If a freshly-allocated long is already shared, it must
be a small integer, so negating it must go to PyLong_FromLong */
#define NEGATE(x) \
@@ -496,8 +496,8 @@
/* Get a C unsigned long int from a long int object, ignoring the high bits.
Returns -1 and sets an error condition if an error occurs. */
-unsigned long
-PyLong_AsUnsignedLongMask(PyObject *vv)
+static unsigned long
+_PyLong_AsUnsignedLongMask(PyObject *vv)
{
register PyLongObject *v;
unsigned long x;
@@ -526,6 +526,41 @@
return x * sign;
}
+unsigned long
+PyLong_AsUnsignedLongMask(register PyObject *op)
+{
+ PyNumberMethods *nb;
+ PyLongObject *lo;
+ unsigned long val;
+
+ if (op && PyLong_Check(op))
+ return _PyLong_AsUnsignedLongMask(op);
+
+ if (op == NULL || (nb = op->ob_type->tp_as_number) == NULL ||
+ nb->nb_int == NULL) {
+ PyErr_SetString(PyExc_TypeError, "an integer is required");
+ return (unsigned long)-1;
+ }
+
+ lo = (PyLongObject*) (*nb->nb_int) (op);
+ if (lo == NULL)
+ return (unsigned long)-1;
+ if (PyLong_Check(lo)) {
+ val = _PyLong_AsUnsignedLongMask((PyObject *)lo);
+ Py_DECREF(lo);
+ if (PyErr_Occurred())
+ return (unsigned long)-1;
+ return val;
+ }
+ else
+ {
+ Py_DECREF(lo);
+ PyErr_SetString(PyExc_TypeError,
+ "nb_int should return int object");
+ return (unsigned long)-1;
+ }
+}
+
int
_PyLong_Sign(PyObject *vv)
{
@@ -912,7 +947,7 @@
/* special-case null pointer */
if (!p)
return PyInt_FromLong(0);
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)p);
+ return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)(Py_uintptr_t)p);
}
@@ -1146,8 +1181,8 @@
/* Get a C unsigned long int from a long int object, ignoring the high bits.
Returns -1 and sets an error condition if an error occurs. */
-unsigned PY_LONG_LONG
-PyLong_AsUnsignedLongLongMask(PyObject *vv)
+static unsigned PY_LONG_LONG
+_PyLong_AsUnsignedLongLongMask(PyObject *vv)
{
register PyLongObject *v;
unsigned PY_LONG_LONG x;
@@ -1175,6 +1210,41 @@
}
return x * sign;
}
+
+unsigned PY_LONG_LONG
+PyLong_AsUnsignedLongLongMask(register PyObject *op)
+{
+ PyNumberMethods *nb;
+ PyLongObject *lo;
+ unsigned PY_LONG_LONG val;
+
+ if (op && PyLong_Check(op))
+ return _PyLong_AsUnsignedLongLongMask(op);
+
+ if (op == NULL || (nb = op->ob_type->tp_as_number) == NULL ||
+ nb->nb_int == NULL) {
+ PyErr_SetString(PyExc_TypeError, "an integer is required");
+ return (unsigned PY_LONG_LONG)-1;
+ }
+
+ lo = (PyLongObject*) (*nb->nb_int) (op);
+ if (lo == NULL)
+ return (unsigned PY_LONG_LONG)-1;
+ if (PyLong_Check(lo)) {
+ val = _PyLong_AsUnsignedLongLongMask((PyObject *)lo);
+ Py_DECREF(lo);
+ if (PyErr_Occurred())
+ return (unsigned PY_LONG_LONG)-1;
+ return val;
+ }
+ else
+ {
+ Py_DECREF(lo);
+ PyErr_SetString(PyExc_TypeError,
+ "nb_int should return int object");
+ return (unsigned PY_LONG_LONG)-1;
+ }
+}
#undef IS_LITTLE_ENDIAN
#endif /* HAVE_LONG_LONG */
Modified: python/branches/int_unification/Objects/stringobject.c
==============================================================================
--- python/branches/int_unification/Objects/stringobject.c (original)
+++ python/branches/int_unification/Objects/stringobject.c Sun Jan 14 01:27:01 2007
@@ -4557,6 +4557,8 @@
goto error;
}
width = PyInt_AsLong(v);
+ if (width == -1 && PyErr_Occurred())
+ goto error;
if (width < 0) {
flags |= F_LJUST;
width = -width;
@@ -4594,6 +4596,8 @@
goto error;
}
prec = PyInt_AsLong(v);
+ if (prec == -1 && PyErr_Occurred())
+ goto error;
if (prec < 0)
prec = 0;
if (--fmtcnt >= 0)
Modified: python/branches/int_unification/Objects/unicodeobject.c
==============================================================================
--- python/branches/int_unification/Objects/unicodeobject.c (original)
+++ python/branches/int_unification/Objects/unicodeobject.c Sun Jan 14 01:27:01 2007
@@ -7566,6 +7566,8 @@
goto onError;
}
width = PyInt_AsLong(v);
+ if (width == -1 && PyErr_Occurred())
+ goto onError;
if (width < 0) {
flags |= F_LJUST;
width = -width;
@@ -7601,6 +7603,8 @@
goto onError;
}
prec = PyInt_AsLong(v);
+ if (prec == -1 && PyErr_Occurred())
+ goto onError;
if (prec < 0)
prec = 0;
if (--fmtcnt >= 0)
Modified: python/branches/int_unification/PC/_msi.c
==============================================================================
--- python/branches/int_unification/PC/_msi.c (original)
+++ python/branches/int_unification/PC/_msi.c Sun Jan 14 01:27:01 2007
@@ -543,7 +543,7 @@
if (PyString_Check(data)) {
status = MsiSummaryInfoSetProperty(si->h, field, VT_LPSTR,
0, NULL, PyString_AsString(data));
- } else if (PyInt_Check(data)) {
+ } else if (PyInt_CheckExact(data)) {
status = MsiSummaryInfoSetProperty(si->h, field, VT_I4,
PyInt_AsLong(data), NULL, NULL);
} else {
Modified: python/branches/int_unification/Python/getargs.c
==============================================================================
--- python/branches/int_unification/Python/getargs.c (original)
+++ python/branches/int_unification/Python/getargs.c Sun Jan 14 01:27:01 2007
@@ -720,9 +720,7 @@
case 'K': { /* long long sized bitfield */
unsigned PY_LONG_LONG *p = va_arg(*p_va, unsigned PY_LONG_LONG *);
unsigned PY_LONG_LONG ival;
- if (PyInt_Check(arg))
- ival = PyInt_AsUnsignedLongMask(arg);
- else if (PyLong_Check(arg))
+ if (PyLong_Check(arg))
ival = PyLong_AsUnsignedLongLongMask(arg);
else
return converterr("integer<K>", arg, msgbuf, bufsize);
Modified: python/branches/int_unification/Python/traceback.c
==============================================================================
--- python/branches/int_unification/Python/traceback.c (original)
+++ python/branches/int_unification/Python/traceback.c Sun Jan 14 01:27:01 2007
@@ -250,7 +250,7 @@
return -1;
}
limitv = PySys_GetObject("tracebacklimit");
- if (limitv && PyInt_Check(limitv)) {
+ if (limitv && PyInt_CheckExact(limitv)) {
limit = PyInt_AsLong(limitv);
if (limit <= 0)
return 0;
More information about the Python-checkins
mailing list