diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index 12b8e7da318..a676bc21180 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -226,6 +226,10 @@ class OtherFileTests(unittest.TestCase): except: pass + def testInvalidInit(self): + self.assertRaises(TypeError, _fileio._FileIO, "1", 0, 0) + + def test_main(): # Historically, these tests have been sloppy about removing TESTFN. # So get rid of it no matter what. diff --git a/Modules/_fileio.c b/Modules/_fileio.c index ec123e891e8..81ca20227d1 100644 --- a/Modules/_fileio.c +++ b/Modules/_fileio.c @@ -175,7 +175,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) kwlist, Py_FileSystemDefaultEncoding, &name, &mode, &closefd)) - goto error; + return -1; } }