Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6f5d3f32
Commit
6f5d3f32
authored
Dec 10, 2008
by
Jeffrey Yasskin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport issue 4597 to python 2.5.3: Fixed several opcodes that weren't always
propagating exceptions.
parent
6f63190d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
+31
-3
Lib/test/test_file.py
Lib/test/test_file.py
+14
-0
Misc/NEWS
Misc/NEWS
+3
-0
Python/ceval.c
Python/ceval.c
+14
-3
No files found.
Lib/test/test_file.py
View file @
6f5d3f32
...
@@ -341,6 +341,20 @@ class StdoutTests(unittest.TestCase):
...
@@ -341,6 +341,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
,
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.
...
...
Misc/NEWS
View file @
6f5d3f32
...
@@ -12,6 +12,9 @@ What's New in Python 2.5.3?
...
@@ -12,6 +12,9 @@ What's New in Python 2.5.3?
Core and builtins
Core and builtins
-----------------
-----------------
- Issue #4597: Fixed several opcodes that weren'
t
always
propagating
exceptions
.
-
Issue
#
4589
:
Propagated
an
exception
thrown
by
a
context
manager
's
-
Issue
#
4589
:
Propagated
an
exception
thrown
by
a
context
manager
's
__exit__ method'
s
result
while
it
's being converted to bool.
__exit__ method'
s
result
while
it
's being converted to bool.
...
...
Python/ceval.c
View file @
6f5d3f32
...
@@ -1025,6 +1025,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -1025,6 +1025,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
:
...
@@ -1618,9 +1619,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -1618,9 +1619,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
)
{
Py_INCREF
(
w
);
Py_INCREF
(
w
);
...
@@ -1837,6 +1840,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -1837,6 +1840,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
))
{
...
@@ -2381,7 +2385,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -2381,7 +2385,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
)
{
...
@@ -2395,7 +2402,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -2395,7 +2402,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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment