summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2013-04-29 14:23:31 (GMT)
committerBenjamin Peterson <benjamin@python.org>2013-04-29 14:23:31 (GMT)
commit0bb83f812f2a253d478c1a4f33e4b10685c5c5db (patch)
treede8f22092a15df5319f9cab18fa934c2e97b1f69
parent5c089314efb94d3ab4ddfea9c27d408e97ec3ff2 (diff)
parentfe1b22af0a9d696918204adaaae125a9bf86c5cf (diff)
downloadcpython-0bb83f812f2a253d478c1a4f33e4b10685c5c5db.zip
cpython-0bb83f812f2a253d478c1a4f33e4b10685c5c5db.tar.gz
cpython-0bb83f812f2a253d478c1a4f33e4b10685c5c5db.tar.bz2
merge 3.3 (#17863)
-rw-r--r--Misc/NEWS3
-rw-r--r--Python/pythonrun.c17
2 files changed, 11 insertions, 9 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 1769923..431485a 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
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
index 0cd695f..b92a8bd 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1255,16 +1255,15 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
_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) {