Make to_native_str() decode bytes

used for doctests
This commit is contained in:
Matthias Urlichs committed 2019-02-04 13:14:32 +01:00
1 parent 05919363e1
commit 2e47f49f7a
1 file changed
+3 -1
+3 -1
View File
@@ -42,7 +42,9 @@ def to_native_str(s_or_u):
if isinstance(s_or_u, unicode):
return s_or_u.encode("utf-8")
else:
if not isinstance(s_or_u, str):
if isinstance(s_or_u, bytes):
return s_or_u.decode("utf-8") # only used for doctests
elif not isinstance(s_or_u, str):
raise RuntimeError("Please use a string here.")
return s_or_u