summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-05-23 00:06:51 (GMT)
committerGuido van Rossum <guido@python.org>1997-05-23 00:06:51 (GMT)
commitc8b6df90045a3f419e6fab272d93ad4159e54ccc (patch)
tree20cb4b6f0ba2718577079198780d5fc3852e4a70 /Python
parent5b2121b25fc6a50fe229fe25ef6be8a2f883d1f4 (diff)
downloadcpython-c8b6df90045a3f419e6fab272d93ad4159e54ccc.zip
cpython-c8b6df90045a3f419e6fab272d93ad4159e54ccc.tar.gz
cpython-c8b6df90045a3f419e6fab272d93ad4159e54ccc.tar.bz2
PyObject_Compare can raise an exception now.
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c18
-rw-r--r--Python/ceval.c7
-rw-r--r--Python/compile.c3
3 files changed, 23 insertions, 5 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 4029e1b..245d31e 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -245,10 +245,14 @@ builtin_cmp(self, args)
PyObject *args;
{
PyObject *a, *b;
+ long c;
if (!PyArg_ParseTuple(args, "OO:cmp", &a, &b))
return NULL;
- return PyInt_FromLong((long)PyObject_Compare(a, b));
+ c = PyObject_Compare(a, b);
+ if (c && PyErr_Occurred())
+ return NULL;
+ return PyInt_FromLong(c);
}
static PyObject *
@@ -1073,7 +1077,13 @@ min_max(args, sign)
if (w == NULL)
w = x;
else {
- if (PyObject_Compare(x, w) * sign > 0) {
+ int c = PyObject_Compare(x, w);
+ if (c && PyErr_Occurred()) {
+ Py_DECREF(x);
+ Py_XDECREF(w);
+ return NULL;
+ }
+ if (c * sign > 0) {
Py_DECREF(w);
w = x;
}
@@ -1360,8 +1370,8 @@ builtin_raw_input(self, args)
PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
return NULL;
}
- Py_FlushLine();
- if (PyFile_WriteObject(v, f, Py_PRINT_RAW) != 0)
+ if (Py_FlushLine() != 0 ||
+ PyFile_WriteObject(v, f, Py_PRINT_RAW) != 0)
return NULL;
}
f = PySys_GetObject("stdin");
diff --git a/Python/ceval.c b/Python/ceval.c
index 7897006..bd312b2 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -456,6 +456,9 @@ eval_code2(co, globals, locals,
if (PyObject_Compare(keyword, nm) == 0)
break;
}
+ /* Check errors from Compare */
+ if (PyErr_Occurred())
+ goto fail;
if (j >= co->co_argcount) {
if (kwdict == NULL) {
PyErr_Format(PyExc_TypeError,
@@ -2475,6 +2478,8 @@ cmp_member(v, w)
Py_XDECREF(x);
if (cmp == 0)
return 1;
+ if (PyErr_Occurred())
+ return -1;
}
return 0;
}
@@ -2507,6 +2512,8 @@ cmp_outcome(op, v, w)
break;
default:
cmp = PyObject_Compare(v, w);
+ if (cmp && PyErr_Occurred())
+ return NULL;
switch (op) {
case LT: res = cmp < 0; break;
case LE: res = cmp <= 0; break;
diff --git a/Python/compile.c b/Python/compile.c
index 155142a..36304e3 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -666,7 +666,8 @@ com_add(c, list, v)
if (v->ob_type == w->ob_type && PyObject_Compare(v, w) == 0)
return i;
}
- if (PyList_Append(list, v) != 0)
+ /* Check for error from PyObject_Compare */
+ if (PyErr_Occurred() || PyList_Append(list, v) != 0)
c->c_errors++;
return n;
}