Commit Graph

214 Commits

Author SHA1 Message Date
Thomas Heller 07750565c9 Merged revisions 69505 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r69505 | thomas.heller | 2009-02-10 19:43:01 +0100 (Di, 10 Feb 2009) | 3 lines

  Issue#5203: ctypes segfaults when passing a unicode string to a
  function without argtypes, if HAVE_USABLE_WCHAR_T is false.
........
2009-02-10 18:46:11 +00:00
Georg Brandl 686d53eed3 Merged revisions 68521,68527,68534-68536,68540,68547,68552,68563,68570,68572,68575,68579-68580,68584 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r68521 | hirokazu.yamamoto | 2009-01-11 04:28:13 +0100 (So, 11 Jan 2009) | 1 line

  Fixed version number in build_ssl.bat.
........
  r68527 | martin.v.loewis | 2009-01-11 10:43:55 +0100 (So, 11 Jan 2009) | 2 lines

  Issue #4895: Use _strdup on Windows CE.
........
  r68534 | gregory.p.smith | 2009-01-11 18:53:33 +0100 (So, 11 Jan 2009) | 2 lines

  correct email address
........
  r68535 | gregory.p.smith | 2009-01-11 18:57:54 +0100 (So, 11 Jan 2009) | 9 lines

  Update the documentation for binascii and zlib crc32/adler32 functions
  to better describe the signed vs unsigned return value behavior on
  different platforms and versions of python.  Mention the workaround to
  make them all return the same thing by using & 0xffffffff.

  Fixes issue4903.

  Also needs to be merged into release26-maint, release30-maint, & py3k.
........
  r68536 | benjamin.peterson | 2009-01-11 20:48:15 +0100 (So, 11 Jan 2009) | 1 line

  add email addresses
........
  r68540 | martin.v.loewis | 2009-01-12 08:57:11 +0100 (Mo, 12 Jan 2009) | 2 lines

  Issue #4915: Port sysmodule to Windows CE.
........
  r68547 | kristjan.jonsson | 2009-01-12 19:09:27 +0100 (Mo, 12 Jan 2009) | 1 line

  Add tests for invalid format specifiers in strftime, and for handling of invalid file descriptors in the os module.
........
  r68552 | vinay.sajip | 2009-01-12 21:36:18 +0100 (Mo, 12 Jan 2009) | 1 line

  Minor changes/corrections in markup.
........
  r68563 | benjamin.peterson | 2009-01-13 02:49:10 +0100 (Di, 13 Jan 2009) | 1 line

  small logic correction
........
  r68570 | raymond.hettinger | 2009-01-13 10:08:32 +0100 (Di, 13 Jan 2009) | 5 lines

  Issue 4922: Incorrect comments for MutableSet.add() and MutableSet.discard().

  Needs to be backported to 2.6 and forward ported to 3.0 and 3.1.
........
  r68572 | andrew.kuchling | 2009-01-13 14:40:54 +0100 (Di, 13 Jan 2009) | 1 line

  Note that first coord. is left alone
........
  r68575 | thomas.heller | 2009-01-13 18:32:28 +0100 (Di, 13 Jan 2009) | 1 line

  Fix refcount leak in error cases.  Bug found by coverity.
........
  r68579 | benjamin.peterson | 2009-01-13 22:42:23 +0100 (Di, 13 Jan 2009) | 1 line

  make bytearrayobject.o depend on the stringlib #4936
........
  r68580 | benjamin.peterson | 2009-01-13 22:43:11 +0100 (Di, 13 Jan 2009) | 1 line

  add bytearrayobject.h to PYTHON_HEADERS
........
  r68584 | benjamin.peterson | 2009-01-13 23:22:41 +0100 (Di, 13 Jan 2009) | 1 line

  de-spacify
........
2009-01-14 00:08:09 +00:00
Christian Heimes f3127b123b Issue #4025 again
Converted a C99 style comment to a C89 style comment (found by MAL).
2008-12-03 00:51:50 +00:00
Christian Heimes 4d8a6f4834 Merged revisions 66748 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r66748 | christian.heimes | 2008-10-02 21:47:50 +0200 (Thu, 02 Oct 2008) | 1 line

  Fixed a couple more C99 comments and one occurence of inline.
........
2008-10-02 19:49:47 +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
Neal Norwitz 18aa388ca0 Fix:
* crashes on memory allocation failure found with failmalloc
 * memory leaks found with valgrind
 * compiler warnings in opt mode which would lead to invalid memory reads
 * problem using wrong name in decimal module reported by pychecker

Update the valgrind suppressions file with new leaks that are small/one-time
leaks we don't care about (ie, they are too hard to fix).

TBR=barry
TESTED=./python -E -tt ./Lib/test/regrtest.py -uall (both debug and opt modes)
  in opt mode:
  valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
    ./python -E -tt ./Lib/test/regrtest.py -uall,-bsddb,-compiler \
                        -x test_logging test_ssl test_multiprocessing
  valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
    ./python -E -tt ./Lib/test/regrtest.py test_multiprocessing
  for i in `seq 1 4000` ; do
    LD_PRELOAD=~/local/lib/libfailmalloc.so FAILMALLOC_INTERVAL=$i \
        ./python -c pass
  done

