Author: mattip <[email protected]>
Branch: 
Changeset: r55554:fa1ecb3a52df
Date: 2012-06-10 23:49 +0300
http://bitbucket.org/pypy/pypy/changeset/fa1ecb3a52df/

Log:    test, fix: os.isatty should not raise in windows

diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -1362,7 +1362,8 @@
         os_isatty = self.llexternal(underscore_on_windows+'isatty', 
[rffi.INT], rffi.INT)
 
         def isatty_llimpl(fd):
-            rposix.validate_fd(fd)
+            if not rposix.is_valid_fd(fd):
+                return False
             res = rffi.cast(lltype.Signed, os_isatty(rffi.cast(rffi.INT, fd)))
             return res != 0
 
diff --git a/pypy/rpython/module/test/test_ll_os.py 
b/pypy/rpython/module/test/test_ll_os.py
--- a/pypy/rpython/module/test/test_ll_os.py
+++ b/pypy/rpython/module/test/test_ll_os.py
@@ -268,6 +268,14 @@
     expected = -signal.SIGTERM
     assert proc.wait() == expected
 
+def test_isatty():
+    try:
+        f = getllimpl(os.isatty)
+    except:
+        skip('No isatty in os')
+    assert f(-1)  == False
+
+
 class ExpectTestOs:
     def setup_class(cls):
         if not hasattr(os, 'ttyname'):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to