diff options
author | Thomas Heller <theller@ctypes.org> | 2008-06-04 20:22:05 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2008-06-04 20:22:05 (GMT) |
commit | d5bb9215c960da14e138adc88c80daa54e6601c4 (patch) | |
tree | 17416a616e9932c0b721fa6a67dbb42df90d164a /Lib/ctypes/test | |
parent | 8f22b88e28bbb2ea9255592d3ac12e2623bc51e8 (diff) | |
download | cpython-d5bb9215c960da14e138adc88c80daa54e6601c4.zip cpython-d5bb9215c960da14e138adc88c80daa54e6601c4.tar.gz cpython-d5bb9215c960da14e138adc88c80daa54e6601c4.tar.bz2 |
Revert revisions 63943 and 63942 (Issue #1798: Add ctypes calling
convention that allows safe access to errno)
This code does not yet work on OS X (__thread storage specifier not
available), so i needs a configure check plus a more portable
solution.
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r-- | Lib/ctypes/test/test_errno.py | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/Lib/ctypes/test/test_errno.py b/Lib/ctypes/test/test_errno.py deleted file mode 100644 index b80656b..0000000 --- a/Lib/ctypes/test/test_errno.py +++ /dev/null @@ -1,76 +0,0 @@ -import unittest, os, errno -from ctypes import * -from ctypes.util import find_library -import threading - -class Test(unittest.TestCase): - def test_open(self): - libc_name = find_library("c") - if libc_name is not None: - libc = CDLL(libc_name, use_errno=True) - if os.name == "nt": - libc_open = libc._open - else: - libc_open = libc.open - - libc_open.argtypes = c_char_p, c_int - - self.failUnlessEqual(libc_open("", 0), -1) - self.failUnlessEqual(get_errno(), errno.ENOENT) - - self.failUnlessEqual(set_errno(32), errno.ENOENT) - self.failUnlessEqual(get_errno(), 32) - - - def _worker(): - set_errno(0) - - libc = CDLL(libc_name, use_errno=False) - if os.name == "nt": - libc_open = libc._open - else: - libc_open = libc.open - libc_open.argtypes = c_char_p, c_int - self.failUnlessEqual(libc_open("", 0), -1) - self.failUnlessEqual(get_errno(), 0) - - t = threading.Thread(target=_worker) - t.start() - t.join() - - self.failUnlessEqual(get_errno(), 32) - set_errno(0) - - if os.name == "nt": - - def test_GetLastError(self): - dll = WinDLL("kernel32", use_last_error=True) - GetModuleHandle = dll.GetModuleHandleA - GetModuleHandle.argtypes = [c_wchar_p] - - self.failUnlessEqual(0, GetModuleHandle("foo")) - self.failUnlessEqual(get_last_error(), 126) - - self.failUnlessEqual(set_last_error(32), 126) - self.failUnlessEqual(get_last_error(), 32) - - def _worker(): - set_last_error(0) - - dll = WinDLL("kernel32", use_last_error=False) - GetModuleHandle = dll.GetModuleHandleW - GetModuleHandle.argtypes = [c_wchar_p] - GetModuleHandle("bar") - - self.failUnlessEqual(get_last_error(), 0) - - t = threading.Thread(target=_worker) - t.start() - t.join() - - self.failUnlessEqual(get_last_error(), 32) - - set_last_error(0) - -if __name__ == "__main__": - unittest.main() |