Skip to content
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

Fix ascii_filename to work properly in Python 3 #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kwikwag
Copy link

@kwikwag kwikwag commented Aug 19, 2021

This fixes issue #49. In Python 3 the result of str.encode() is bytes and so "something %s" % (b'else') == "something b'else'", which 2to3does not catch because of thestr-bytes` ambiguity in Python 2 (see also here). I suggest simply reconverting the ASCII-bytes into a Unicode string (containing only ASCII characters) for Python 3. Actually, the version check is redundant, as in Python 2 I think

s = s.encode('ascii', 'ignore')
assert s.decode('ascii') == s

Is always true.

I haven't tested this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant