summaryrefslogtreecommitdiff
path: root/passlib/utils
diff options
context:
space:
mode:
Diffstat (limited to 'passlib/utils')
-rw-r--r--passlib/utils/__init__.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py
index b9ee776..e0b9e75 100644
--- a/passlib/utils/__init__.py
+++ b/passlib/utils/__init__.py
@@ -548,6 +548,7 @@ def to_bytes(source, encoding="utf-8", errname="value", source_encoding=None):
* if *source_encoding* is specified, byte strings will be transcoded
to *encoding*.
"""
+ assert encoding
if isinstance(source, bytes):
if source_encoding and not is_same_codec(source_encoding, encoding):
return source.decode(source_encoding).encode(encoding)
@@ -579,6 +580,7 @@ def to_unicode(source, source_encoding="utf-8", errname="value"):
if isinstance(source, unicode):
return source
elif isinstance(source, bytes):
+ assert source_encoding
return source.decode(source_encoding)
else:
raise ExpectedStringError(source, errname)