@@ -1960,15 +1960,16 @@ Return a tuple containing unpacked values.
19601960Values are unpacked according to the format string Struct.format.
19611961
19621962The buffer's size in bytes, starting at position offset, must be
1963- at least Struct.size.
1963+ at least Struct.size. A negative offset counts from the end of the
1964+ buffer.
19641965
19651966See help(struct) for more on format strings.
19661967[clinic start generated code]*/
19671968
19681969static PyObject *
19691970Struct_unpack_from_impl (PyStructObject * self , Py_buffer * buffer ,
19701971 Py_ssize_t offset )
1971- /*[clinic end generated code: output=57fac875e0977316 input=cafd4851d473c894 ]*/
1972+ /*[clinic end generated code: output=57fac875e0977316 input=3451f778ed8a5345 ]*/
19721973{
19731974 _structmodulestate * state = get_struct_state_structinst (self );
19741975 ENSURE_STRUCT_IS_READY (self );
@@ -2296,8 +2297,9 @@ PyDoc_STRVAR(s_pack_into__doc__,
22962297\n\
22972298Pack the values v1, v2, ... according to the format string S.format\n\
22982299and write the packed bytes into the writable buffer buf starting at\n\
2299- offset. Note that the offset is a required argument. See\n\
2300- help(struct) for more on format strings." );
2300+ offset. Note that the offset is a required argument. A negative\n\
2301+ offset counts from the end of the buffer. See help(struct) for more\n\
2302+ on format strings." );
23012303
23022304static PyObject *
23032305s_pack_into (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
@@ -2593,8 +2595,8 @@ PyDoc_STRVAR(pack_into_doc,
25932595\n\
25942596Pack the values v1, v2, ... according to the format string and write\n\
25952597the packed bytes into the writable buffer buf starting at offset. Note\n\
2596- that the offset is a required argument. See help(struct) for more \n\
2597- on format strings." );
2598+ that the offset is a required argument. A negative offset counts from \n\
2599+ the end of the buffer. See help(struct) for more on format strings." );
25982600
25992601static PyObject *
26002602pack_into (PyObject * module , PyObject * const * args , Py_ssize_t nargs )
@@ -2648,14 +2650,15 @@ unpack_from
26482650Return a tuple containing values unpacked according to the format string.
26492651
26502652The buffer's size, minus offset, must be at least calcsize(format).
2653+ A negative offset counts from the end of the buffer.
26512654
26522655See help(struct) for more on format strings.
26532656[clinic start generated code]*/
26542657
26552658static PyObject *
26562659unpack_from_impl (PyObject * module , PyStructObject * s_object ,
26572660 Py_buffer * buffer , Py_ssize_t offset )
2658- /*[clinic end generated code: output=1042631674c6e0d3 input=6e80a5398e985025 ]*/
2661+ /*[clinic end generated code: output=1042631674c6e0d3 input=e383ecb97728be2b ]*/
26592662{
26602663 return Struct_unpack_from_impl (s_object , buffer , offset );
26612664}
0 commit comments