diff -r 8ecd1a1c7dfc Doc/c-api/veryhigh.rst --- a/Doc/c-api/veryhigh.rst Sun Mar 11 19:21:07 2012 +0200 +++ b/Doc/c-api/veryhigh.rst Sun Mar 11 11:26:27 2012 -0700 @@ -147,7 +147,8 @@ Read and execute statements from a file associated with an interactive device until EOF is reached. The user will be prompted using ``sys.ps1`` and ``sys.ps2``. *filename* is decoded from the filesystem encoding - (:func:`sys.getfilesystemencoding`). Returns ``0`` at EOF. + (:func:`sys.getfilesystemencoding`). Returns ``0`` if EOF is reached, or the + return value from `PyRun_InteractiveOneFlags` if an error occurs. .. c:function:: struct _node* PyParser_SimpleParseString(const char *str, int start) diff -r 8ecd1a1c7dfc Misc/NEWS --- a/Misc/NEWS Sun Mar 11 19:21:07 2012 +0200 +++ b/Misc/NEWS Sun Mar 11 11:26:27 2012 -0700 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #8070: Make PyRun_InteractiveLoopFlags() return an error if + PyRun_InteractiveRunFlags(), rather than entering an infinite loop. + - Issue #1469629: Allow cycles through an object's __dict__ slot to be collected. (For example if ``x.__dict__ is x``). diff -r 8ecd1a1c7dfc Python/pythonrun.c --- a/Python/pythonrun.c Sun Mar 11 19:21:07 2012 +0200 +++ b/Python/pythonrun.c Sun Mar 11 11:26:27 2012 -0700 @@ -1107,10 +1107,8 @@ PRINT_TOTAL_REFS(); if (ret == E_EOF) return 0; - /* - if (ret == E_NOMEM) - return -1; - */ + else if (ret != 0) + return ret; } } @@ -1151,12 +1149,14 @@ if (fp == stdin) { /* Fetch encoding from sys.stdin */ 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 (v == NULL || v == Py_None) + enc = Py_FileSystemDefaultEncoding; + else { + oenc = _PyObject_GetAttrId(v, &PyId_encoding); + if (!oenc) + return -1; + enc = _PyUnicode_AsString(oenc); + } if (enc == NULL) return -1; }