At least some of these fixes should probably be backported to 2.5.
2008-08-24 05:04:52 +00:00
Thomas Heller d9ccf8c547 COM method code is windows specific 2008-08-19 19:40:23 +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
Martin v. Löwis 8401eec7fa Properly INCREF reference in Py_buffer. 2008-08-14 15:56:07 +00:00
Thomas Heller ba55936b8a Make ctypes compatible with Python 2.3, 2.4, and 2.5 again. 2008-07-24 11:16:45 +00:00
Thomas Heller 880f529c04 Issue #3313: Contrary to the man page, a failed dlopen() call does not
always set a dlerror() message.
2008-07-15 19:39:38 +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
Neal Norwitz e9ee44c25b Check for memory alloc failure 2008-06-13 06:00:46 +00:00
Thomas Heller dcea9a91c6 Add an optional 'offset' parameter to byref, defaultingto zero. 2008-06-10 14:02:46 +00:00
Gregory P. Smith dd96db63f6 This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html

Python 2.6 should stick with PyString_* in its codebase.  The PyBytes_* names
in the spirit of 3.0 are available via a #define only.  See the email thread.
2008-06-09 04:58:54 +00:00
Travis E. Oliphant 0144f27602 Remove locking part of new buffer protocol. 2008-06-06 22:39:47 +00:00
Thomas Heller f89b04c164 Performance improvement: Use PyDict_Get/SetItem instead of
PyDict_Get/SetItemString.
2008-06-06 18:37:55 +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
Ronald Oussoren 5640ce2f1e MacOS X: Enable 4-way universal builds
This patch adds a new configure argument on OSX:
        --with-universal-archs=[32-bit|64-bit|all]

When used with the --enable-universalsdk option this controls which
CPU architectures are includes in the framework. The default is 32-bit,
meaning i386 and ppc. The most useful alternative is 'all', which includes
all 4 CPU architectures supported by MacOS X (i386, ppc, x86_64 and ppc64).

This includes limited support for the Carbon bindings in 64-bit mode as well,
limited because (a) I haven't done extensive testing and (b) a large portion
of the Carbon API's aren't available in 64-bit mode anyway.

I've also duplicated a feature of Apple's build of python: setting the
environment variable 'ARCHFLAGS' controls the '-arch' flags used for building
extensions using distutils.
2008-06-05 12:58:24 +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 8f22b88e28 Fix ctypes.set_errno for gcc. 2008-06-04 19:19:00 +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 de2d78a153 Fix misspelled sys.platform name and misspelled filename. 2008-06-02 18:41:30 +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 a52b244cc1 Fix compiler warning. 2008-05-29 19:18:12 +00:00
Christian Heimes 593daf545b Renamed PyString to PyBytes 2008-05-26 12:51:38 +00:00
Martin v. Löwis 8c255e4173 Patch #1722225: Support QNX 6. 2008-05-23 15:06:50 +00:00
Thomas Heller 03b75ddf7c On HPUX, -fPIC must be used for linking. _ctypes now builds on HP-UX
IA64 and PA machines.

The ctypes unittests work fine on the IA64, but dump core in
test_qsort on the PA.
2008-05-20 19:53:47 +00:00
Georg Brandl a6b79f3b11 Add missing return type to dealloc. 2008-04-26 18:32:17 +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 bf027c48c8 Remove cyclic reference in CFuncPtr instances; see issue #2682.
Backport candidate for the release25-maint branch.
2008-04-24 18:14:19 +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 d3ed492164 Performance improvements. 2008-04-11 14:20:26 +00:00
Thomas Heller 12c4e6478a Move backwards compatibility macro to the correct place;
PyIndex_Check() was introduced in Python 2.5.
2008-04-11 13:05:38 +00:00
Thomas Heller c4ef47611f More files from libffi 3.0.5.
Removed libffi.pc.in because it is not needed for ctypes.
2008-04-04 19:14:42 +00:00
Thomas Heller e1929d5133 Sync with files from the just released libffi 3.0.5 version. 2008-04-04 16:01:54 +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 fffd939056 Make _ctypes.c PY_SSIZE_T_CLEAN. 2008-03-25 21:18:39 +00:00
Thomas Heller 50a24d8bfd Include <alloca.h> on Solaris, see issue #1506.
It would probably be better to have a configure test for that, but
this is outside of my configure expertise.
2008-03-18 15:03:17 +00:00
Thomas Heller 41e22ff5cc Remove unneeded initializer. 2008-03-14 21:06:21 +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
Thomas Heller a23aede562 Try to fix the build for PY_LINUX. 2008-03-04 20:21:42 +00:00
Thomas Heller 8bdf81d2df Merged changes from libffi3-branch.
The bundled libffi copy is now in sync with the recently released
libffi3.0.4 version, apart from some small changes to
Modules/_ctypes/libffi/configure.ac.

I gave up on using libffi3 files on os x.
Instead, static configuration with files from pyobjc is used.
2008-03-04 20:09:11 +00:00
Neal Norwitz ed0a593a10 Get ctypes working on the Alpha (Tru64). The problem was that there
were two module_methods and the one used depended on the order the
modules were loaded.  By making the test module_methods static,
it is not exported and the correct version is picked up.
2008-02-24 07:21:56 +00:00
Thomas Heller 981f31860b configure.ac: Remove the configure check for _Bool, it is already done in the
top-level Python configure script.
configure, fficonfig.h.in: regenerated.
2008-02-21 18:28:48 +00:00
Thomas Heller a06a1a88ee Add pickle support to ctypes types. 2008-02-13 20:21:53 +00:00
Brett Cannon 8352585909 Make sure a switch statement does not have repetitive case statements.
Error found through LLVM post-2.1 svn.
2008-02-07 22:27:10 +00:00
Thomas Heller 55b8c3e26f Fixed refcounts and error handling.
Should not be merged to py3k branch.
2008-02-06 20:29:17 +00:00