summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2015-08-08 11:38:59 (GMT)
committerStefan Krah <skrah@bytereef.org>2015-08-08 11:38:59 (GMT)
commit5f35725fb846f2427b4bd19553d15e73747746eb (patch)
tree28783880546e5e67ec034bafb5704193f16991f1 /Objects
parent9548f1ee3854b5c9b0f2ef05c49cf42db22f8a4f (diff)
parent0c51595a784787d8e198af910cb6d79172ee52bb (diff)
downloadcpython-5f35725fb846f2427b4bd19553d15e73747746eb.zip
cpython-5f35725fb846f2427b4bd19553d15e73747746eb.tar.gz
cpython-5f35725fb846f2427b4bd19553d15e73747746eb.tar.bz2
Merge #15944.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/memoryobject.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
index 54fd05f..74cad7d 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -1197,13 +1197,6 @@ cast_to_1D(PyMemoryViewObject *mv, PyObject *format)
assert(view->strides == mv->ob_array + view->ndim);
assert(view->suboffsets == mv->ob_array + 2*view->ndim);
- if (get_native_fmtchar(&srcchar, view->format) < 0) {
- PyErr_SetString(PyExc_ValueError,
- "memoryview: source format must be a native single character "
- "format prefixed with an optional '@'");
- return ret;
- }
-
asciifmt = PyUnicode_AsASCIIString(format);
if (asciifmt == NULL)
return ret;
@@ -1216,7 +1209,8 @@ cast_to_1D(PyMemoryViewObject *mv, PyObject *format)
goto out;
}
- if (!IS_BYTE_FORMAT(srcchar) && !IS_BYTE_FORMAT(destchar)) {
+ if ((get_native_fmtchar(&srcchar, view->format) < 0 ||
+ !IS_BYTE_FORMAT(srcchar)) && !IS_BYTE_FORMAT(destchar)) {
PyErr_SetString(PyExc_TypeError,
"memoryview: cannot cast between two non-byte formats");
goto out;