Skip to content

Commit 0b82f15

Browse files
authored
Use the encoding param in to_str and to_bytes
1 parent f45783e commit 0b82f15

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/rfc3986/compat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@
4040
unicode = str # Python 3.x
4141

4242

43-
def to_str(b, encoding):
43+
def to_str(b, encoding='utf-8'):
4444
"""Ensure that b is text in the specified encoding."""
4545
if hasattr(b, 'decode') and not isinstance(b, unicode):
46-
b = b.decode('utf-8')
46+
b = b.decode(encoding)
4747
return b
4848

4949

50-
def to_bytes(s, encoding):
50+
def to_bytes(s, encoding='utf-8'):
5151
"""Ensure that s is converted to bytes from the encoding."""
5252
if hasattr(s, 'encode') and not isinstance(s, bytes):
53-
s = s.encode('utf-8')
53+
s = s.encode(encoding)
5454
return s

0 commit comments

Comments
 (0)