Dear all,

when trying to update graphics/py-PyX I stumbled across a unicode decode error
on reading the setup.py file for PyX version 0.13.
Our current approach is to read setup.py into a string buffer, to replace the
line endings and pass the result to compile() and exec().
This works great as long as

 * the execution environment is configured to deal with matching encodings
   properly (so that locale.getpreferredencoding() returns a file-compatible
   encoding)
 * the setup.py file features a proper encoding so that the execution
   environment can deal with it (see above)

The majority of ports uses setup.py files, which use ASCII only. PyX 0.13
however contains some UTF-8 codepoints (umlauts), which causes the error
above, if the execution environment does not use some UTF-8 locale.

To work around that issue, we just need to read the file contents into a byte
buffer instead of converting the file contents to a string buffer:

-PYDISTUTILS_SETUP?=    -c "import setuptools; __file__='${PYSETUP}'; 
exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))"
+PYDISTUTILS_SETUP?=    -c "import setuptools; __file__='${PYSETUP}'; 
exec(compile(open(__file__, 'rb').read().replace(b'\\r\\n', b'\\n'), __file__, 
'exec'))"

If there are no concerns, I'll commit the change this weekend.

Cheers
Marcus

Attachment: pgpws6jZQfpo0.pgp
Description: PGP signature

Reply via email to