This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients alynn, louielu, mark.dickinson, meador.inge, serhiy.storchaka
Date 2017-02-25.15:10:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488035439.42.0.0723622393576.issue23578@psf.upfronthosting.co.za>
In-reply-to
Content
1. Using global variable doesn't look good to me.

2. "at offset 1" looks confusing to me. What is offset? Is this an offset of packed item in created bytes object? The you shouldn't get the odd number for the '!h' format.

I think it would be better to report the number of the packed item. struct.pack() already formats similar errors when pass unsuitable number of items.

>>> struct.pack('<hb', 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
struct.error: pack expected 2 items for packing (got 1)
>>> struct.pack('<hb', 1, 2, 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
struct.error: pack expected 2 items for packing (got 3)

3. It is not safe to use the fixed length array for formatting error message. Once the underlying error message can be changed and will overflow the buffer. The "%zd" format in sprintf() is not portable.
History
Date User Action Args
2017-02-25 15:10:39serhiy.storchakasetrecipients: + serhiy.storchaka, mark.dickinson, meador.inge, alynn, louielu
2017-02-25 15:10:39serhiy.storchakasetmessageid: <1488035439.42.0.0723622393576.issue23578@psf.upfronthosting.co.za>
2017-02-25 15:10:39serhiy.storchakalinkissue23578 messages
2017-02-25 15:10:39serhiy.storchakacreate