[issue16349] Document whether it's safe to use bytes for struct format string

2017-04-28 Thread Martin Panter
Changes by Martin Panter : -- dependencies: +struct.Struct.format is bytes, but should be str -Document whether it's safe to use bytes for struct format string ___ Python tracker

[issue16349] Document whether it's safe to use bytes for struct format string

2017-04-28 Thread Martin Panter
Martin Panter added the comment: I think the direction to take for this depends on the outcome of Issue 21071. First we have to decide if the “format” attribute is blessed as a byte string (and not deprecated), or whether it is deprecated or changed to a text string. Serhiy pointed out that

[issue16349] Document whether it's safe to use bytes for struct format string

2014-12-18 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16349 ___

[issue16349] Document whether it's safe to use bytes for struct format string

2014-12-17 Thread Martin Panter
Martin Panter added the comment: Assuming it is intended to support byte strings, here is a patch that documents them being allowed, and adds a test case -- keywords: +patch Added file: http://bugs.python.org/file37489/format-bytes.patch ___ Python

[issue16349] Document whether it's safe to use bytes for struct format string

2014-12-16 Thread Martin Panter
Martin Panter added the comment: Actually the “struct” module doc string seems to already hint that format strings can be byte strings: “Python bytes objects are used to hold the data representing the C struct and also as format strings . . .” --

[issue16349] Document whether it's safe to use bytes for struct format string

2014-04-16 Thread Martin Panter
Martin Panter added the comment: The issue of Struct.format being a byte string has been raised separately in Issue 21071. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16349 ___

[issue16349] Document whether it's safe to use bytes for struct format string

2012-11-30 Thread Thomas Kluyver
Thomas Kluyver added the comment: I'm happy to put together a docs patch, but I don't have any indication of the right answer (is it a safe feature to use, or an implementation detail?) Is there another venue where I should raise the question? --

[issue16349] Document whether it's safe to use bytes for struct format string

2012-11-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Python 2 supports only str. Support for unicode objects has been added in r59687 (merged with other unrelated changes in changeset 13aabc23cf2e). Maybe Raymond can explain why the type for the Struct.format was chosen bytes, not unicode. --

[issue16349] Document whether it's safe to use bytes for struct format string

2012-11-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: No, this is not r59687. I can't found from which revision in 59680-59695 it came. -- nosy: +christian.heimes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16349

[issue16349] Document whether it's safe to use bytes for struct format string

2012-11-03 Thread Mark Dickinson
Mark Dickinson added the comment: but also discovered that example outputs are wrong That's documented to some extent: there's a line in the docs that says: All examples assume a native byte order, size, and alignment with a big-endian machine. Given that little-endian machines are much

[issue16349] Document whether it's safe to use bytes for struct format string

2012-11-03 Thread Mark Dickinson
Mark Dickinson added the comment: Also it would be nice to clarify if struct.Struct.format is meant to be a byte string. Hmm. That seems wrong to me. After all, the format string is supposed to be a piece of human-readable text rather than a collection of bytes. I think it's borderline

[issue16349] Document whether it's safe to use bytes for struct format string

2012-11-03 Thread Terry J. Reedy
Terry J. Reedy added the comment: I think the example should be switched *and* the formats should specify the endianess so the examples work on all systems. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16349

[issue16349] Document whether it's safe to use bytes for struct format string

2012-11-02 Thread Terry J. Reedy
Terry J. Reedy added the comment: For 3.3, I verified that adding b prefix to first three doc examples gives same output as without, but also discovered that example outputs are wrong, at least on windows, because of byte ordering issues. pack('hhl', 1, 2, 3)

[issue16349] Document whether it's safe to use bytes for struct format string

2012-10-28 Thread Thomas Kluyver
New submission from Thomas Kluyver: At least in CPython, format strings can be given as bytes, as an alternative to str. E.g. struct.unpack(b'hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03') (1, 2, 3) Looking at the source code [1], this appears to be consciously accounted for. But it doesn't

[issue16349] Document whether it's safe to use bytes for struct format string

2012-10-28 Thread Martin Panter
Martin Panter added the comment: Also it would be nice to clarify if struct.Struct.format is meant to be a byte string. Reading the documentation and examples I expected a character string. It was an issue for me when embedding one structure within another: HSF_VOL_DESC = Struct( B 5s B) #