Pack the values *v1*, *v2*, ... according to the format string *format* and
write the packed bytes into the writable buffer *buffer* starting at
position *offset*. Note that *offset* is a required argument.
+ A negative *offset* counts from the end of *buffer*.
.. function:: unpack(format, buffer)
string *format*. The result is a tuple even if it contains exactly one
item. The buffer's size in bytes, starting at position *offset*, must be at
least the size required by the format, as reflected by :func:`calcsize`.
+ A negative *offset* counts from the end of *buffer*.
.. function:: iter_unpack(format, buffer)
Values are unpacked according to the format string Struct.format.
The buffer's size in bytes, starting at position offset, must be
-at least Struct.size.
+at least Struct.size. A negative offset counts from the end of the
+buffer.
See help(struct) for more on format strings.
[clinic start generated code]*/
static PyObject *
Struct_unpack_from_impl(PyStructObject *self, Py_buffer *buffer,
Py_ssize_t offset)
-/*[clinic end generated code: output=57fac875e0977316 input=cafd4851d473c894]*/
+/*[clinic end generated code: output=57fac875e0977316 input=3451f778ed8a5345]*/
{
_structmodulestate *state = get_struct_state_structinst(self);
ENSURE_STRUCT_IS_READY(self);
\n\
Pack the values v1, v2, ... according to the format string S.format\n\
and write the packed bytes into the writable buffer buf starting at\n\
-offset. Note that the offset is a required argument. See\n\
-help(struct) for more on format strings.");
+offset. Note that the offset is a required argument. A negative\n\
+offset counts from the end of the buffer. See help(struct) for more\n\
+on format strings.");
static PyObject *
s_pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
\n\
Pack the values v1, v2, ... according to the format string and write\n\
the packed bytes into the writable buffer buf starting at offset. Note\n\
-that the offset is a required argument. See help(struct) for more\n\
-on format strings.");
+that the offset is a required argument. A negative offset counts from\n\
+the end of the buffer. See help(struct) for more on format strings.");
static PyObject *
pack_into(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Return a tuple containing values unpacked according to the format string.
The buffer's size, minus offset, must be at least calcsize(format).
+A negative offset counts from the end of the buffer.
See help(struct) for more on format strings.
[clinic start generated code]*/
static PyObject *
unpack_from_impl(PyObject *module, PyStructObject *s_object,
Py_buffer *buffer, Py_ssize_t offset)
-/*[clinic end generated code: output=1042631674c6e0d3 input=6e80a5398e985025]*/
+/*[clinic end generated code: output=1042631674c6e0d3 input=e383ecb97728be2b]*/
{
return Struct_unpack_from_impl(s_object, buffer, offset);
}
"Values are unpacked according to the format string Struct.format.\n"
"\n"
"The buffer\'s size in bytes, starting at position offset, must be\n"
-"at least Struct.size.\n"
+"at least Struct.size. A negative offset counts from the end of the\n"
+"buffer.\n"
"\n"
"See help(struct) for more on format strings.");
"Return a tuple containing values unpacked according to the format string.\n"
"\n"
"The buffer\'s size, minus offset, must be at least calcsize(format).\n"
+"A negative offset counts from the end of the buffer.\n"
"\n"
"See help(struct) for more on format strings.");
return return_value;
}
-/*[clinic end generated code: output=67bd299e5d72fee0 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d74ae26e398819db input=a9049054013a1b77]*/