-
-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pants fails to create chroot from packages containing UTF-8 encoded files when default encoding is non-UTF-8. #3823
Comments
OK, using the following script: #!/usr/bin/env python2
from __future__ import print_function
import codecs
import errno
import os
import tempfile
import zipfile
target = tempfile.mkdtemp()
print('Extracting zfile entry by entry to {}'.format(target))
codec = codecs.lookup('utf-8')
with zipfile.ZipFile('CherryPy-7.1.0.zip') as zfile:
for info in zfile.infolist():
path, _ = codec.encode(info.filename)
if not path.endswith(b'/'):
rel_dir = os.path.dirname(path)
abs_dir = os.path.join(target, rel_dir)
abs_path = os.path.join(abs_dir, os.path.basename(path))
try:
os.makedirs(abs_dir)
except os.error as e:
if e.errno != errno.EEXIST:
raise e
with open(abs_path, 'wb') as tfp:
tfp.write(zfile.read(info))
target = tempfile.mkdtemp()
print('Extracting zfile using extractall to {}'.format(target))
with zipfile.ZipFile('CherryPy-7.1.0.zip') as zfile:
zfile.extractall(target) I find on my default UTF-8 encoding machine:
So the entry-by-entry extraction might be the way to go over in pex. Thinking on this a bit before filing an issue over there, but maybe @kwlzn can spot the problem with doing this more quickly than I. |
seems reasonable to me. tho it's also worth noting that I don't seem to repro the failure on OSX (10.11):
I wonder what's different between our envs? |
See my LANG=... CMD line prefix On Sep 1, 2016 3:26 PM, "Kris Wilson" [email protected] wrote:
|
yup - present in my paste. |
Aha - not sure, but the environment that spawned this ticket from Aurora CI is Linux. |
Aha: https://docs.python.org/2/library/sys.html#sys.getfilesystemencoding |
Noting that CherryPy has "fixed" the motivating case in 8.0.0: cherrypy/cherrypy@b8e2518 This solves the motivating error, see Aurora RB: https://reviews.apache.org/r/51615/ |
To work around this in a session:
But note that you may first need to:
|
Likely fixed by the Python 3 migration. |
This was certainly never fixed by Pants own internal code migration since, in May 2020, Pants was already calling Pex in a sub-process and that sub-process could be running a Python 2.7 interpreter. In fact, to this day, FWICT, Pants supports Python 2.7 since Pex does; so this continues to be a bug for the ~0 Pants users using Python 2.7. All that said, the issue could now be closed for real here once Pants upgrades to Pex 2.20.2 which has fixed this issue: https://github.com/pex-tool/pex/releases/tag/v2.20.2 |
Saw this in an Aurora RB: https://reviews.apache.org/r/51499/
Repro'd via the following with a few prints added to the pex code:
And, in fact:
The text was updated successfully, but these errors were encountered: