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