[Python-checkins] cpython (3.3): ignore errors when trying to fetch sys.stdin.encoding (closes #17863)
benjamin.peterson
python-checkins at python.org
Mon Apr 29 16:23:40 CEST 2013
http://hg.python.org/cpython/rev/68d1ac152b5d
changeset: 83551:68d1ac152b5d
branch: 3.3
parent: 83549:08ce30768003
user: Benjamin Peterson <benjamin at python.org>
date: Mon Apr 29 10:23:08 2013 -0400
summary:
ignore errors when trying to fetch sys.stdin.encoding (closes #17863)
files:
Misc/NEWS | 3 +++
Python/pythonrun.c | 17 ++++++++---------
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@
Core and Builtins
-----------------
+- Issue #17863: In the interactive console, don't loop forever if the encoding
+ can't be fetched from stdin.
+
- Issue #17867: Raise an ImportError if __import__ is not found in __builtins__.
- Issue #17857: Prevent build failures with pre-3.5.0 versions of sqlite3,
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1237,16 +1237,15 @@
_Py_IDENTIFIER(encoding);
if (fp == stdin) {
- /* Fetch encoding from sys.stdin */
+ /* Fetch encoding from sys.stdin if possible. */
v = PySys_GetObject("stdin");
- if (v == NULL || v == Py_None)
- return -1;
- oenc = _PyObject_GetAttrId(v, &PyId_encoding);
- if (!oenc)
- return -1;
- enc = _PyUnicode_AsString(oenc);
- if (enc == NULL)
- return -1;
+ if (v && v != Py_None) {
+ oenc = _PyObject_GetAttrId(v, &PyId_encoding);
+ if (oenc)
+ enc = _PyUnicode_AsString(oenc);
+ if (!enc)
+ PyErr_Clear();
+ }
}
v = PySys_GetObject("ps1");
if (v != NULL) {
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list