Yes, before 3.1, struct.pack() will erroneously encode strings into UTF-8 bytes; this has been fixed in Python 3.2. See question 10783 .
The conclusion was that implicit conversion was a bad idea, and it was canceled, while developers still had the opportunity to do this:
I prefer to break the API today than support a broken API for 10 or 20 years :-) And we have a very small user base using Python 3, it is now easier to change it than in the next version.
This is also described in the port section of manual 3.2 What's New :
struct.pack() now only allows bytes for s string code. He used to take text arguments and implicitly encode them into bytes using UTF-8. This was problematic because it made assumptions about the correct encoding and because variable length encoding may not work when writing to a segment of a fixed length structure.
You need to explicitly encode your lines before packing.
Martijn pieters
source share