Author: Armin Rigo <ar...@tunes.org>
Branch: errno-again
Changeset: r75328:24f8ef4e0443
Date: 2015-01-14 18:26 +0100
http://bitbucket.org/pypy/pypy/changeset/24f8ef4e0443/

Log:    in-progress

diff --git a/rpython/memory/gc/inspector.py b/rpython/memory/gc/inspector.py
--- a/rpython/memory/gc/inspector.py
+++ b/rpython/memory/gc/inspector.py
@@ -130,7 +130,8 @@
                                  rffi.cast(llmemory.Address, self.writebuffer),
                                  rffi.cast(rffi.SIZE_T, bytes))
             if rffi.cast(lltype.Signed, count) != bytes:
-                raise OSError(rposix.get_errno(), "raw_os_write failed")
+                raise OSError(rffi.cast(lltype.Signed, rposix._get_errno()),
+                              "raw_os_write failed")
             self.buf_count = 0
     flush._dont_inline_ = True
 
diff --git a/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py 
b/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py
--- a/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py
+++ b/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py
@@ -756,21 +756,23 @@
             old_err_mode = ctypes.windll.kernel32.GetErrorMode()
             new_err_mode = old_err_mode | SEM_NOGPFAULTERRORBOX
             ctypes.windll.kernel32.SetErrorMode(new_err_mode)
-        strlen = rffi.llexternal('strlen', [rffi.CCHARP], rffi.SIZE_T,
-                                 compilation_info=eci)
+        os_write_no_errno = rffi.llexternal(UNDERSCORE_ON_WIN32 + 'write',
+                                   [rffi.INT, rffi.CCHARP, rffi.SIZE_T],
+                                   rffi.SIZE_T, save_err=rffi.RFFI_ERR_NONE)
         os_write = rffi.llexternal(UNDERSCORE_ON_WIN32 + 'write',
                                    [rffi.INT, rffi.CCHARP, rffi.SIZE_T],
-                                   rffi.SIZE_T)
+                                   rffi.SIZE_T, save_err=rffi.RFFI_SAVE_ERRNO)
         buffer = lltype.malloc(rffi.CCHARP.TO, 5, flavor='raw')
         written = os_write(12312312, buffer, 5)
         if sys.platform.startswith('win'):
             ctypes.windll.kernel32.SetErrorMode(old_err_mode)
+        assert rffi.cast(rffi.LONG, written) < 0
+        # the next line is a different external function call
+        # without RFFI_SAVE_ERRNO, to check that it doesn't reset errno
+        buffer[0] = '\n'
+        os_write_no_errno(2, buffer, 1)
         lltype.free(buffer, flavor='raw')
-        assert rffi.cast(rffi.LONG, written) < 0
-        # the next line is a random external function call,
-        # to check that it doesn't reset errno
-        strlen("hi!")
-        err = rposix.get_errno()
+        err = rposix.get_saved_errno()
         import errno
         assert err == errno.EBADF
         assert not ALLOCATED     # detects memory leaks in the test
diff --git a/rpython/rtyper/lltypesystem/test/test_rffi.py 
b/rpython/rtyper/lltypesystem/test/test_rffi.py
--- a/rpython/rtyper/lltypesystem/test/test_rffi.py
+++ b/rpython/rtyper/lltypesystem/test/test_rffi.py
@@ -3,7 +3,7 @@
 import sys
 from rpython.rtyper.lltypesystem.rffi import *
 from rpython.rtyper.lltypesystem.rffi import _keeper_for_type # crap
-from rpython.rlib.rposix import get_errno, set_errno
+from rpython.rlib.rposix import get_saved_errno, set_saved_errno
 from rpython.translator.c.test.test_genc import compile as compile_c
 from rpython.rtyper.lltypesystem.lltype import Signed, Ptr, Char, malloc
 from rpython.rtyper.lltypesystem import lltype
@@ -207,15 +207,15 @@
             bad_fd = 12312312
 
         def f():
-            set_errno(12)
-            return get_errno()
+            set_saved_errno(12)
+            return get_saved_errno()
 
         def g():
             try:
                 os.write(bad_fd, "xxx")
             except OSError:
                 pass
-            return get_errno()
+            return get_saved_errno()
 
         fn = self.compile(f, [])
         assert fn() == 12
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to