@@ -248,8 +248,8 @@ _io_open_impl(PyModuleDef *module, PyObject *file, const char *mode,
248248 _Py_IDENTIFIER (close );
249249
250250 if (!PyUnicode_Check (file ) &&
251- !PyBytes_Check (file ) &&
252- !PyNumber_Check (file )) {
251+ !PyBytes_Check (file ) &&
252+ !PyNumber_Check (file )) {
253253 PyErr_Format (PyExc_TypeError , "invalid file: %R" , file );
254254 return NULL ;
255255 }
@@ -307,9 +307,9 @@ _io_open_impl(PyModuleDef *module, PyObject *file, const char *mode,
307307
308308 /* Parameters validation */
309309 if (universal ) {
310- if (writing || appending ) {
310+ if (creating || writing || appending || updating ) {
311311 PyErr_SetString (PyExc_ValueError ,
312- "can't use U and writing mode at once " );
312+ "mode U cannot be combined with x', 'w', 'a', or '+' " );
313313 return NULL ;
314314 }
315315 if (PyErr_WarnEx (PyExc_DeprecationWarning ,
@@ -437,10 +437,10 @@ _io_open_impl(PyModuleDef *module, PyObject *file, const char *mode,
437437
438438 /* wraps into a TextIOWrapper */
439439 wrapper = PyObject_CallFunction ((PyObject * )& PyTextIOWrapper_Type ,
440- "Osssi" ,
441- buffer ,
442- encoding , errors , newline ,
443- line_buffering );
440+ "Osssi" ,
441+ buffer ,
442+ encoding , errors , newline ,
443+ line_buffering );
444444 if (wrapper == NULL )
445445 goto error ;
446446 result = wrapper ;
0 commit comments