Commit Graph

151 Commits

Author SHA1 Message Date
Florent Xicluna f08a0176a7 Get rid of buffer() in test_ctypes: backport the 3.x tests. 2010-03-22 15:02:46 +00:00
Collin Winter 786431282b Avoid hardcoding refcounts in tests. 2010-03-17 17:36:16 +00:00
Ezio Melotti d80b4bfd0b #7092: silence some more py3k warnings. 2010-03-17 13:52:48 +00:00
Matthias Klose 358e7ff36b - Issue #7356: ctypes.util: Make parsing of ldconfig output independent of
the locale.
2010-03-15 13:42:23 +00:00
Florent Xicluna 1f3b4e12e8 Fix some py3k warnings in the standard library. 2010-03-07 12:14:25 +00:00
Gregory P. Smith 3c699d334a Adds c_ssize_t to ctypes. issue 6729. 2010-03-01 04:56:12 +00:00
Thomas Heller 92bd059c67 ctypes CThunkObject was not registered correctly with the cycle
garbage collector, leading to possible leaks when using callback
functions.
2010-02-23 20:11:44 +00:00
Ezio Melotti dde5b94875 #7092: Silence more py3k warnings. Patch by Florent Xicluna. 2010-02-03 05:37:26 +00:00
Eric Smith 84da0905e4 Per the discussion in issue6882, backport the try/finally work that was done to the py3k version (mostly in r59477, I think). 2009-10-22 20:13:14 +00:00
Georg Brandl 590a3675b7 Revert unintended change. 2009-10-22 07:06:49 +00:00
Georg Brandl 0968fd679b Fix punctuation. 2009-10-22 07:05:48 +00:00
Thomas Heller 6be522bfc2 Issue #4606: Passing 'None' if ctypes argtype is set to POINTER(...)
does now always result in NULL.
2009-09-18 20:05:44 +00:00
Thomas Heller 7a352c0ed8 Issue #5042: Structure sub-subclass does now initialize correctly with
base class positional arguments.
2009-09-18 18:55:17 +00:00
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