@@ -1758,15 +1758,16 @@ Return a tuple containing unpacked values.
17581758Values are unpacked according to the format string Struct.format.
17591759
17601760The buffer's size in bytes, starting at position offset, must be
1761- at least Struct.size.
1761+ at least Struct.size. A negative offset counts from the end of the
1762+ buffer.
17621763
17631764See help(struct) for more on format strings.
17641765[clinic start generated code]*/
17651766
17661767static PyObject *
17671768Struct_unpack_from_impl (PyStructObject * self , Py_buffer * buffer ,
17681769 Py_ssize_t offset )
1769- /*[clinic end generated code: output=57fac875e0977316 input=cafd4851d473c894 ]*/
1770+ /*[clinic end generated code: output=57fac875e0977316 input=3451f778ed8a5345 ]*/
17701771{
17711772 _structmodulestate * state = get_struct_state_structinst (self );
17721773 ENSURE_STRUCT_IS_READY (self );
@@ -2085,8 +2086,9 @@ PyDoc_STRVAR(s_pack_into__doc__,
20852086\n\
20862087Pack the values v1, v2, ... according to the format string S.format\n\
20872088and write the packed bytes into the writable buffer buf starting at\n\
2088- offset. Note that the offset is a required argument. See\n\
2089- help(struct) for more on format strings." );
2089+ offset. Note that the offset is a required argument. A negative\n\
2090+ offset counts from the end of the buffer. See help(struct) for more\n\
2091+ on format strings." );
20902092
20912093static PyObject *
20922094s_pack_into (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
@@ -2378,8 +2380,8 @@ PyDoc_STRVAR(pack_into_doc,
23782380\n\
23792381Pack the values v1, v2, ... according to the format string and write\n\
23802382the packed bytes into the writable buffer buf starting at offset. Note\n\
2381- that the offset is a required argument. See help(struct) for more \n\
2382- on format strings." );
2383+ that the offset is a required argument. A negative offset counts from \n\
2384+ the end of the buffer. See help(struct) for more on format strings." );
23832385
23842386static PyObject *
23852387pack_into (PyObject * module , PyObject * const * args , Py_ssize_t nargs )
@@ -2433,14 +2435,15 @@ unpack_from
24332435Return a tuple containing values unpacked according to the format string.
24342436
24352437The buffer's size, minus offset, must be at least calcsize(format).
2438+ A negative offset counts from the end of the buffer.
24362439
24372440See help(struct) for more on format strings.
24382441[clinic start generated code]*/
24392442
24402443static PyObject *
24412444unpack_from_impl (PyObject * module , PyStructObject * s_object ,
24422445 Py_buffer * buffer , Py_ssize_t offset )
2443- /*[clinic end generated code: output=1042631674c6e0d3 input=6e80a5398e985025 ]*/
2446+ /*[clinic end generated code: output=1042631674c6e0d3 input=e383ecb97728be2b ]*/
24442447{
24452448 return Struct_unpack_from_impl (s_object , buffer , offset );
24462449}
0 commit comments