Skip to content

Commit 7b8754f

Browse files
author
jeffrey.yasskin
committed
Merged revisions 67666,67685 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r67666 | jeffrey.yasskin | 2008-12-08 10:55:24 -0800 (Mon, 08 Dec 2008) | 3 lines Issue 4597: Fix several cases in EvalFrameEx where an exception could be "raised" without setting x, err, or why to let the eval loop know. ........ r67685 | jeffrey.yasskin | 2008-12-09 23:35:02 -0800 (Tue, 09 Dec 2008) | 2 lines Update Misc/NEWS for r67666. ........ git-svn-id: http://svn.python.org/projects/python/branches/py3k@67697 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 443ce20 commit 7b8754f

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

Misc/NEWS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ What's New in Python 3.1 alpha 0
1212
Core and Builtins
1313
-----------------
1414

15-
- Issue #4597: Fixed exception handling when the __exit__ function of a
15+
- Issue #4597: Fixed several opcodes that weren't always propagating
16+
exceptions.
17+
18+
- Issue #4589: Fixed exception handling when the __exit__ function of a
1619
context manager returns a value that cannot be converted to a bool.
1720

1821
- Issue #4445: Replace "sizeof(PyBytesObject)" with

Python/ceval.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
11201120
}
11211121
Py_FatalError("invalid argument to DUP_TOPX"
11221122
" (bytecode corruption?)");
1123+
/* Never returns, so don't bother to set why. */
11231124
break;
11241125

11251126
case UNARY_POSITIVE:
@@ -1736,6 +1737,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
17361737
if ((v = f->f_locals) == NULL) {
17371738
PyErr_Format(PyExc_SystemError,
17381739
"no locals when loading %R", w);
1740+
why = WHY_EXCEPTION;
17391741
break;
17401742
}
17411743
if (PyDict_CheckExact(v)) {
@@ -2287,7 +2289,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
22872289

22882290
if (x != NULL && opcode == MAKE_CLOSURE) {
22892291
v = POP();
2290-
err = PyFunction_SetClosure(x, v);
2292+
if (PyFunction_SetClosure(x, v) != 0) {
2293+
/* Can't happen unless bytecode is corrupt. */
2294+
why = WHY_EXCEPTION;
2295+
}
22912296
Py_DECREF(v);
22922297
}
22932298

@@ -2311,7 +2316,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
23112316
Py_DECREF(w);
23122317
}
23132318

2314-
err = PyFunction_SetAnnotations(x, v);
2319+
if (PyFunction_SetAnnotations(x, v) != 0) {
2320+
/* Can't happen unless
2321+
PyFunction_SetAnnotations changes. */
2322+
why = WHY_EXCEPTION;
2323+
}
23152324
Py_DECREF(v);
23162325
Py_DECREF(u);
23172326
}
@@ -2328,7 +2337,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
23282337
w = POP();
23292338
PyTuple_SET_ITEM(v, posdefaults, w);
23302339
}
2331-
err = PyFunction_SetDefaults(x, v);
2340+
if (PyFunction_SetDefaults(x, v) != 0) {
2341+
/* Can't happen unless
2342+
PyFunction_SetDefaults changes. */
2343+
why = WHY_EXCEPTION;
2344+
}
23322345
Py_DECREF(v);
23332346
}
23342347
if (x != NULL && kwdefaults > 0) {
@@ -2346,7 +2359,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
23462359
Py_DECREF(w);
23472360
Py_DECREF(u);
23482361
}
2349-
err = PyFunction_SetKwDefaults(x, v);
2362+
if (PyFunction_SetKwDefaults(x, v) != 0) {
2363+
/* Can't happen unless
2364+
PyFunction_SetKwDefaults changes. */
2365+
why = WHY_EXCEPTION;
2366+
}
23502367
Py_DECREF(v);
23512368
}
23522369
PUSH(x);

0 commit comments

Comments
 (0)