@@ -2164,17 +2164,29 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
2164
2164
2165
2165
/* stdin is a text stream, so it must have an encoding. */
2166
2166
stdin_encoding = PyObject_GetAttr (fin , & _Py_ID (encoding ));
2167
+ if (stdin_encoding == NULL ) {
2168
+ tty = 0 ;
2169
+ goto _readline_errors ;
2170
+ }
2167
2171
stdin_errors = PyObject_GetAttr (fin , & _Py_ID (errors ));
2168
- if (!stdin_encoding || !stdin_errors ||
2169
- !PyUnicode_Check (stdin_encoding ) ||
2170
- !PyUnicode_Check (stdin_errors )) {
2172
+ if (stdin_errors == NULL ) {
2173
+ tty = 0 ;
2174
+ goto _readline_errors ;
2175
+ }
2176
+ if (!PyUnicode_Check (stdin_encoding ) ||
2177
+ !PyUnicode_Check (stdin_errors ))
2178
+ {
2171
2179
tty = 0 ;
2172
2180
goto _readline_errors ;
2173
2181
}
2174
2182
stdin_encoding_str = PyUnicode_AsUTF8 (stdin_encoding );
2183
+ if (stdin_encoding_str == NULL ) {
2184
+ goto _readline_errors ;
2185
+ }
2175
2186
stdin_errors_str = PyUnicode_AsUTF8 (stdin_errors );
2176
- if (! stdin_encoding_str || ! stdin_errors_str )
2187
+ if (stdin_errors_str == NULL ) {
2177
2188
goto _readline_errors ;
2189
+ }
2178
2190
tmp = PyObject_CallMethodNoArgs (fout , & _Py_ID (flush ));
2179
2191
if (tmp == NULL )
2180
2192
PyErr_Clear ();
@@ -2185,17 +2197,29 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
2185
2197
const char * stdout_encoding_str , * stdout_errors_str ;
2186
2198
PyObject * stringpo ;
2187
2199
stdout_encoding = PyObject_GetAttr (fout , & _Py_ID (encoding ));
2200
+ if (stdout_encoding == NULL ) {
2201
+ tty = 0 ;
2202
+ goto _readline_errors ;
2203
+ }
2188
2204
stdout_errors = PyObject_GetAttr (fout , & _Py_ID (errors ));
2189
- if (!stdout_encoding || !stdout_errors ||
2190
- !PyUnicode_Check (stdout_encoding ) ||
2191
- !PyUnicode_Check (stdout_errors )) {
2205
+ if (stdout_errors == NULL ) {
2206
+ tty = 0 ;
2207
+ goto _readline_errors ;
2208
+ }
2209
+ if (!PyUnicode_Check (stdout_encoding ) ||
2210
+ !PyUnicode_Check (stdout_errors ))
2211
+ {
2192
2212
tty = 0 ;
2193
2213
goto _readline_errors ;
2194
2214
}
2195
2215
stdout_encoding_str = PyUnicode_AsUTF8 (stdout_encoding );
2216
+ if (stdout_encoding_str == NULL ) {
2217
+ goto _readline_errors ;
2218
+ }
2196
2219
stdout_errors_str = PyUnicode_AsUTF8 (stdout_errors );
2197
- if (! stdout_encoding_str || ! stdout_errors_str )
2220
+ if (stdout_errors_str == NULL ) {
2198
2221
goto _readline_errors ;
2222
+ }
2199
2223
stringpo = PyObject_Str (prompt );
2200
2224
if (stringpo == NULL )
2201
2225
goto _readline_errors ;
0 commit comments