Skip to content

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.

1 participant