Issue 12112: The new packaging module should not use the locale encoding (original) (raw)

Created on 2011-05-19 11:54 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
packaging_utf8.patch vstinner,2011-05-19 11:54 review
Messages (10)
msg136280 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-05-19 11:54
The locale encoding is not portable, packaging should use UTF-8 instead. Attached patch is a draft to workaround "LANG=C ./python -m test test_packaging" failures. I'm not sure that my test in Metadata.write_file() of packaging.metadata is a good idea. Moreover, packaging should also maybe use the surrogateescape error handler, but I propose to decide that later and in another issue. We may use this error handler only to read files (like the Python makefile). For write a complete patch, *all* calls to open() in Lib/packaging/* (including Lib/packaging/tests/*) should be checked. distutils uses the locale encoding, which is UTF-8 on Mac OS X and most Linux setup (but never on Windows). But distutils cannot be fixed, whereas packaging is a new module and can be fixed.
msg136281 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-05-19 11:56
See also issue #9561 (distutils: set encoding to utf-8 for input and output files) and #6011 (python doesn't build if prefix contains non-ascii characters). If you are curious, read also #8611 (Python3 doesn't support locale different than utf8 and an non-ASCII path (POSIX)) and #9425 (Rewrite import machinery to work with unicode paths).
msg136282 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2011-05-19 12:01
Looks good, please commit this
msg136290 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-05-19 13:19
I ported a distutils fix (for non-ASCII path) into packaging: New changeset cc5cfeaa4a8d by Victor Stinner in branch 'default': Issue #10419, issue #6011: port 6ad356525381 fix from distutils to packaging http://hg.python.org/cpython/rev/cc5cfeaa4a8d
msg136291 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-05-19 13:24
+ if not isinstance(fileobject, StringIO): + encoding = codecs.lookup(fileobject.encoding).name IMO you should try to get the "encoding" attribute and silence the AttributeError instead. (also, I'm not even sure why you're adding this check)
msg136312 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-19 16:50
New changeset fe740c1cee02 by Victor Stinner in branch 'default': Issue #12112: packaging reads and writes setup.cfg using UTF-8 http://hg.python.org/cpython/rev/fe740c1cee02 New changeset 01d61096140a by Victor Stinner in branch 'default': Issue #12112: packaging reads/writes metadata using UTF-8 http://hg.python.org/cpython/rev/01d61096140a
msg136313 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-05-19 16:52
What is the MainProgram.inspect_file() function in packaging.create? Which kind of file should it process? => What is the encoding of the input files?
msg136315 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2011-05-19 17:04
That's not used anymore, I am going to strip it
msg136330 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-19 19:45
New changeset a636cb1b7f84 by Victor Stinner in branch 'default': Issue #12112: fix the encoding of setup.py in the packaging module http://hg.python.org/cpython/rev/a636cb1b7f84
msg141384 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-07-29 14:47
I can run LANG=C python -m test test_packaging successfully. Can we close this?
History
Date User Action Args
2022-04-11 14:57:17 admin set github: 56321
2013-01-03 02:57:56 vstinner set status: open -> closedresolution: fixed
2011-07-29 14:47:49 eric.araujo set messages: +
2011-05-19 19:45:25 python-dev set messages: +
2011-05-19 17:04:54 tarek set messages: +
2011-05-19 16:52:57 vstinner set messages: +
2011-05-19 16:50:26 python-dev set nosy: + python-devmessages: +
2011-05-19 14:22:08 Arfrever set nosy: + Arfrever
2011-05-19 13:24:01 pitrou set nosy: + pitroumessages: +
2011-05-19 13:19:25 vstinner set messages: +
2011-05-19 12:01:48 tarek set messages: +
2011-05-19 11:56:49 vstinner set messages: +
2011-05-19 11:54:46 vstinner set nosy: + tarek, eric.araujocomponents: + Library (Lib)
2011-05-19 11:54:27 vstinner create