[pypy-commit] pypy test_SetFromErrnoWithFilename_NULL: Add test_SetFromErrnoWithFilename_NULL

Marc Abramowitz noreply at buildbot.pypy.org
Mon Mar 24 08:16:47 CET 2014


Author: Marc Abramowitz <marc at marc-abramowitz.com>
Branch: test_SetFromErrnoWithFilename_NULL
Changeset: r70228:322c7911932a
Date: 2014-03-24 00:12 -0700
http://bitbucket.org/pypy/pypy/changeset/322c7911932a/

Log:	Add test_SetFromErrnoWithFilename_NULL

	Tests that PyErr_SetFromErrnoWithFilename with filename == NULL
	works

diff --git a/pypy/module/cpyext/test/test_pyerrors.py b/pypy/module/cpyext/test/test_pyerrors.py
--- a/pypy/module/cpyext/test/test_pyerrors.py
+++ b/pypy/module/cpyext/test/test_pyerrors.py
@@ -215,6 +215,23 @@
         assert exc_info.value.errno == errno.EBADF
         assert exc_info.value.strerror == os.strerror(errno.EBADF)
 
+    def test_SetFromErrnoWithFilename_NULL(self):
+        import errno, os
+
+        module = self.import_extension('foo', [
+                ("set_from_errno", "METH_NOARGS",
+                 '''
+                 errno = EBADF;
+                 PyErr_SetFromErrnoWithFilename(PyExc_OSError, NULL);
+                 return NULL;
+                 '''),
+                ],
+                prologue="#include <errno.h>")
+        exc_info = raises(OSError, module.set_from_errno)
+        assert exc_info.value.filename == None
+        assert exc_info.value.errno == errno.EBADF
+        assert exc_info.value.strerror == os.strerror(errno.EBADF)
+
     def test_SetFromErrnoWithFilenameObject__PyString(self):
         import errno, os
 


More information about the pypy-commit mailing list