-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There're two issues in the existing code. First, this heuristic often fails on short random strings, making their type unreliable. For example, "t" (transaction ID) in DHT protocol is just two bytes. Second, the code assumed that they keys of dictionaries are always UTF-8 encoded. Although that's true in many BitTorrent-related protocols, bencoding doesn't mandate it, and exceptions do in fact exist: see #6. Also, change the code to consistently return bytes/str in all cases, leaving support for passing encoding str/unicode strings, which are transparently encoded to UTF-8.
- Loading branch information
Showing
3 changed files
with
35 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters