summaryrefslogtreecommitdiffstats
path: root/Modules/_tkinter.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-12-04 22:10:37 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2007-12-04 22:10:37 (GMT)
commitd1a1d1ed802187cd1a9a8a95ac5d758c7acffee6 (patch)
tree17489e6ea4df32ba3b3bbda6e4b31155a460f265 /Modules/_tkinter.c
parent0fbab7ff8d2efd92e222fcc13c0aff0998c3c158 (diff)
downloadcpython-d1a1d1ed802187cd1a9a8a95ac5d758c7acffee6.zip
cpython-d1a1d1ed802187cd1a9a8a95ac5d758c7acffee6.tar.gz
cpython-d1a1d1ed802187cd1a9a8a95ac5d758c7acffee6.tar.bz2
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Diffstat (limited to 'Modules/_tkinter.c')
-rw-r--r--Modules/_tkinter.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index c755f89..2a341ab 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -863,14 +863,21 @@ static Tcl_Obj*
AsObj(PyObject *value)
{
Tcl_Obj *result;
+ long longVal;
+ int overflow;
if (PyString_Check(value))
return Tcl_NewStringObj(PyString_AS_STRING(value),
PyString_GET_SIZE(value));
else if (PyBool_Check(value))
return Tcl_NewBooleanObj(PyObject_IsTrue(value));
- else if (PyInt_CheckExact(value))
- return Tcl_NewLongObj(PyLong_AS_LONG(value));
+ else if (PyLong_CheckExact(value) &&
+ ((longVal = PyLong_AsLongAndOverflow(value, &overflow)),
+ !overflow)) {
+ /* If there is an overflow in the long conversion,
+ fall through to default object handling. */
+ return Tcl_NewLongObj(longVal);
+ }
else if (PyFloat_Check(value))
return Tcl_NewDoubleObj(PyFloat_AS_DOUBLE(value));
else if (PyTuple_Check(value)) {