projects
/
python
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
84092ac
)
Issue #23571: If io.TextIOWrapper constructor fails in _Py_DisplaySourceLine(),
author
Victor Stinner
<victor.stinner@gmail.com>
Wed, 25 Mar 2015 01:25:25 +0000
(
02:25
+0100)
committer
Victor Stinner
<victor.stinner@gmail.com>
Wed, 25 Mar 2015 01:25:25 +0000
(
02:25
+0100)
close the binary file to fix a resource warning.
Python/traceback.c
patch
|
blob
|
history
diff --git
a/Python/traceback.c
b/Python/traceback.c
index c2aba522bf6c5ccf084b3f9dc5136e40711816df..2bea29e44a2a67024053bd84b3a4b07410da38fd 100644
(file)
--- a/
Python/traceback.c
+++ b/
Python/traceback.c
@@
-309,13
+309,20
@@
_Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
}
fob = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "Os", binary, encoding);
Py_DECREF(io);
- Py_DECREF(binary);
PyMem_FREE(found_encoding);
if (fob == NULL) {
PyErr_Clear();
+
+ res = _PyObject_CallMethodId(binary, &PyId_close, "");
+ Py_DECREF(binary);
+ if (res)
+ Py_DECREF(res);
+ else
+ PyErr_Clear();
return 0;
}
+ Py_DECREF(binary);
/* get the line number lineno */
for (i = 0; i < lineno; i++) {