Skip to content

Commit ace4440

Browse files
committed
Force UTF-8 when parsing binary string addresses to Unicode in Python 2 (cf #36)
1 parent b95b905 commit ace4440

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

multiaddr/multiaddr.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def __init__(self, addr):
4242
# obvious case of a “binary-encoded” multiaddr starting with a slash
4343
# and decode it into text
4444
if six.PY2 and isinstance(addr, str) and addr.startswith("/"):
45-
import locale
46-
addr = addr.decode(locale.getpreferredencoding())
45+
addr = addr.decode("utf-8")
4746

4847
if isinstance(addr, six.text_type):
4948
self._bytes = string_to_bytes(addr)

0 commit comments

Comments
 (0)