Author vstinner
Recipients inada.naoki, larry, serhiy.storchaka, vstinner
Date 2017-01-27.08:53:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1485507237.81.0.764966280061.issue29300@psf.upfronthosting.co.za>
In-reply-to
Content
Patch version 3:

* Use also Argument Clinic for Struct.__init__()
* Rename fmt to format: in the code and docstring. By the way, Struct docstring was wrong: Struct() accepts a 'format' keyword argument, not 'fmt'
* Use Py_buffer converter for the buffer parameter, except for iter_unpack()
* Document that unpack_from() now accepts keywords and write an unit test
* Fix Struct.__init__() error message: the method accepts also Unicode
* Document that Struct accepts str encodable to ASCII and bytes

I would be nice to use Py_buffer format for the "buffer" argument of iter_unpack(), but Argument Clinic calls PyBuffer_Release(&buffer), whereas the buffer should stay alive after the function exit. Is there a way to clone/copy a Py_buffer?

For the fmt/format argument: s_init() uses custom code to accept Unicode encodable to ASCII and bytes objects. Using Argument Clinic to check fmt type would require to write a converter. I would prefer to not make too many changes in a single patch, and I don't know how to write such converter. I suggest to do that later and keep the existing code. It seems like all functions getting a format ends in s_init() to check the format argument.
History
Date User Action Args
2017-01-27 08:53:58vstinnersetrecipients: + vstinner, larry, inada.naoki, serhiy.storchaka
2017-01-27 08:53:57vstinnersetmessageid: <1485507237.81.0.764966280061.issue29300@psf.upfronthosting.co.za>
2017-01-27 08:53:57vstinnerlinkissue29300 messages
2017-01-27 08:53:55vstinnercreate