Author: Maciej Fijalkowski <fij...@gmail.com>
Branch: 
Changeset: r75894:3e90693d2d35
Date: 2015-02-15 12:52 +0200
http://bitbucket.org/pypy/pypy/changeset/3e90693d2d35/

Log:    Merged in jstasiak/pypy/fix-kqueue-error2 (pull request #305)

        Fix exception being raised by kqueue.control (CPython compatibility)

diff --git a/lib-python/2.7/test/test_kqueue.py 
b/lib-python/2.7/test/test_kqueue.py
--- a/lib-python/2.7/test/test_kqueue.py
+++ b/lib-python/2.7/test/test_kqueue.py
@@ -205,6 +205,17 @@
         b.close()
         kq.close()
 
+    def test_control_raises_oserror(self):
+        kq = select.kqueue()
+        event = select.kevent(123456, select.KQ_FILTER_READ, 
select.KQ_EV_DELETE)
+        with self.assertRaises(OSError) as cm:
+            kq.control([event], 0, 0)
+
+        self.assertEqual(cm.exception.args[0], errno.EBADF)
+        self.assertEqual(cm.exception.errno, errno.EBADF)
+
+        kq.close()
+
 def test_main():
     test_support.run_unittest(TestKQueue)
 
diff --git a/pypy/module/select/interp_kqueue.py 
b/pypy/module/select/interp_kqueue.py
--- a/pypy/module/select/interp_kqueue.py
+++ b/pypy/module/select/interp_kqueue.py
@@ -201,7 +201,7 @@
                                           max_events,
                                           ptimeout)
                     if nfds < 0:
-                        raise exception_from_saved_errno(space, 
space.w_IOError)
+                        raise exception_from_saved_errno(space, 
space.w_OSError)
                     else:
                         elist_w = [None] * nfds
                         for i in xrange(nfds):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to