Fix to_bytes(None) on Python 3

You cannot call bytes(obj) to get a simple representation of obj on
Python 3!  E.g. bytes(42) returns a byte string with 42 NUL characters
instead of b'42'.
pull/12119/head
Marius Gedminas 9 years ago
parent df1b41d3d3
commit eb99aa8c68

@ -215,7 +215,7 @@ def to_bytes(obj, encoding='utf-8', errors='replace', nonstring=None):
return obj
elif nonstring == 'simplerepr':
try:
simple = binary_type(obj)
simple = str(obj)
except UnicodeError:
try:
simple = obj.__str__()

Loading…
Cancel
Save