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
Feature/fix os walk py2 #3505
Feature/fix os walk py2 #3505
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conans/test/util/files_test.py
Outdated
if six.PY2: | ||
folder = unicode(folder) | ||
save(to_file_bytes(filepath), "contents") | ||
file = [f[0] for _, _, f in walk(folder)][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file
is a reserved word
conans/test/util/files_test.py
Outdated
folder = temp_folder() | ||
filepath = os.path.join(folder, badfilename) | ||
if six.PY2: | ||
folder = unicode(folder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use six.u(folder)
in line 46 and avoid this if clause?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting this six.u
, I didn't now about it.
…o feature/fix_os_walk_py2
I'm trying to make a snippet that fails to check that this PR is solving an issue and everything I tried runs ok (MacOS, py 2.7.15). Following the test you provided I'm making some changes to check that the issue actually exists and I thought that these lines below should fail: badfilename = "\xE3\x81\x82badfile.txt"
folder = temp_folder()
filepath = os.path.join(folder, badfilename)
save(to_file_bytes(filepath), "contents")
a_file = [f[0] for _, _, f in os.walk(unicode(folder))][0] Maybe, does it depend on the locale? |
…ed) and broken walk on purpose to see what happend in CI
I've pushed the test with |
@jgsogo Look at the py2 builds using directly Pushing again with the correct code. |
I've replayed builds (MacOS failed because of a CI issue): https://conan-ci.jfrog.info/blue/organizations/jenkins/ConanTestSuite/detail/PR-3505/10/pipeline I want to see what happens with py2. Anyway, it may depend on locale, but these changes are necessary. |
Feature/fix os walk py2
Based on the fact: When py2 uses
os.walk
and it is passed a directory to iterate as "unicode", if iterating it finds some filename it can't decode, it fails. But if you pass a simple str() it works.Changelog: BugFix: Fixed failures when Conan walk directories with files containing not ASCCI characters in the file name.