mirror of
https://github.com/python/cpython.git
synced 2025-09-25 01:43:11 +00:00
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. ........
This commit is contained in:
parent
79c9f76629
commit
6961498040
3 changed files with 32 additions and 4 deletions
|
@ -531,6 +531,20 @@ class StdoutTests(unittest.TestCase):
|
||||||
finally:
|
finally:
|
||||||
sys.stdout = save_stdout
|
sys.stdout = save_stdout
|
||||||
|
|
||||||
|
def test_del_stdout_before_print(self):
|
||||||
|
# Issue 4597: 'print' with no argument wasn't reporting when
|
||||||
|
# sys.stdout was deleted.
|
||||||
|
save_stdout = sys.stdout
|
||||||
|
del sys.stdout
|
||||||
|
try:
|
||||||
|
print
|
||||||
|
except RuntimeError as e:
|
||||||
|
self.assertEquals(str(e), "lost sys.stdout")
|
||||||
|
else:
|
||||||
|
self.fail("Expected RuntimeError")
|
||||||
|
finally:
|
||||||
|
sys.stdout = save_stdout
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
# Historically, these tests have been sloppy about removing TESTFN.
|
# Historically, these tests have been sloppy about removing TESTFN.
|
||||||
|
|
|
@ -12,7 +12,10 @@ What's New in Python 2.6.2
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
- Issue #4597: Fixed exception handling when the __exit__ function of a
|
- Issue #4597: Fixed several opcodes that weren't always propagating
|
||||||
|
exceptions.
|
||||||
|
|
||||||
|
- Issue #4589: Fixed exception handling when the __exit__ function of a
|
||||||
context manager returns a value that cannot be converted to a bool.
|
context manager returns a value that cannot be converted to a bool.
|
||||||
|
|
||||||
- Issue #4233: Changed semantic of ``_fileio.FileIO``'s ``close()``
|
- Issue #4233: Changed semantic of ``_fileio.FileIO``'s ``close()``
|
||||||
|
|
|
@ -1041,6 +1041,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
||||||
}
|
}
|
||||||
Py_FatalError("invalid argument to DUP_TOPX"
|
Py_FatalError("invalid argument to DUP_TOPX"
|
||||||
" (bytecode corruption?)");
|
" (bytecode corruption?)");
|
||||||
|
/* Never returns, so don't bother to set why. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UNARY_POSITIVE:
|
case UNARY_POSITIVE:
|
||||||
|
@ -1634,9 +1635,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
||||||
case PRINT_NEWLINE:
|
case PRINT_NEWLINE:
|
||||||
if (stream == NULL || stream == Py_None) {
|
if (stream == NULL || stream == Py_None) {
|
||||||
w = PySys_GetObject("stdout");
|
w = PySys_GetObject("stdout");
|
||||||
if (w == NULL)
|
if (w == NULL) {
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"lost sys.stdout");
|
"lost sys.stdout");
|
||||||
|
why = WHY_EXCEPTION;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (w != NULL) {
|
if (w != NULL) {
|
||||||
/* w.write() may replace sys.stdout, so we
|
/* w.write() may replace sys.stdout, so we
|
||||||
|
@ -1862,6 +1865,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
||||||
PyErr_Format(PyExc_SystemError,
|
PyErr_Format(PyExc_SystemError,
|
||||||
"no locals when loading %s",
|
"no locals when loading %s",
|
||||||
PyObject_REPR(w));
|
PyObject_REPR(w));
|
||||||
|
why = WHY_EXCEPTION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (PyDict_CheckExact(v)) {
|
if (PyDict_CheckExact(v)) {
|
||||||
|
@ -2458,7 +2462,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
if (x != NULL) {
|
if (x != NULL) {
|
||||||
v = POP();
|
v = POP();
|
||||||
err = PyFunction_SetClosure(x, v);
|
if (PyFunction_SetClosure(x, v) != 0) {
|
||||||
|
/* Can't happen unless bytecode is corrupt. */
|
||||||
|
why = WHY_EXCEPTION;
|
||||||
|
}
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
}
|
}
|
||||||
if (x != NULL && oparg > 0) {
|
if (x != NULL && oparg > 0) {
|
||||||
|
@ -2472,7 +2479,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
||||||
w = POP();
|
w = POP();
|
||||||
PyTuple_SET_ITEM(v, oparg, w);
|
PyTuple_SET_ITEM(v, oparg, w);
|
||||||
}
|
}
|
||||||
err = PyFunction_SetDefaults(x, v);
|
if (PyFunction_SetDefaults(x, v) != 0) {
|
||||||
|
/* Can't happen unless
|
||||||
|
PyFunction_SetDefaults changes. */
|
||||||
|
why = WHY_EXCEPTION;
|
||||||
|
}
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
}
|
}
|
||||||
PUSH(x);
|
PUSH(x);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue