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