summaryrefslogtreecommitdiff
path: root/Modules/_struct.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-02-02 14:24:16 +0100
committerVictor Stinner <victor.stinner@gmail.com>2017-02-02 14:24:16 +0100
commitc0f59ad1455a53b6a8a9f09620ae4283e4df9f26 (patch)
tree2777c138d7b040194dba9a44926a325755a601dd /Modules/_struct.c
parenta0e454b69d4e00c75eb04ffe7268b65dc51ae54b (diff)
downloadcpython-git-c0f59ad1455a53b6a8a9f09620ae4283e4df9f26.tar.gz
Rename struct.unpack() 2nd parameter to "buffer"
Issue #29300: Rename struct.unpack() second parameter from "inputstr" to "buffer", and use the Py_buffer type. Fix also unit tests on struct.unpack() which passed a Unicode string instead of a bytes string as struct.unpack() second parameter. The purpose of test_trailing_counter() is to test invalid format strings, not to test the buffer parameter.
Diffstat (limited to 'Modules/_struct.c')
-rw-r--r--Modules/_struct.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c
index 3626bad033..78cd0f3401 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -2162,7 +2162,7 @@ pack_into(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
unpack
format: object
- inputstr: object
+ buffer: Py_buffer
/
Return a tuple containing values unpacked according to the format string.
@@ -2173,8 +2173,8 @@ See help(struct) for more on format strings.
[clinic start generated code]*/
static PyObject *
-unpack_impl(PyObject *module, PyObject *format, PyObject *inputstr)
-/*[clinic end generated code: output=06951d66eae6d63b input=4b81d54988890f5e]*/
+unpack_impl(PyObject *module, PyObject *format, Py_buffer *buffer)
+/*[clinic end generated code: output=f75ada02aaa33b3b input=654078e6660c2df0]*/
{
PyStructObject *s_object;
PyObject *result;
@@ -2182,7 +2182,7 @@ unpack_impl(PyObject *module, PyObject *format, PyObject *inputstr)
s_object = cache_struct(format);
if (s_object == NULL)
return NULL;
- result = Struct_unpack(s_object, inputstr);
+ result = Struct_unpack_impl(s_object, buffer);
Py_DECREF(s_object);
return result;
}