Open westurner opened 7 years ago
Fails on Python 3, NameError: name 'unicode' is not defined
:(
Whoops. I think that should only be for Python 2 because in Python 3 all str are unicode.
On Wednesday, November 16, 2016, Alexander Pushkov notifications@github.com wrote:
Fails on Python 3, NameError: name 'unicode' is not defined :(
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kosqx/better-bencode/pull/4#issuecomment-260935205, or mute the thread https://github.com/notifications/unsubscribe-auth/AADGy77ug9XCD5PdA461pQNqM3AtSJzmks5q-vfTgaJpZM4Kwxlh .
The error actually happens in the elif t is unicode
line. We can safely substitute unicode for str (in py3k) here (as unicode_to_bytes
accepts str in python 3), so I suggest this simple fix: https://github.com/Songbee/better-bencode/commit/0bb114b9875fac1a6829e0a7bd8ffb933c66c525
Good call @iamale
TEST_DATA
to test for unicode strings?... TIL "All character string values are UTF-8 encoded." https://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure
Also I think it would be nice to decode unicode strings to unicode
/str
as well (although it might be a bit trickier).
3