Commit Graph

138 Commits

Author SHA1 Message Date
Thomas Heller d8431ae3bd Revert rev 74134, as it does not completely fixx issue #6493. 2009-07-21 19:04:02 +00:00
Thomas Heller 6adda9641d Issue #6493: Fix a ctypes problem setting bitfields more than 31 bits
wide.
2009-07-21 06:27:14 +00:00
Benjamin Peterson 4d3f18f2ed fix a few cases where automated fail -> assert translation messed up
Thanks Joe Amenta
2009-07-01 00:36:41 +00:00
Benjamin Peterson 5c8da86f3a convert usage of fail* to assert* 2009-06-30 22:57:08 +00:00
Thomas Heller a57773e483 Fix Issue #4875: find_library can return directories instead of files
(on win32)
2009-05-05 18:55:47 +00:00
Thomas Heller ec21ccde12 Issue 5041: ctypes unwilling to allow pickling wide character. 2009-04-24 20:00:41 +00:00
Benjamin Peterson 164b0455b6 make tests fail if they can't be imported 2009-01-10 22:42:10 +00:00
Matthias Klose 43723e2ad8 - Issue #4861: ctypes.util.find_library(): Robustify. Fix library detection on
biarch systems. Try to rely on ldconfig only, without using objdump and gcc.
2009-01-10 17:00:42 +00:00
Thomas Heller e144873071 Fix issue #3547 for MingW, update comments. 2008-09-29 19:56:24 +00:00
Thomas Heller a85c95d5e8 Fix issue #3547: ctypes is confused by bitfields of varying integer types
Reviewed by Fredrik Lundh and Skip Montanaro.
2008-09-24 18:26:05 +00:00
Hirokazu Yamamoto 838c79f472 Issue #3612: Added some missing basic types in ctypes.wintypes. 2008-08-20 13:14:07 +00:00
Thomas Heller 0ad5ae02af Fix a regression introduced by rev. 63792: ctypes function pointers
that are COM methods must have a boolean True value.
2008-08-19 19:25:04 +00:00
Thomas Heller 63d325e8c4 Disable the test until I have one that works. 2008-08-14 20:19:18 +00:00
Thomas Heller 6d2014ee59 Try to fix the test on 64-bit platforms. 2008-08-14 20:04:38 +00:00
Thomas Heller 57adf22f6e issue #3554: ctypes.string_at and ctypes.wstring_at must use the
pythonapi calling convention so that the GIL is held and error return
values are checked.
2008-08-14 19:10:48 +00:00
Nick Coghlan 48361f5cbf Issue 2235: Py3k warnings are now emitted for classes that will no longer inherit a__hash__ implementation from a parent class in Python 3.x. The standard library and test suite have been updated to not emit these warnings. 2008-08-11 15:45:58 +00:00
Thomas Heller 2affb40e70 Fix test on 64-bit platforms. 2008-07-15 20:18:46 +00:00
Thomas Heller c0b2a807ff Issue #3258: Fix an assertion error (in debug build) and a crash (in
release build) when the format string of a pointer to an incomplete
structure is created.
2008-07-15 17:03:08 +00:00
Martin v. Löwis 06510b2213 Run svneol.py on all sources. 2008-06-13 22:38:33 +00:00
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
Thomas Heller 2e75c450d2 Backport from py3k: Implement the new buffer interface from pep3118
for ctypes instances.  Closes issue #2404.
2008-06-05 17:51:15 +00:00
Thomas Heller d5bb9215c9 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.
2008-06-04 20:22:05 +00:00
Thomas Heller e70c3378c0 Issue #1798: Add ctypes calling convention that allows safe access to
errno (and LastError, on Windows).

ctypes maintains a module-global, but thread-local, variable that
contains an error number; called 'ctypes_errno' for this discussion.
This variable is a private copy of the systems 'errno' value; the copy
is swapped with the 'errno' variable on several occasions.

Foreign functions created with CDLL(..., use_errno=True), when called,
swap the values 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.

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).

Two new ctypes functions are provided to access the 'ctypes_errno'
value from Python:

- ctypes.set_errno(value) sets ctypes_errno to 'value', the previous
  ctypes_errno value is returned.

- ctypes.get_errno() returns the current ctypes_errno value.

---

On Windows, the same scheme is implemented for the error value which
is managed by the GetLastError() and SetLastError() windows api calls.

The ctypes functions are 'ctypes.set_last_error(value)' and
'ctypes.get_last_error()', the CDLL and WinDLL optional parameter is
named 'use_last_error', defaults to False.

---

