This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Replace buffer()-->memoryview() in Lib/ctypes/test/
Type: behavior Stage: resolved
Components: ctypes Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: theller Nosy List: flox, pitrou, theller
Priority: normal Keywords: patch

Created on 2010-01-14 14:17 by flox, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue7703_ctypes_memoryview.diff flox, 2010-01-14 14:20 Patch, apply to trunk
issue7703_test_ctypes.diff flox, 2010-01-14 14:23 Patch, apply to trunk
Messages (13)
msg97765 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-14 14:17
In order to upgrate the tests for ctypes, following changes are required:
 - binascii.hexlify should accept memoryview() objects
 - the ctypes character buffer should accept assignment of memoryview() objects using their "raw" property

Then we can backport the Py3 ctypes tests to Py2.
msg97766 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-14 14:23
Patches attached:
 - partial backport of Modules/binascii.c
 - partial backport of Modules/_ctypes/_ctypes.c (preserving 2.3 compat.)
 - update ctypes tests (buffer -> memoryview)
msg97768 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-01-14 14:47
Does binascii still work with array.array objects? Also, there should be additional tests for compatibility of binascii with memoryview objects.
msg97769 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-14 15:17
Additional tests for binascii.
msg97772 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-01-14 16:01
Please be careful with the coding style. Stuff like:

+			  if (_PyString_Resize(&rv, 2*out_len) < 0) \
+			    { Py_DECREF(rv); PyBuffer_Release(&pin); return NULL; } \

should be spread out on several lines.
Otherwise, the binascii patch looks good.
msg97773 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-01-14 16:35
I've now committed the binascii patch + tests to trunk, and merged the tests into py3k.

Note: binascii_a2b_hqx() still uses the "t#" argument specifier in py3k as well as in trunk, this would deserve a separate patch.
msg97867 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-16 10:10
Patch for the last "t#" format string in binascii module.
And provide additional tests.

PS: I removed this comment. IMHO, it is a wrong assertion:
        "# The hqx test is in test_binhex.py"
msg97868 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-01-16 10:46
I don't think the bytes -> bytearray changes are useful, e.g.:

-        fillers = ""
+        fillers = bytearray()

As for:

+            try:
+                f(empty)
+            except SystemError, err:
+                self.fail("{}({!r}) raises SystemError: {}".format(func, empty, err))
+            except Exception, err:
+                self.fail("{}({!r}) raises {!r}".format(func, empty, err))

The "except SystemError" is pointless, since "except Exception" will catch SystemError anyway.
msg97872 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-16 11:45
Changed.
msg97877 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-16 13:14
Removed no-op str("...") conversions.
msg97885 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-01-16 17:42
When the following snippet is taken:

	if (_PyString_Resize(&rv,
			   (bin_data -
			    (unsigned char *)PyString_AS_STRING(rv))) < 0) {
		PyBuffer_Release(&pascii);
		Py_DECREF(rv);
		rv = NULL;
	}

pascii will get released a second time at the end of function. The rest is fine, I'm gonna fix it myself.
msg97886 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-01-16 17:57
The a2b_hqx() patch was committed in r77528 (trunk) and r77529 (py3k). Thanks again!
msg101518 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-03-22 16:09
Fixed with r79288 and r79295.
History
Date User Action Args
2022-04-11 14:56:56adminsetgithub: 51952
2010-03-22 16:09:41floxsetstatus: open -> closed
priority: normal
messages: + msg101518

resolution: fixed
stage: patch review -> resolved
2010-01-16 17:57:49pitrousetfiles: - issue7703_binascii_a2b_hqx_v3.diff
2010-01-16 17:57:44pitrousetmessages: + msg97886
2010-01-16 17:42:44pitrousetmessages: + msg97885
2010-01-16 13:14:17floxsetfiles: + issue7703_binascii_a2b_hqx_v3.diff

messages: + msg97877
2010-01-16 13:11:53floxsetfiles: - issue7703_binascii_a2b_hqx_v2.diff
2010-01-16 11:45:38floxsetfiles: + issue7703_binascii_a2b_hqx_v2.diff

messages: + msg97872
2010-01-16 11:45:09floxsetfiles: - issue7703_binascii_a2b_hqx.diff
2010-01-16 10:46:20pitrousetmessages: + msg97868
2010-01-16 10:10:57floxsetfiles: + issue7703_binascii_a2b_hqx.diff

messages: + msg97867
2010-01-14 16:35:48pitrousetfiles: - issue7703_binascii_memoryview.diff
2010-01-14 16:35:46pitrousetfiles: - issue7703_test_binascii.diff
2010-01-14 16:35:36pitrousetmessages: + msg97773
2010-01-14 16:01:54pitrousetmessages: + msg97772
2010-01-14 15:17:13floxsetfiles: + issue7703_test_binascii.diff

messages: + msg97769
2010-01-14 14:47:14pitrousetnosy: + pitrou
messages: + msg97768
2010-01-14 14:23:34floxsetfiles: + issue7703_test_ctypes.diff

assignee: theller
components: + ctypes

nosy: + theller
messages: + msg97766
stage: needs patch -> patch review
2010-01-14 14:20:02floxsetfiles: + issue7703_ctypes_memoryview.diff
2010-01-14 14:19:48floxsetfiles: + issue7703_binascii_memoryview.diff
keywords: + patch
2010-01-14 14:17:09floxcreate