Title: struni: Fix test_aepack by converting 4cc's to bytes
Type: Stage:
Components: macOS Versions: Python 3.0
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, jyasskin
Priority: normal Keywords: patch

Created on 2007-07-26 18:37 by jyasskin, last changed 2008-01-06 22:29 by admin. This issue is now closed.

File name Uploaded Description Edit
aetypes_applesingle.diff jyasskin, 2007-07-26 18:37 Fix to test_aepack and test_applesingle
aepack_b2i_to_str.diff jyasskin, 2007-07-27 06:19
Messages (5)
msg52946 - (view) Author: Jeffrey Yasskin (jyasskin) * (Python committer) Date: 2007-07-26 18:37
Also includes a simple fix for test_applesingle.

The core of this fix is to change Python/mactoolboxglue.c:PyMac_BuildOSType(OSType) to return a bytes object instead of a str8, and then to go through the python code and change the four-character-codes to bytes. This hits a snag when they're used as dictionary keys, since bytes isn't hashable, so a hacky little b2i() function converts them to ints first. b2i() should go away when someone writes the general bytes/int conversion api.

This is discussed some at If Talin's and Ronald's preference from that thread is taken, then PyMac_BuildOSType should return their new type instead.
msg52947 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-07-27 04:42
Committed revision 56560.

(Except I changed the open mode from the unconventional 'bw' to 'wb'. :-)
msg52948 - (view) Author: Jeffrey Yasskin (jyasskin) * (Python committer) Date: 2007-07-27 06:19
But I like black'n'white files. ;)

I've attached a patch changing b2i to str for using 4CCs in dicts. Since this file, at least, never needs to convert back, nothing's ambiguous about it, and I do like the idea of being able to read these while debugging. The test still passes.
File Added: aepack_b2i_to_str.diff
msg52949 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-07-27 12:55
Hmm...  What if there's a 4CC containing a non-ASCII byte?
msg52950 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-08-03 19:04
On the list we agreed not to apply the second patch.
Date User Action Args
2008-01-06 22:29:45adminsetkeywords: - py3k
versions: + Python 3.0
2007-07-26 18:37:06jyasskincreate