On Windows, TlsSetValue and TlsGetValue calls are used to provide
thread local storage for the variables; ctypes compiled with __GNUC__
uses __thread variables.
2008-06-04 18:59:03 +00:00
Thomas Heller 261b136321 Fix the -x flag so that is does work. 2008-06-02 20:07:46 +00:00
Thomas Heller 9287acf83d ctypes NULL function pointers have a boolean False value now. 2008-05-29 19:42:34 +00:00
Thomas Heller 6c78f553ae Oops, get_tests may be called with 3 arguments. 2008-05-21 19:47:44 +00:00
Thomas Heller 7d9e721586 The -x <test1[,test2...]> flag allows to exclude tests. 2008-05-21 18:47:02 +00:00
Thomas Heller ee130b72f8 Very simple test for ctypes.util.find_library on Windows. 2008-05-16 20:19:07 +00:00
Thomas Heller 95ba13fa85 Issue 1793: Add ctypes.util.find_msvcrt() function (on Windows). 2008-05-16 20:06:31 +00:00
Thomas Heller 6ad5fbb7ea Add from_buffer and from_buffer_copy class methods to ctypes types. 2008-04-25 15:44:16 +00:00
Thomas Heller 046e6a43ff Issue #2616: Implement ctypes.pointer() and ctypes.POINTER() in C for
better performance.
2008-04-14 16:10:07 +00:00
Thomas Heller 8e8ba151dd Issue #2543: Make ctypes compatible (again) with Python 2.3, 2.4, and 2.5. 2008-04-04 08:35:44 +00:00
Thomas Heller f3c0559b5e Issue 1872: Changed the struct module typecode from 't' to '?', for
compatibility with PEP3118.
2008-03-05 15:34:29 +00:00
Christian Heimes c5f05e45cf Patch #2167 from calvin: Remove unused imports 2008-02-23 17:40:11 +00:00
Thomas Heller 8982cf5484 Replace 'has_key()' with 'in'.
Replace 'raise Error, stuff' with 'raise Error(stuff)'.
2008-02-21 18:52:20 +00:00
Thomas Heller 4516451aec Make the test somewhat clearer (I hope). 2008-02-13 20:36:51 +00:00
Thomas Heller a06a1a88ee Add pickle support to ctypes types. 2008-02-13 20:21:53 +00:00
Thomas Heller 99120c4f7e Revert rev. 59925, it breaks comtypes (I need to further examine this). 2008-01-28 08:44:13 +00:00
Thomas Heller 5ca924038d Invert the checks in get_[u]long and get_[u]longlong. The intent was
to not accept float types; the result was that integer-like objects
were not accepted.

Ported from release25-maint.
2008-01-24 19:15:02 +00:00
Thomas Heller 0f75f9847a Use 'g' instead of 'D' as the ctypes typecode for c_longdouble, for
compliance with PEP 3118.
2008-01-16 20:34:37 +00:00
Thomas Heller 415c1e36a9 Raise a TypeError instead of a ValueError when too many initializers
are used in a Structure or Union constructor.
2008-01-16 19:45:51 +00:00
Thomas Heller 02ec289f3e Raise a TypeError if conflicting positional and named arguments are
passed to a Structure or Union constructor.
2008-01-16 19:37:33 +00:00
Thomas Heller 902d30752f Convert the internal ctypes array type cache to a WeakValueDict so
that array types do not live longer than needed.
2008-01-16 19:16:27 +00:00
Thomas Heller c682614df0 Raise an error instead of crashing with a segfault when a NULL
function pointer is called.

Will backport to release25-maint.
2008-01-11 19:34:06 +00:00
Thomas Heller 153038efa4 Issue #1642: Fix segfault in ctypes when trying to delete attributes. 2007-12-18 19:00:34 +00:00
Thomas Heller 03fd077482 Enable the full ctypes c_longdouble tests again. 2007-11-02 19:11:23 +00:00
Thomas Heller e7becc5007 Added unittest for calling a function with paramflags (backport from py3k branch). 2007-10-24 19:50:45 +00:00
Thomas Heller 7fee6dd2a3 On OS X, use os.uname() instead of gestalt.sysv(...) to get the
operating system version.  This allows to use ctypes when Python
was configured with --disable-toolbox-glue.
2007-10-11 19:51:32 +00:00
Thomas Heller a7f49f733b ctypes.util.find_library uses dump(1) instead of objdump(1) on Solaris.
Fixes issue #1777530; will backport to release25-maint.
2007-09-14 19:40:35 +00:00
Thomas Heller 0b7120258a Disable some tests that fail on the 'ppc Debian unstable' buildbot to
find out if they cause the segfault on the 'alpha Debian' machine.
2007-09-11 19:17:48 +00:00