comparison Python/pythonrun.c @ 83551:68d1ac152b5d 3.3

ignore errors when trying to fetch sys.stdin.encoding (closes #17863)
author Benjamin Peterson <benjamin@python.org>
date Mon, 29 Apr 2013 10:23:08 -0400
parents 215297665098
children 8c1385205a35 97522b189c79
comparison
equal deleted inserted replaced
83549:08ce30768003 83551:68d1ac152b5d
1235 char *ps1 = "", *ps2 = "", *enc = NULL; 1235 char *ps1 = "", *ps2 = "", *enc = NULL;
1236 int errcode = 0; 1236 int errcode = 0;
1237 _Py_IDENTIFIER(encoding); 1237 _Py_IDENTIFIER(encoding);
1238 1238
1239 if (fp == stdin) { 1239 if (fp == stdin) {
1240 /* Fetch encoding from sys.stdin */ 1240 /* Fetch encoding from sys.stdin if possible. */
1241 v = PySys_GetObject("stdin"); 1241 v = PySys_GetObject("stdin");
1242 if (v == NULL || v == Py_None) 1242 if (v && v != Py_None) {
1243 return -1; 1243 oenc = _PyObject_GetAttrId(v, &PyId_encoding);
1244 oenc = _PyObject_GetAttrId(v, &PyId_encoding); 1244 if (oenc)
1245 if (!oenc) 1245 enc = _PyUnicode_AsString(oenc);
1246 return -1; 1246 if (!enc)
1247 enc = _PyUnicode_AsString(oenc); 1247 PyErr_Clear();
1248 if (enc == NULL) 1248 }
1249 return -1;
1250 } 1249 }
1251 v = PySys_GetObject("ps1"); 1250 v = PySys_GetObject("ps1");
1252 if (v != NULL) { 1251 if (v != NULL) {
1253 v = PyObject_Str(v); 1252 v = PyObject_Str(v);
1254 if (v == NULL) 1253 if (v == NULL)