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'.
This commit is contained in:
parent
df1b41d3d3
commit
eb99aa8c68
1 changed files with 1 additions and 1 deletions
|
@ -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…
Reference in a new issue