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
Thomas Heller
5dc4fe09b7
Patch #1649190 : Adding support for _Bool to ctypes as c_bool, by David Remahl.
2007-03-13 20:42:52 +00:00
Thomas Heller
2456a3c02a
Bug #1651235 : When a tuple was passed to a ctypes function call,
...
Python would crash instead of raising an error.
The crash was caused by a section of code that should have been
removed long ago, at that time ctypes had other ways to pass
parameters to function calls.
2007-03-09 20:39:22 +00:00
Thomas Heller
c2f7725c86
Fix bug #1646630 : ctypes.string_at(buf, 0) and ctypes.wstring_at(buf, 0)
...
returned string up to the first NUL character.
2007-03-09 19:21:28 +00:00
Thomas Heller
4378215474
Fix for #1643874 : When calling SysAllocString, create a PyCObject
...
which will eventually call SysFreeString to free the BSTR resource.
2007-01-25 18:34:14 +00:00
Thomas Heller
2e07810ef0
Replace C++ comments with C comments.
2007-01-17 09:40:34 +00:00
Thomas Heller
8138c26a83
Fixes for 64-bit Windows: In ctypes.wintypes, correct the definitions
...
of HANDLE, WPARAM, LPARAM data types. Make parameterless foreign
function calls work.
2007-01-11 21:18:56 +00:00
Thomas Heller
9ae562efb1
Must change the version number in the _ctypes extension as well.
2007-01-10 20:51:19 +00:00
Thomas Heller
ef583a4992
Fix #1563807 : _ctypes built on AIX fails with ld ffi error.
...
The contents of ffi_darwin.c must be compiled unless __APPLE__ is
defined and __ppc__ is not.
Will backport.
2006-11-28 20:21:54 +00:00
Thomas Heller
25d208bd46
Fix bug #1598620 : A ctypes structure cannot contain itself.
2006-11-24 18:45:39 +00:00
Martin v. Löwis
1b2f627f96
- Patch #1560695 : Add .note.GNU-stack to ctypes' sysv.S so that
...
ctypes isn't considered as requiring executable stacks.
Will backport to 2.5.
2006-10-22 10:55:15 +00:00
Martin v. Löwis
a811c38d8e
Fix various minor errors in passing arguments to
...
PyArg_ParseTuple.
2006-10-19 11:00:37 +00:00
Thomas Heller
d2ea4a2584
ctypes callback functions only support 'fundamental' result types.
...
Check this and raise an error when something else is used - before
this change ctypes would hang or crash when such a callback was
called. This is a partial fix for #1574584 .
Will backport to release25-maint.
2006-10-17 19:30:48 +00:00
Thomas Heller
2244af596a
The cast function did not accept c_char_p or c_wchar_p instances
...
as first argument, and failed with a 'bad argument to internal function'
error message.
2006-09-07 19:09:54 +00:00
Thomas Heller
fdb62f0e5f
Anonymous structure fields that have a bit-width specified did not work,
...
and they gave a strange error message from PyArg_ParseTuple:
function takes exactly 2 arguments (3 given).
With tests.
2006-09-07 18:56:28 +00:00
Thomas Heller
b1a7d758e2
Add missing file for _ctypes.pyd port to win64 on AMD64.
2006-08-25 07:34:51 +00:00
Thomas Heller
98619f267c
Port _ctypes.pyd to win64 on AMD64.
2006-08-25 07:27:33 +00:00
Neal Norwitz
9b17eba8be
Move assert to after NULL check, otherwise we deref NULL in the assert.
...
Klocwork #307
2006-08-19 04:23:04 +00:00
Thomas Heller
0b21b43d49
Add asserts to check for 'impossible' NULL values, with comments.
...
In one place where I'n not 1000% sure about the non-NULL, raise
a RuntimeError for safety.
This should fix the klocwork issues that Neal sent me. If so,
it should be applied to the release25-maint branch also.
2006-08-18 14:38:46 +00:00
Thomas Heller
b4a0cf17c4
Remove the special casing of Py_None when converting the return value
...
of the Python part of a callback function to C. If it cannot be
converted, call PyErr_WriteUnraisable with the exception we got.
Before, arbitrary data has been passed to the calling C code in this
case.
(I'm not really sure the NEWS entry is understandable, but I cannot
find better words)
2006-08-16 15:10:12 +00:00
Thomas Heller
b0aa98fd4f
The __repr__ method of a NULL py_object does no longer raise an
...
exception. Remove a stray '?' character from the exception text
when the value is retrieved of such an object.
Includes tests.
2006-08-16 14:07:44 +00:00
Thomas Heller
d32e616722
Add commented assert statements to check that the result of
...
PyObject_stgdict() and PyType_stgdict() calls are non-NULL before
dereferencing the result. Hopefully this fixes what klocwork is
complaining about.
Fix a few other nits as well.
2006-08-16 13:03:11 +00:00
Thomas Heller
4dc5dd1f3b
Check for NULL return value from new_CArgObject calls.
2006-08-15 13:07:21 +00:00
Thomas Heller
ef8d513d62
Patch #1536908 : Add support for AMD64 / OpenBSD.
...
Remove the -no-stack-protector compiler flag for OpenBSD
as it has been reported to be unneeded.
2006-08-14 16:17:41 +00:00
Thomas Heller
867200483b
Apply the patch #1532975 plus ideas from the patch #1533481 .
...
ctypes instances no longer have the internal and undocumented
'_as_parameter_' attribute which was used to adapt them to foreign
function calls; this mechanism is replaced by a function pointer in
the type's stgdict.
In the 'from_param' class methods, try the _as_parameter_ attribute if
other conversions are not possible.
This makes the documented _as_parameter_ mechanism work as intended.
Change the ctypes version number to 1.0.1.
2006-08-14 11:17:48 +00:00
Thomas Heller
e6dd31c50b
Revert the change that tries to zero out a closure's result storage
...
area because the size if unknown in source/callproc.c.
2006-08-14 10:02:24 +00:00
Thomas Heller
dca703fbda
Check for NULL return value of GenericCData_new().
...
Fixes klockwork issues #188 , #189 .
2006-08-14 07:50:14 +00:00
Thomas Heller
efa2727334
Check for NULL return value from new_CArgObject().
...
Fixes klockwork issues #183 , #184 , #185 .
2006-08-14 07:14:09 +00:00
Thomas Heller
acdedfbf0a
Remove unused, buggy test function.
...
Fixes klockwork issue #207 .
2006-08-14 07:13:05 +00:00
Neal Norwitz
93bf902242
Handle alloca failures.
...
Klocwork 225-228
2006-08-13 18:40:39 +00:00
Neal Norwitz
6b4953fd3d
Check returned pointer is valid.
...
Klocwork #233
2006-08-12 02:06:34 +00:00
Thomas Heller
2a899c8b76
When a ctypes C callback function is called, zero out the result
...
storage before converting the result to C data. See the comment in
the code for details.
Provide a better context for errors when the conversion of a callback
function's result cannot be converted.
2006-08-11 19:55:35 +00:00
Thomas Heller
d61d0733cb
Speed up PyType_stgdict and PyObject_stgdict.
2006-08-01 19:14:15 +00:00
Thomas Heller
11d68a6ac4
Minimal useful docstring for CopyComPointer.
2006-08-01 17:46:10 +00:00
Thomas Heller
3de83e9b61
Fix a potential segfault and various potentail refcount leaks
...
in the cast() function.
2006-08-01 16:54:43 +00:00
Thomas Heller
1393d6a4ca
Patch #1529514 : More openbsd platforms for ctypes.
...
Regenerated Modules/_ctypes/libffi/configure with autoconf 2.59.
Approved by Neal.
2006-07-28 21:43:20 +00:00
Thomas Heller
944f3b6ecb
Remove a useless XXX comment.
...
Cosmetic changes to the code so that the #ifdef _UNICODE block
doesn't mess emacs code formatting.
2006-07-28 19:42:40 +00:00
Neal Norwitz
93f2ca1f85
Check the allocation of b_objects and return if there was a failure.
...
Also fix a few memory leaks in other failure scenarios.
It seems that if b_objects == Py_None, we will have an extra ref to
b_objects. Add XXX comment so hopefully someone documents why the
else isn't necessary or adds it in.
Reported by Klocwork #20
2006-07-23 07:55:55 +00:00
Thomas Heller
100a4e944b
Make sure the _ctypes extension can be compiled when WITH_THREAD is
...
not defined on Windows, even if that configuration is probably not
supported at all.
2006-07-19 09:09:32 +00:00
Neal Norwitz
109f91414f
proto was dereffed above and is known to be good. No need for X.
...
Reported by Klocwork, #39 .
2006-07-16 02:05:35 +00:00
Thomas Heller
ce049a0aef
Patch #1521817 : The index range checking on ctypes arrays containing
...
exactly one element is enabled again.
2006-07-14 17:51:14 +00:00
Thomas Heller
9f902470da
Make the prototypes of our private PyUnicode_FromWideChar and
...
PyUnicode_AsWideChar replacement functions compatible to the official
functions by using Py_ssize_t instead of int.
2006-07-14 15:01:05 +00:00
Thomas Heller
b4dc2ef5da
A misspelled preprocessor symbol caused ctypes to be always compiled
...
without thread support. Replaced WITH_THREADS with WITH_THREAD.
2006-07-13 09:53:47 +00:00
Thomas Heller
3b9be2ae6f
Change the ctypes version number to 1.0.0.
2006-07-11 18:40:50 +00:00
Thomas Heller
7644262aa5
Assigning None to pointer type structure fields possible overwrote
...
wrong fields.
2006-07-10 11:11:10 +00:00
Thomas Heller
7b1da513fd
Fixed a segfault when ctypes.wintypes were imported on
...
non-Windows machines.
2006-07-10 09:31:06 +00:00
Thomas Heller
dda068dee1
Fix bug #1518190 : accept any integer or long value in the
...
ctypes.c_void_p constructor.
2006-07-10 09:10:28 +00:00
Thomas Heller
5becdbee96
Patch #1517790 : It is now possible to use custom objects in the ctypes
...
foreign function argtypes sequence as long as they provide a
from_param method, no longer is it required that the object is a
ctypes type.
2006-07-06 08:48:35 +00:00