Author: Armin Rigo <[email protected]>
Branch: errno-again
Changeset: r75331:1180859920a4
Date: 2015-01-14 18:46 +0100
http://bitbucket.org/pypy/pypy/changeset/1180859920a4/

Log:    more fixes

diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -114,7 +114,8 @@
         ))
     def validate_fd(fd):
         if not is_valid_fd(fd):
-            raise OSError(get_errno(), 'Bad file descriptor')
+            from errno import EBADF
+            raise OSError(EBADF, 'Bad file descriptor')
 else:
     def is_valid_fd(fd):
         return 1
diff --git a/rpython/rlib/rtermios.py b/rpython/rlib/rtermios.py
--- a/rpython/rlib/rtermios.py
+++ b/rpython/rlib/rtermios.py
@@ -114,26 +114,34 @@
                            ('c_line', CC_T),
                            ('c_cc', lltype.FixedSizeArray(CC_T, NCCS)), *_add)
 
-def c_external(name, args, result):
-    return rffi.llexternal(name, args, result, compilation_info=eci)
+def c_external(name, args, result, **kwds):
+    return rffi.llexternal(name, args, result, compilation_info=eci, **kwds)
 
-c_tcgetattr = c_external('tcgetattr', [rffi.INT, TERMIOSP], rffi.INT)
-c_tcsetattr = c_external('tcsetattr', [rffi.INT, rffi.INT, TERMIOSP], rffi.INT)
+c_tcgetattr = c_external('tcgetattr', [rffi.INT, TERMIOSP], rffi.INT,
+                         save_err=rffi.RFFI_SAVE_ERRNO)
+c_tcsetattr = c_external('tcsetattr', [rffi.INT, rffi.INT, TERMIOSP], rffi.INT,
+                         save_err=rffi.RFFI_SAVE_ERRNO)
 c_cfgetispeed = c_external('cfgetispeed', [TERMIOSP], SPEED_T)
 c_cfgetospeed = c_external('cfgetospeed', [TERMIOSP], SPEED_T)
-c_cfsetispeed = c_external('cfsetispeed', [TERMIOSP, SPEED_T], rffi.INT)
-c_cfsetospeed = c_external('cfsetospeed', [TERMIOSP, SPEED_T], rffi.INT)
+c_cfsetispeed = c_external('cfsetispeed', [TERMIOSP, SPEED_T], rffi.INT,
+                           save_err=rffi.RFFI_SAVE_ERRNO)
+c_cfsetospeed = c_external('cfsetospeed', [TERMIOSP, SPEED_T], rffi.INT,
+                           save_err=rffi.RFFI_SAVE_ERRNO)
 
-c_tcsendbreak = c_external('tcsendbreak', [rffi.INT, rffi.INT], rffi.INT)
-c_tcdrain = c_external('tcdrain', [rffi.INT], rffi.INT)
-c_tcflush = c_external('tcflush', [rffi.INT, rffi.INT], rffi.INT)
-c_tcflow = c_external('tcflow', [rffi.INT, rffi.INT], rffi.INT)
+c_tcsendbreak = c_external('tcsendbreak', [rffi.INT, rffi.INT], rffi.INT,
+                           save_err=rffi.RFFI_SAVE_ERRNO)
+c_tcdrain = c_external('tcdrain', [rffi.INT], rffi.INT,
+                       save_err=rffi.RFFI_SAVE_ERRNO)
+c_tcflush = c_external('tcflush', [rffi.INT, rffi.INT], rffi.INT,
+                       save_err=rffi.RFFI_SAVE_ERRNO)
+c_tcflow = c_external('tcflow', [rffi.INT, rffi.INT], rffi.INT,
+                      save_err=rffi.RFFI_SAVE_ERRNO)
 
 
 def tcgetattr(fd):
     with lltype.scoped_alloc(TERMIOSP.TO) as c_struct:
         if c_tcgetattr(fd, c_struct) < 0:
-            raise OSError(rposix.get_errno(), 'tcgetattr failed')
+            raise OSError(rposix.get_saved_errno(), 'tcgetattr failed')
         cc = [chr(c_struct.c_c_cc[i]) for i in range(NCCS)]
         ispeed = c_cfgetispeed(c_struct)
         ospeed = c_cfgetospeed(c_struct)
@@ -157,24 +165,24 @@
         for i in range(NCCS):
             c_struct.c_c_cc[i] = rffi.r_uchar(ord(cc[i][0]))
         if c_cfsetispeed(c_struct, ispeed) < 0:
-            raise OSError(rposix.get_errno(), 'tcsetattr failed')
+            raise OSError(rposix.get_saved_errno(), 'tcsetattr failed')
         if c_cfsetospeed(c_struct, ospeed) < 0:
-            raise OSError(rposix.get_errno(), 'tcsetattr failed')
+            raise OSError(rposix.get_saved_errno(), 'tcsetattr failed')
         if c_tcsetattr(fd, when, c_struct) < 0:
-            raise OSError(rposix.get_errno(), 'tcsetattr failed')
+            raise OSError(rposix.get_saved_errno(), 'tcsetattr failed')
 
 def tcsendbreak(fd, duration):
     if c_tcsendbreak(fd, duration) < 0:
-        raise OSError(rposix.get_errno(), 'tcsendbreak failed')
+        raise OSError(rposix.get_saved_errno(), 'tcsendbreak failed')
 
 def tcdrain(fd):
     if c_tcdrain(fd) < 0:
-        raise OSError(rposix.get_errno(), 'tcdrain failed')
+        raise OSError(rposix.get_saved_errno(), 'tcdrain failed')
 
 def tcflush(fd, queue_selector):
     if c_tcflush(fd, queue_selector) < 0:
-        raise OSError(rposix.get_errno(), 'tcflush failed')
+        raise OSError(rposix.get_saved_errno(), 'tcflush failed')
 
 def tcflow(fd, action):
     if c_tcflow(fd, action) < 0:
-        raise OSError(rposix.get_errno(), 'tcflow failed')
+        raise OSError(rposix.get_saved_errno(), 'tcflow failed')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to