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
Thomas Heller
99120c4f7e
Revert rev. 59925, it breaks comtypes (I need to further examine this).
2008-01-28 08:44:13 +00:00
Christian Heimes
d7e1b2bd17
static PyObject* variables should use PyString_InternFromString() instead of PyObject_FromString() to store a python string in a function level static var.
2008-01-28 02:07:53 +00:00
Neal Norwitz
b3c8243c47
Update to newer version of ffi. Fixes crashes and test failures of longdouble
2008-01-27 17:10:43 +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
71dba4ccee
Replace Py_BuildValue with PyTuple_Pack because it is faster.
...
Also add a missing DECREF.
2008-01-24 18:54:12 +00:00
Thomas Heller
e4c03e4520
Use a PyDictObject again for the array type cache; retrieving items
...
from the WeakValueDictionary was slower by nearly a factor of 3.
To avoid leaks, weakref proxies for the array types are put into the
cache dict, with weakref callbacks that removes the entries when the
type goes away.
2008-01-24 18:36:27 +00:00
Brett Cannon
a35a8b11c3
Fix a function pointer declaration to silence the compiler.
2008-01-17 18:45:10 +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
7a66a1becc
Issue 1821: configure libffi for amd64 on FreeeBSD.
2008-01-14 10:35:28 +00:00
Amaury Forgeot d'Arc
7cdf5f5c31
?Why did my tests not notice this before?
...
Slots inheritance is very different from OO inheritance.
This code lead to infinite recursion on classes derived from StructType.
2008-01-14 01:07:27 +00:00
Amaury Forgeot d'Arc
08ccf202e6
As discussed in issue 1700288:
...
ctypes takes some liberties when creating python types: it modifies the types'
__dict__ directly, bypassing all the machinery of type objects which deal with
special methods. And this broke recent optimisations of method lookup.
Now we try to modify the type with more "official" functions.
2008-01-14 00:22:44 +00:00
Thomas Heller
43617bc610
Fix a potential 'SystemError: NULL result without error'.
...
NULL may be a valid return value from PyLong_AsVoidPtr.
Will backport to release25-maint.
2008-01-11 20:29:19 +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
41f278ffa5
Use relative instead of absolute filenames in the C-level tracebacks.
...
This prevents traceback prints pointing to files in this way:
File "\loewis\25\python\Modules\_ctypes\callbacks.c", line 206, in 'calling callback function'
2008-01-08 15:15:09 +00:00
Christian Heimes
000a074c95
Modified PyImport_Import and PyImport_ImportModule to always use absolute imports by calling __import__ with an explicit level of 0
...
Added a new API function PyImport_ImportModuleNoBlock. It solves the problem with dead locks when mixing threads and imports
2008-01-03 22:16:32 +00:00
Christian Heimes
e93237dfcc
#1629 : Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
2007-12-19 02:37:44 +00:00
Thomas Heller
153038efa4
Issue #1642 : Fix segfault in ctypes when trying to delete attributes.
2007-12-18 19:00:34 +00:00
Christian Heimes
2518b25578
Fixed a warning in _codecs_iso2022.c and some non C89 conform // comments.
2007-12-14 03:02:34 +00:00
Thomas Heller
8fc2a34014
Remove unused global variable, and remove unneeded COMError.__str__
...
implementation in C.
2007-11-27 12:22:11 +00:00
Thomas Heller
469b2a52cd
ffi_type_longdouble may be already #defined.
...
See issue 1324.
2007-10-25 19:47:32 +00:00
Thomas Heller
91ac42243c
Fix ctypes on 32-bit systems when Python is configured --with-system-ffi.
...
See also https://bugs.launchpad.net/bugs/72505 .
Ported from release25-maint branch.
2007-10-19 18:11:41 +00:00
Neal Norwitz
c740d834ee
Get rid of warnings on a bunch of platforms by using a proper prototype.
2007-10-12 03:01:30 +00:00
Thomas Heller
49c7c71d9f
Remove unneeded #include.
2007-09-07 09:30:40 +00:00
Thomas Heller
2825b2ea44
Add a 'c_longdouble' type to the ctypes module.
2007-09-07 06:32:17 +00:00
Matthias Klose
38336406eb
- Fix libffi configure for hppa*-*-linux* | parisc*-*-linux*.
2007-09-04 20:46:02 +00:00
Thomas Wouters
dcb3c382ac
Somewhat-preliminary slice-object and extended slicing support for ctypes.
...
The exact behaviour of omitted and negative indices for the Pointer type may
need a closer look (especially as it's subtly different from simple slices)
but there's time yet before 2.6, and not enough before 3.0a1 :-)
2007-08-30 21:01:17 +00:00
Martin v. Löwis
6819210b9e
PEP 3123: Provide forward compatibility with Python 3.0, while keeping
...
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
2007-07-21 06:55:02 +00:00
Thomas Heller
fe31d77dc0
PyType_stgdict() returns a borrowed reference which must not be
...
Py_DECREF'd.
2007-07-13 19:51:55 +00:00
Thomas Heller
ef4fff3435
Fix for SF# 1649098: avoid zero-sized array declaration in structure.
2007-07-13 17:46:54 +00:00
Thomas Heller
1421b00162
Repair COMError. Since exceptions are new style classes now, setting
...
the methods and docstring after the type creation does not work, they
must be in the dictionary before creating the type.
2007-07-13 13:59:39 +00:00
Thomas Heller
410c3b58c9
Use "O&" in calls to PyArg_Parse when we need a 'void*' instead of "k"
...
or "K" codes.
2007-06-11 15:58:33 +00:00
Thomas Heller
ea7f88e3d9
Fix warnings by using proper function prototype.
2007-06-08 19:14:23 +00:00
Thomas Heller
6088f24df2
Fix gcc warnings intruduced by passing Py_ssize_t to PyErr_Format calls.
2007-06-08 19:01:06 +00:00
Thomas Heller
e81c9f6d5e
[ 1715718 ] x64 clean compile patch for _ctypes, by Kristj?n Valur
...
with small modifications.
2007-06-08 18:20:09 +00:00
Thomas Heller
601aa414b2
Fix compiler warnings.
2007-05-30 06:58:30 +00:00
Thomas Heller
1ad576c267
Do not truncate 64-bit pointers to 32-bit integers.
...
Fixes SF #1703286 , will backport to release25-maint.
2007-05-04 19:54:22 +00:00
Thomas Heller
db3bfdf141
On 64-bit Windows, ffi_arg must be 8 bytes long. This fixes the
...
remaining crashes in the ctypes tests, when functions return float or
double types.
2007-05-04 08:20:41 +00:00
Thomas Heller
9b73d0aed5
Don't truncate pointers to integers (on win64 platform).
2007-05-03 12:05:20 +00:00
Thomas Heller
68bb9a1418
When accessing the .value attribute of a c_wchar_p instance, and the
...
instance does not point to a valid wchar_t zero-terminated string,
raise a ValueError. c_char_p does this already.
The ValueError message now contains the correct pointer address.
Will backport to release25-maint.
2007-04-30 16:04:57 +00:00
Thomas Heller
5a901bd3cc
Make sure to call PyErr_NoMemory() in several places where
...
PyMem_Malloc() could potentially fail.
Will backport to the release25-maint branch.
2007-04-30 15:44:17 +00:00
Kristján Valur Jónsson
17b8e97e2e
Merge change 54909 from release25-maint: Fix several minor issues discovered using code analysis in VisualStudio 2005 Team Edition
2007-04-25 00:10:50 +00:00
Thomas Heller
e6a7039451
Prevent creation (followed by a segfault) of array types when the size
...
overflows the valid Py_ssize_t range. Check return values of
PyMem_Malloc.
Will backport to release25-maint.
2007-03-23 19:55:27 +00:00
Thomas Heller
82730f8d11
Explain the purpose of the b_needsfree flag (forward ported from release25-maint).
2007-03-22 20:34:37 +00:00
Thomas Heller
f493cbd824
Back out "Patch #1643874 : memory leak in ctypes fixed."
...
The code in this patch leaves no way to give up the ownership of a
BSTR instance.
2007-03-22 19:44:31 +00:00