[swift-dev] utf-8 issues in gyb and line-directive

Lukas Stabe lukas at stabe.de
Tue Jan 12 12:12:33 CST 2016


I’ve tried to compile Swift in a clean Arch Linux chroot. In this environment, `sys.getdefaultencoding()` does not return `utf-8`, which causes gyb and line-directive to fail with non-ascii characters in input files.

One example of such a file is Arrays.swift.gyb, which contains a ≤-character [here](https://github.com/apple/swift/blob/master/stdlib/public/core/Arrays.swift.gyb#L358).

In gyb, `argparse.FileType` is used to open input files, and line-directive uses plain old `open(…)`. Sadly, both of those don’t provide functionality to specify the file encoding in Python 2.7.10, which is what OSX ships with.

I’m not that experienced in Python, so I don’t know what the pythonic way to solve this would be, so if anyone with more Python experience would help solve this, that would be great.

— Lukas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160112/6dcadc17/attachment.sig>


More information about the swift-dev mailing list