Commit Graph

338 Commits

Author SHA1 Message Date
Miss Islington (bot) 53e2248a94
bpo-10320: Replace nonstandard sprintf() length modifier in ctypes' PyCArg_repr(). (GH-10853)
Use "ll" instead of the nonstandard "q".
(cherry picked from commit 062cbb6772)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-12-18 15:51:04 -08:00
Serhiy Storchaka 93d7918f77
[2.7] bpo-16865: Support arrays >=2GB in ctypes. (GH-3006). (GH-7441)
(cherry picked from commit 735abadd5b)

Co-Authored-By: Segev Finer <segev208@gmail.com>
2018-12-04 12:38:07 +02:00
Vladimir Matveev b63a16febb [2.7] bpo-34603, ctypes/libffi_msvc: Fix returning structs from functions (GH-9258) (GH-9425)
Co-authored-by: Vladimir Matveev <v2matveev@outlook.com>
2018-09-19 13:48:21 -07:00
Victor Stinner dd4d8b4d80
Fix compilation warnings on Windows (GH-8627)
* Fix compilation warning in _ctypes module on Window

(cherry picked from commit 20f11fe43c)

* Fix compilation warnings on Windows 64-bit

(cherry picked from commit 725e421222)

* Fix compiler warning in unicodeobject.c

Explicitly case to Py_UNICODE to fix the warning:

Objects\unicodeobject.c(4225): warning C4244: '=' :
conversion from 'long' to 'Py_UNICODE', possible loss of data

The downcast cannot overflow since we check that value <= 0x10ffff.
2018-08-02 18:02:59 +02:00
Victor Stinner 6a6b248347
bpo-29565: Fix compilation for C89 (GH-8626)
Use a local scope for the 'i' variable.
2018-08-02 17:40:11 +02:00
Victor Stinner 3243f8c1fb
bpo-29565: Corrected ctypes passing of large structs by value on Windows AMD64 (GH-168) (GH-8625)
Fixed bpo-29565: Corrected ctypes passing of large structs by value.

Added code and test to check that when a structure passed by value
is large enough to need to be passed by reference, a copy of the
original structure is passed. The callee updates the passed-in value,
and the test verifies that the caller's copy is unchanged. A similar
change was also added to the test added for bpo-20160 (that test was
passing, but the changes should guard against regressions).

