Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r95077:99c1daa566cf
Date: 2018-09-05 09:43 +0200
http://bitbucket.org/pypy/pypy/changeset/99c1daa566cf/

Log:    Define select.PIPE_BUF only when it exists on CPython

diff --git a/pypy/module/select/__init__.py b/pypy/module/select/__init__.py
--- a/pypy/module/select/__init__.py
+++ b/pypy/module/select/__init__.py
@@ -3,7 +3,7 @@
 
 import sys
 import os
-from select import PIPE_BUF
+import select
 
 
 class Module(MixedModule):
@@ -13,9 +13,11 @@
     interpleveldefs = {
         'select': 'interp_select.select',
         'error' : 'space.fromcache(interp_select.Cache).w_error',
-        'PIPE_BUF' : 'space.wrap(%r)' % PIPE_BUF,
     }
 
+    if hasattr(select, 'PIPE_BUF'):
+        interpleveldefs['PIPE_BUF'] = 'space.wrap(%r)' % select.PIPE_BUF
+
     if os.name =='posix':
         interpleveldefs['poll'] = 'interp_select.poll'
 
diff --git a/pypy/module/select/test/test_select.py 
b/pypy/module/select/test/test_select.py
--- a/pypy/module/select/test/test_select.py
+++ b/pypy/module/select/test/test_select.py
@@ -245,10 +245,6 @@
         raises(OverflowError, pollster.modify, 1, -1)
         raises(OverflowError, pollster.modify, 1, 1 << 64)
 
-    def test_PIPE_BUF(self):
-        import select
-        assert isinstance(select.PIPE_BUF, int)
-
 
 class AppTestSelectWithPipes(_AppTestSelect):
     "Use a pipe to get pairs of file descriptors"
@@ -322,6 +318,11 @@
         # ^^^ CPython gives 100, PyPy gives 1.  I think both are OK as
         # long as there is no crash.
 
+    def test_PIPE_BUF(self):
+        # no PIPE_BUF on Windows; this test class is skipped on Windows.
+        import select
+        assert isinstance(select.PIPE_BUF, int)
+
 
 class AppTestSelectWithSockets(_AppTestSelect):
     """Same tests with connected sockets.
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to