mirror of
https://github.com/python/cpython.git
synced 2025-07-10 04:45:36 +00:00
ignore errors when trying to fetch sys.stdin.encoding (closes #17863)
This commit is contained in:
parent
7d110042c5
commit
fe1b22af0a
2 changed files with 11 additions and 9 deletions
|
@ -1237,16 +1237,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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue