conan: Cannot get MD5 for non-ASCII filenames
(Conan 0.30.3, Python 2.7.12, Ubuntu 16.04)
In conans/util/files.py, I get
UnicodeEncodeError: 'ascii' codec can't encode characters in position 10122-10125: ordinal not in range(128)
on the line content.encode()
. This is because the unicode-type string content
contains non-ASCII characters that are not handled by the default encoder.
Is there any reason not to do content.encode("utf-8")
?
To reproduce, add a file with non-ASCII characters in the filename to the files exported by a library.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 28 (16 by maintainers)
Commits related to this issue
- #2260 Ignore surrongates from file contents - When a file content is encoded, surrongates characters are not supported on Python. Following the same approach from decode_text we will ignore them.... — committed to uilianries/conan by uilianries 5 years ago
- #2260 Python2 does not woke like py3 Signed-off-by: Uilian Ries <uilianries@gmail.com> — committed to uilianries/conan by uilianries 5 years ago
Strangely enough, I came across a very similar error today. I can build my package locally on Ubuntu16+conan 1.21 and also Ubuntu 18 + conan 1.29.0. On our CI servers, we rock the same configs but on dockers. On the docker images, I get
And I cant reproduce it locally or figure out what is going on. We are using python 3.5 on U16 and 3.6 on U18.
Any suggestions to debug this?
UPDATE: It was related to a
locale
config. The following did the trick for me.Source: https://www.embeddeduse.com/2019/02/11/using-docker-containers-for-yocto-builds/
I believe we should take a look at PEP 0383
since we’re trying to store/load file names as bytes, we have to use
surrogateescape
encoding, as PEP suggestsI have not been able to reproduce this in Py3 with conan 1.0. Here’s my test setup:
conan create .
@masseman have you encountered the same troubles on Py3, or is this only a Py2 problem?