summaryrefslogtreecommitdiffstats
path: root/Objects/exceptions.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 /Objects/exceptions.c
parent0fbab7ff8d2efd92e222fcc13c0aff0998c3c158 (diff)
downloadcpython-d1a1d1ed802187cd1a9a8a95ac5d758c7acffee6.zip
cpython-d1a1d1ed802187cd1a9a8a95ac5d758c7acffee6.tar.gz
cpython-d1a1d1ed802187cd1a9a8a95ac5d758c7acffee6.tar.bz2
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r--Objects/exceptions.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index cbcda7b..9655733 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -929,6 +929,10 @@ SyntaxError_str(PySyntaxErrorObject *self)
{
int have_lineno = 0;
char *filename = 0;
+ /* Below, we always ignore overflow errors, just printing -1.
+ Still, we cannot allow an OverflowError to be raised, so
+ we need to call PyLong_AsLongAndOverflow. */
+ int overflow;
/* XXX -- do all the additional formatting with filename and
lineno here */
@@ -936,7 +940,7 @@ SyntaxError_str(PySyntaxErrorObject *self)
if (self->filename && PyUnicode_Check(self->filename)) {
filename = PyUnicode_AsString(self->filename);
}
- have_lineno = (self->lineno != NULL) && PyInt_CheckExact(self->lineno);
+ have_lineno = (self->lineno != NULL) && PyLong_CheckExact(self->lineno);
if (!filename && !have_lineno)
return PyObject_Str(self->msg ? self->msg : Py_None);
@@ -945,7 +949,7 @@ SyntaxError_str(PySyntaxErrorObject *self)
return PyUnicode_FromFormat("%S (%s, line %ld)",
self->msg ? self->msg : Py_None,
my_basename(filename),
- PyLong_AsLong(self->lineno));
+ PyLong_AsLongAndOverflow(self->lineno, &overflow));
else if (filename)
return PyUnicode_FromFormat("%S (%s)",
self->msg ? self->msg : Py_None,
@@ -953,7 +957,7 @@ SyntaxError_str(PySyntaxErrorObject *self)
else /* only have_lineno */
return PyUnicode_FromFormat("%S (line %ld)",
self->msg ? self->msg : Py_None,
- PyLong_AsLong(self->lineno));
+ PyLong_AsLongAndOverflow(self->lineno, &overflow));
}
static PyMemberDef SyntaxError_members[] = {