Commit Graph

282 Commits

Author SHA1 Message Date
Segev Finer 735abadd5b bpo-16865: Support arrays >=2GB in ctypes. (GH-3006) 2018-05-15 02:54:29 +03:00
Oren Milman d518d8bc8d bpo-21983: Fix a crash in ctypes.cast() when passed a ctypes structured data type (GH-3859) 2018-05-09 14:38:56 -07:00
Mike 53f7a7c281 bpo-32297: Few misspellings found in Python source code comments. (#4803)
* Fix multiple typos in code comments

* Add spacing in comments (test_logging.py, test_math.py)

* Fix spaces at the beginning of comments in test_logging.py
2017-12-14 13:04:53 +02:00
Victor Stinner 884d13a55f time.clock() now emits a DeprecationWarning (GH-4020)
bpo-31803: time.clock() and time.get_clock_info('clock') now emit a
DeprecationWarning warning.

Replace time.clock() with time.perf_counter() in tests and demos.

Remove also hasattr(time, 'monotonic') in test_time since time.monotonic()
is now always available since Python 3.5.
2017-10-17 14:46:45 -07:00
Oren Milman 57c2561c8c bpo-31311: Fix a SystemError and a crash in ctypes._CData.__setstate__(), in case of a bad __dict__. (#3254) 2017-09-25 11:09:11 +03:00
Oren Milman 30b61b51e0 bpo-31490: Fix an assertion failure in ctypes in case an _anonymous_ attr is defined only outside _fields_. (#3615) 2017-09-17 13:45:38 +03:00
Antoine Pitrou a6a4dc816d bpo-31370: Remove support for threads-less builds (#3385)
* Remove Setup.config
* Always define WITH_THREAD for compatibility.
2017-09-07 18:56:24 +02:00
Pauli Virtanen 07f1658aa0 bpo-10746: Fix ctypes PEP 3118 type codes for c_long, c_bool, c_int (#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.
2017-08-28 14:08:49 +02:00
Serhiy Storchaka f7eae0adfc [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302)
Based on patch by Victor Stinner.

Add private C API function _PyUnicode_AsUnicode() which is similar to
PyUnicode_AsUnicode(), but checks for null characters.
2017-06-28 08:30:06 +03:00
Serhiy Storchaka e613e6add5 bpo-30708: Check for null characters in PyUnicode_AsWideCharString(). (#2285)
Raise a ValueError if the second argument is NULL and the wchar_t\*
string contains null characters.
2017-06-27 16:03:14 +03:00
Erik Bray 9ba3aa4d02 bpo-30353: Fix pass by value for structs on 64-bit Cygwin/MinGW (GH-1559) 2017-06-07 18:42:24 +01:00
Victor Stinner a36e939aeb bpo-30125: disable faulthandler in ctypes test_SEH (#1237)
Disable faulthandler to run test_SEH() of test_ctypes to prevent the
following log with a traceback:

    Windows fatal exception: access violation

Add support.disable_faulthandler() context manager.
2017-04-22 00:31:13 +02:00
Serhiy Storchaka 24c738a9e9 bpo-29845: Mark tests that use _testcapi as CPython-only (#711) 2017-03-19 20:20:10 +02:00
orenmn 1bea762d9e bpo-28129: fix ctypes crashes (#386)
* 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
2017-03-02 18:42:40 +01:00
Vinay Sajip a86339b83f Fixed bpo-29565: Corrected ctypes passing of large structs by value on Windows AMD64. (#168)
* 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).

* Reverted unintended whitespace changes.
2017-02-20 00:16:33 +00:00
Martin Panter 04b35753f7 Issue #25659: Merge ctypes fix from 3.5 2016-11-20 22:07:29 +00:00
Martin Panter 6e723d2d11 Issue #25659: Change assert to TypeError in from_buffer/_copy()
Based on suggestion by Eryk Sun.
2016-11-20 07:58:35 +00:00
Martin Panter 6a8e1ea80c Merge test cleanup from 3.5 into 3.6 2016-09-29 04:40:56 +00:00
Martin Panter c49b4d8ef3 Remove disabled ctypes test
The test was commented out in 2005 before ctypes was added to Python, because
the “cdll” attribute loading feature “will no longer work this way”:
http://svn.python.org/view?view=revision&revision=49102
2016-09-29 02:50:20 +00:00
Martin Panter b745f920c9 Issue #27355: Import no longer needed 2016-09-06 02:18:16 +00:00
Larry Hastings 10108a7b9a Issue #27355: Removed support for Windows CE. It was never finished,
and Windows CE is no longer a relevant platform for Python.
2016-09-05 15:11:23 -07:00
Vinay Sajip 82df3b3071 Closes #9998: Allowed find_library to search additional locations for libraries. 2016-08-17 16:20:07 +01:00
Vinay Sajip a9391a4522 Closes #20160: Merged fix from 3.5. 2016-08-05 21:44:52 +01:00
Vinay Sajip 0b588869ee Issue #20160: Merged fix from 3.4. 2016-08-05 21:44:15 +01:00
Vinay Sajip a0b2568627 Issue #20160: Merged fix from 3.3. 2016-08-05 21:43:25 +01:00
Vinay Sajip 6f25003291 Issue #20160: Handled passing of large structs to callbacks correctly. 2016-08-05 21:24:27 +01:00
Martin Panter 8bde911115 Issue #27626: Merge spelling fixes from 3.5 2016-07-28 01:30:58 +00:00
Martin Panter eb9957065a Issue #27626: Spelling fixes in docs, comments and internal names
Based on patch by Ville Skyttä.
2016-07-28 01:11:04 +00:00
Benjamin Peterson ab078e9ed1 Backed out changeset af29d89083b3 (closes #25548) (closes #27498) 2016-07-13 21:13:29 -07:00
Serhiy Storchaka d91e676fd5 Issue #27343: Fixed error message for conflicting initializers of ctypes.Structure. 2016-06-18 09:58:55 +03:00
Serhiy Storchaka 886a5f352f Issue #27343: Fixed error message for conflicting initializers of ctypes.Structure. 2016-06-18 09:58:24 +03:00
Martin Panter 1db314bd5c Issue #22636: Merge ctypes.util shell injection fixes from 3.5 2016-06-14 02:59:21 +00:00
Martin Panter bfb15ab711 Issue #22636: avoid using a shell in the ctypes.util module
Replace os.popen() with subprocess.Popen. Based on patch by Victor Stinner.

If the "gcc", "cc" or "objdump" command is not available, the code was
supposed to raise an OSError exception. But there was a bug in the code. The
shell code returns the exit code 10 if the required command is missing, and the
code tries to check for the status 10. The problem is that os.popen() doesn't
return the exit code directly, but a status which should be processed by
os.WIFEXITED() and os.WEXITSTATUS(). In practice, the exception was never
raised. The OSError exception was not documented and ctypes.util.find_library()
is expected to return None if the library is not found.
2016-06-14 01:27:11 +00:00
Kushal Das 5801ecb440 Issue #25548: Showing memory address of class objects in repl 2016-06-04 16:21:13 -07:00
Serhiy Storchaka b0f80b0312 Issue #26647: Python interpreter now uses 16-bit wordcode instead of bytecode.
Patch by Demur Rumed.
2016-05-24 09:15:14 +03:00
Martin Panter 4dd27f0adc Issue #25533: Merge frozen module docs from 3.5 2016-05-15 00:41:40 +00:00
Martin Panter f47a400347 Issue #25533: Update documentation regarding the frozen modules table
* "ctypes" documentation was using Python 2 bytes-str equivalence.
* PyImport_FrozenModules is a pointer to const as of Python 3.4
2016-05-15 00:13:04 +00:00
Martin Panter 38e2f175ea Remove old Python 2 compatibility from ctypes test 2016-05-14 06:17:43 +00:00
Serhiy Storchaka a6f26c1d34 Remove more unused imports in tests. 2016-04-25 00:05:30 +03:00
Serhiy Storchaka e437a10d15 Issue #23277: Remove unused imports in tests. 2016-04-24 21:41:02 +03:00
Berker Peksag 1e8ee9b380 Issue #23277: Remove unused sys and os imports
Patch by Jon Dufresne.
2016-04-24 07:31:42 +03:00
Martin Panter 32f2eb4941 Issue #21042: Revert Linux find_library() to return just filename
This reverts most of revision 3092cf163eb4. The change worked on x86
architectures, but did not work on ARM, probably due to extra ABI flags in
the ldconfig output.
2016-03-17 07:50:22 +00:00
Martin Panter b9f3114d42 Issue #21042: Return full path in ctypes.util.find_library() on Linux
Patch by Tamás Bence Gedai.
2016-03-10 01:06:23 +00:00
Martin Panter 34360c8e09 Issue #19023: Document ctypes array and pointer classes
Also add some more tests. Based on patch by Sye van der Veen.
2016-01-29 10:12:19 +00:00
Martin Panter 077e36af25 Issue #25622: Use repr(bytes) to avoid BytesWarning 2015-11-26 02:36:26 +00:00
Martin Panter 7b2eb81997 Issue #25622: Merge ctypes test from 3.4 into 3.5 2015-11-26 10:26:33 +00:00
Martin Panter 92072ac8b4 Issue #25622: Rename to PythonValuesTestCase and enable for non-Windows 2015-11-26 02:36:26 +00:00
Martin Panter 75559affad Issue #25498: Update error message for 3.5 2015-11-13 22:12:58 +00:00
Martin Panter 0da4ac1f21 Issue #25498: Merge ctypes crash fix from 3.4 into 3.5 2015-11-13 22:12:12 +00:00
Martin Panter 1bb651540e Issue #25498: Fix GC crash due to ctypes objects wrapping a memoryview
This was a regression caused by revision 1da9630e9b7f.  Based on patch by
Eryksun.
2015-11-13 21:43:39 +00:00