(cherry picked from commit a86339b83f)
2018-08-02 16:47:26 +02:00
Serhiy Storchaka 48c8bf21f9
[2.7] bpo-34234: Use _PyAnyInt_Check() and _PyAnyInt_CheckExact(). (GH-8479) 2018-07-31 09:09:36 +03:00
Oren Milman fb3bb8d5d5 [2.7] bpo-31490: Fix an assertion failure in ctypes in case an _anonymous_ attr is defined only outside _fields_. (GH-3615) (#3952) 2017-10-12 17:39:01 +03:00
Victor Stinner 8b83687bdf bpo-28129: fix ctypes crashes (#386) (#3800)
* init commit, with initial tests for from_param and fields __set__ and __get__, and some additions to from_buffer and from_buffer_copy

* added the rest of tests and patches. probably only a first draft.

* removed trailing spaces

* replace ctype with ctypes in error messages

* change back from ctypes instance to ctype instance

(cherry picked from commit 1bea762d9e)
2017-09-28 07:31:40 -07:00
Miss Islington (bot) 9bfa55bfea [2.7] bpo-31490: Fix an assertion failure in ctypes in case an _anonymous_ attr is defined only outside _fields_. (GH-3615) (#3780)
(cherry picked from commit 30b61b51e0)
2017-09-27 09:52:44 +03:00
Serhiy Storchaka 81691b0548 [2.7] bpo-31311: Fix a SystemError and a crash in ctypes._CData.__setstate__(), in case of a bad __dict__. (GH-3254). (#3781)
(cherry picked from commit 57c2561c8c)
2017-09-27 09:24:39 +03:00
Benjamin Peterson a72d15c97f consistently use Py_TYPE, Py_REFCNT, and correct initializer macros (#3563)
This no-op change makes 2.7 more consistent with 3.x to ease comparison and backports.
2017-09-13 21:20:29 -07:00
Pauli Virtanen 990b2d043c [2.7] bpo-10746: Fix ctypes PEP 3118 type codes for c_long, c_bool, c_int (GH-31) (#3242)
[2.7] bpo-10746: Fix ctypes PEP 3118 type codes for c_long, c_bool, c_int (GH-31)

Ctypes currently produces wrong pep3118 type codes for several types.
E.g. memoryview(ctypes.c_long()).format gives "<l" on 64-bit platforms,
but it should be "<q" instead for sizeof(c_long) == 8

The problem is that the '<>' endian specification in the struct syntax
also turns on the "standard size" mode, which makes type characters have
a platform-independent meaning, which does not match with the codes used
internally in ctypes.  The struct module format syntax also does not
allow specifying native-size non-native-endian items.

This commit adds a converter function that maps the internal ctypes
codes to appropriate struct module standard-size codes in the pep3118
format strings. The tests are modified to check for this..
(cherry picked from commit 07f1658aa0)
2017-09-02 18:24:32 +02:00
Serhiy Storchaka 5e79321742 bpo-30074: Fix compile warnings of _PySlice_Unpack and convert missed (#1154)
PySlice_GetIndicesEx in _ctypes.c.
2017-04-15 20:11:12 +03:00
Serhiy Storchaka e41390aca5 bpo-27867: Expand the PySlice_GetIndicesEx macro. (#1023) (#1046)
(cherry picked from commit b879fe8)
2017-04-08 11:48:57 +03:00
Serhiy Storchaka 99ba17f553 Issue #29082: Fixed loading libraries in ctypes by unicode names on Windows.
Original patch by Chi Hsuan Yen.
2017-01-12 17:00:32 +02:00
Martin Panter fd08fdc7be Issue #25659: Change assert to TypeError in from_buffer/_copy()
Based on suggestion by Eryk Sun.
2016-11-20 09:35:06 +00:00
Ned Deily 0436cebb8f Issue #24381: Avoid unused function warning when building bundled macOS libffi.
Patch by Vajrasky Kok.
2016-10-20 15:41:11 -04:00
Serhiy Storchaka 36beb5ec13 Issue #27963: Fixed possible null pointer dereference in ctypes.set_conversion_mode().
Patch by Xiang Zhang.
2016-09-27 15:24:13 +03:00
Martin Panter ca56dd4767 Issue #28139: Fix messed up indentation
Also update the classmethod and staticmethod doc strings and comments to
match the RST documentation.
2016-09-17 07:54:55 +00:00
Martin Panter 6507657ddd Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-09-07 12:03:06 +00:00
Martin Panter 6eec87810f Issue #27570: Avoid zero-length memcpy() calls with null source pointers 2016-09-07 11:04:41 +00:00
Benjamin Peterson 28e2771f24 Backed out changeset 8b6be1341770 2016-09-05 17:22:09 -07:00
Benjamin Peterson bbc8fe1841 remove long double from ctypes value union
It is unused. It also forces a 16-byte alignment, which creates problems because
Python's allocator only uses 8-byte alignment.
2016-09-05 16:24:52 -07:00
Vinay Sajip e1f3afbde2 Issue #20160: Handled passing of large structs to callbacks correctly. 2016-08-05 21:10:26 +01:00
Martin Panter a850ef698e Issue #27626: Spelling fixes in docs, comments and internal names
Based on patch by Ville Skyttä.
2016-07-28 01:11:04 +00:00
Martin Panter e2eacc02bc Issue #23943: Fix typos. Patch by Piotr Kasprzyk. 2016-07-28 03:04:04 +00:00
Victor Stinner 2e1a34025c ctypes: fix CThunkObject_new()
* Initialize restype and flags fields to fix a crash when Python runs on a
  read-only file system
* Use Py_ssize_t type rather than int for the "i" iterator variable
* Reorder assignements to be able to more easily check if all fields are
  initialized

Issue #11048. Initial patch written by Marcin Bachry.
2016-07-27 16:58:47 +02:00
Martin Panter b362f75f6e Issue #25523: Correct "a" article to "an" article
This changes the main documentation, doc strings, source code comments, and a
couple error messages in the test suite. In some cases the word was removed
to fix the grammar.
2015-11-02 03:37:02 +00:00
Martin Panter b3eaaf0bfc Issue #22463: Cure unused function warnings on AIX 2016-06-22 02:46:33 +00:00
Martin Panter 646b528467 Issue #22463: Backport compiler warning fixes and workarounds
* Set but unused variable in Parser/pgen.c in non-debug builds. Patch by
  Christian Heimes.
* Unused static function in Modules/readline.c. Patch by Georg Brandl.
* main_window unused in Modules/tkappinit.c. Patch by Gregory P. Smith.
* Dead assignment in Modules/_ctypes/cfield.c. Extracted from patch by Brett
  Cannon.
* Expression result unused in PyObject_INIT macro expansions. Based on
  patches by Christian Heimes.
* Load expat_config.h and therefore pyconfig.h before C stdlib headers are
  loaded. This silences pre-processor warnings including '_POSIX_C_SOURCE
  redefined'. Extracted from patch by Christian Heimes.
2016-06-21 23:58:05 +00:00
Serhiy Storchaka f46d3afc51 ctypes: the type of b_size is Py_ssize_t. 2016-06-17 11:11:07 +03:00
Serhiy Storchaka ef012cc7f7 Issue #27330: Fixed possible leaks in the ctypes module. 2016-06-16 22:08:11 +03:00
Martin Panter 200a615774 Issue #27125: Remove duplicated words from documentation and comments 2016-05-30 04:04:50 +00:00
Martin Panter f45c1755c3 Remove PEP 291 compatibility requirements for ctypes and modulefinder
https://mail.python.org/pipermail/python-dev/2016-May/144502.html
2016-05-14 07:25:37 +00:00
Serhiy Storchaka 9a118f1dc3 Issue #26778: Fixed "a/an/and" typos in code comment and documentation. 2016-04-17 09:37:36 +03:00
Serhiy Storchaka 763a61ca95 Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREF
in places where Py_DECREF was used.
2016-04-10 18:05:12 +03:00
Serhiy Storchaka bc62af1bbe Issue #22570: Renamed Py_SETREF to Py_XSETREF. 2016-04-06 09:51:18 +03:00
Martin Panter 53ae0ba6e3 Issue #26304: Change "allows to <verb>" to "allows <verb>ing" or similar
The original form is incorrect grammar and feels awkward, even though the
meaning is clear.
2016-02-10 05:44:01 +00:00
Serhiy Storchaka 2e6c829681 Issue #20440: More use of Py_SETREF.
This patch is manually crafted and contains changes that couldn't be handled
automatically.
2015-12-27 15:41:58 +02:00
Serhiy Storchaka 5951f2300f Issue #20440: Massive replacing unsafe attribute setting code with special
macro Py_SETREF.
2015-12-24 10:35:35 +02:00
Victor Stinner e97944a27e Issue #23319: Fix ctypes.BigEndianStructure, swap correctly bytes. Patch
written by Matthieu Gautier.
2015-07-29 14:37:17 +02:00
Benjamin Peterson 36691efe7b fix libffi compilation on FreeBSD (#23042)
Patch from Marc-Andre Lemburg.
2015-05-08 21:31:36 -04:00
Serhiy Storchaka 37943b07fe Issue #23338: Fixed formatting ctypes error messages on Cygwin.
Patch by Makoto Kato.
2015-04-04 10:05:35 +03:00
Serhiy Storchaka a2269d074b Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer
overflows.  Added few missed PyErr_NoMemory().
2015-02-16 13:16:07 +02:00
Benjamin Peterson 07f90476b9 fix instances of consecutive articles (closes #23221)
Patch by Karan Goel.
2015-01-13 09:17:24 -05:00
Benjamin Peterson 9dcab59b08 fix test where sizeof(long) != sizeof(int) 2014-11-06 00:52:58 -05:00
Steve Dower 31221a7285 Issue #20160: broken ctypes calling convention on MSVC / 64-bit Windows (large structs). Patch by mattip 2014-11-05 19:16:05 -08:00
R David Murray 55bf20ad6e #13096: Fix segfault in CTypes POINTER handling of large values.
Patch by Meador Inge.
2014-10-12 14:26:30 -04:00
doko@ubuntu.com baa84b827b - Issue #22176: Update the ctypes module's libffi to v3.1. This release
adds support for the Linux AArch64 and POWERPC ELF ABIv2 little endian
  architectures.
2014-08-10 11:15:28 +02:00