cpython/Lib/ctypes/test
Thomas Heller fbb9c0bf3c Issue #1798: Add ctypes calling convention that allows safe access of errno.
ctypes maintains thread-local storage that has space for two error
numbers: private copies of the system 'errno' value and, on Windows,
the system error code accessed by the GetLastError() and
SetLastError() api functions.

Foreign functions created with CDLL(..., use_errno=True), when called,
swap the system 'errno' value with the private copy just before the
actual function call, and swapped again immediately afterwards.  The
'use_errno' parameter defaults to False, in this case 'ctypes_errno'
is not touched.

On Windows, foreign functions created with CDLL(...,
use_last_error=True) or WinDLL(..., use_last_error=True) swap the
system LastError value with the ctypes private copy.

The values are also swapped immeditately before and after ctypes
callback functions are called, if the callbacks are constructed using
the new optional use_errno parameter set to True: CFUNCTYPE(...,
use_errno=TRUE) or WINFUNCTYPE(..., use_errno=True).

New ctypes functions are provided to access the ctypes private copies
from Python:

- ctypes.set_errno(value) and ctypes.set_last_error(value) store
  'value' in the private copy and returns the previous value.

- ctypes.get_errno() and ctypes.get_last_error() returns the current
  ctypes private copies value.
2008-06-06 08:33:46 +00:00
..
__init__.py Fix the -x flag so that is does work. 2008-06-02 20:07:46 +00:00
runtests.py Oops, get_tests may be called with 3 arguments. 2008-05-21 19:47:44 +00:00
test_anon.py Whitespace normalization. 2006-06-11 19:42:51 +00:00
test_array_in_pointer.py Whitespace normalization. 2006-03-09 01:15:05 +00:00
test_arrays.py Convert the internal ctypes array type cache to a WeakValueDict so 2008-01-16 19:16:27 +00:00
test_as_parameter.py Remove the special casing of Py_None when converting the return value 2006-08-16 15:10:12 +00:00
test_bitfields.py Anonymous structure fields that have a bit-width specified did not work, 2006-09-07 18:56:28 +00:00
test_buffers.py Somewhat-preliminary slice-object and extended slicing support for ctypes. 2007-08-30 21:01:17 +00:00
test_byteswap.py Merge in changes from ctypes 0.9.9.6 upstream version. 2006-04-21 16:51:04 +00:00
test_callbacks.py Add a 'c_longdouble' type to the ctypes module. 2007-09-07 06:32:17 +00:00
test_cast.py Somewhat-preliminary slice-object and extended slicing support for ctypes. 2007-08-30 21:01:17 +00:00
test_cfuncs.py Replace 'has_key()' with 'in'. 2008-02-21 18:52:20 +00:00
test_checkretval.py Patch #2167 from calvin: Remove unused imports 2008-02-23 17:40:11 +00:00
test_delattr.py Issue #1642: Fix segfault in ctypes when trying to delete attributes. 2007-12-18 19:00:34 +00:00
test_errcheck.py
test_errno.py Issue #1798: Add ctypes calling convention that allows safe access of errno. 2008-06-06 08:33:46 +00:00
test_find.py Patch #2167 from calvin: Remove unused imports 2008-02-23 17:40:11 +00:00
test_frombuffer.py Add from_buffer and from_buffer_copy class methods to ctypes types. 2008-04-25 15:44:16 +00:00
test_funcptr.py Revert rev. 59925, it breaks comtypes (I need to further examine this). 2008-01-28 08:44:13 +00:00
test_functions.py Enable the full ctypes c_longdouble tests again. 2007-11-02 19:11:23 +00:00
test_incomplete.py
test_init.py
test_integers.py
test_internals.py
test_keeprefs.py Upgrade to ctypes version 0.9.9.7. 2006-06-10 19:55:36 +00:00
test_libc.py Patch #2167 from calvin: Remove unused imports 2008-02-23 17:40:11 +00:00
test_loading.py Very simple test for ctypes.util.find_library on Windows. 2008-05-16 20:19:07 +00:00
test_macholib.py Replace 'has_key()' with 'in'. 2008-02-21 18:52:20 +00:00
test_memfunctions.py Somewhat-preliminary slice-object and extended slicing support for ctypes. 2007-08-30 21:01:17 +00:00
test_numbers.py Patch #2167 from calvin: Remove unused imports 2008-02-23 17:40:11 +00:00
test_objects.py Don't run the doctests with Python 2.3 because it doesn't have the ELLIPSIS flag. 2006-07-03 07:59:50 +00:00
test_parameters.py Patch #1517790: It is now possible to use custom objects in the ctypes 2006-07-06 08:48:35 +00:00
test_pep3118.py Backport from py3k: Implement the new buffer interface from pep3118 2008-06-05 17:51:15 +00:00
test_pickling.py Make the test somewhat clearer (I hope). 2008-02-13 20:36:51 +00:00
test_pointers.py ctypes NULL function pointers have a boolean False value now. 2008-05-29 19:42:34 +00:00
test_prototypes.py Issue #2543: Make ctypes compatible (again) with Python 2.3, 2.4, and 2.5. 2008-04-04 08:35:44 +00:00
test_python_api.py Fix some ctypes test crashes, when running with a debug Python 2007-05-04 07:14:39 +00:00
test_random_things.py Replace 'has_key()' with 'in'. 2008-02-21 18:52:20 +00:00
test_refcounts.py Merge in changes from ctypes 0.9.9.6 upstream version. 2006-04-21 16:51:04 +00:00
test_repr.py Add a 'c_longdouble' type to the ctypes module. 2007-09-07 06:32:17 +00:00
test_returnfuncptrs.py Merge in changes from ctypes 0.9.9.6 upstream version. 2006-04-21 16:51:04 +00:00
test_simplesubclasses.py
test_sizes.py Merge changes from the upstream version: 2006-03-17 15:52:58 +00:00
test_slicing.py Somewhat-preliminary slice-object and extended slicing support for ctypes. 2007-08-30 21:01:17 +00:00
test_stringptr.py Merge in changes from ctypes 0.9.9.6 upstream version. 2006-04-21 16:51:04 +00:00
test_strings.py Somewhat-preliminary slice-object and extended slicing support for ctypes. 2007-08-30 21:01:17 +00:00
test_struct_fields.py
test_structures.py Raise a TypeError instead of a ValueError when too many initializers 2008-01-16 19:45:51 +00:00
test_unaligned_structures.py Add missing SVN eol-style property to text files. 2006-04-16 22:11:28 +00:00
test_unicode.py Somewhat-preliminary slice-object and extended slicing support for ctypes. 2007-08-30 21:01:17 +00:00
test_values.py Merge in changes from ctypes 0.9.9.6 upstream version. 2006-04-21 16:51:04 +00:00
test_varsize_struct.py Patch #1521817: The index range checking on ctypes arrays containing 2006-07-14 17:51:14 +00:00
test_win32.py Add tests for _ctypes.COMError. 2007-07-13 14:18:06 +00:00