py/objstr: Make empty bytes object have a null-terminating byte.

Because a lot of string processing functions assume there is a null
terminating byte, so they can work in an efficient way.

Fixes issue #3334.
This commit is contained in:
Damien George
2017-10-04 17:59:22 +11:00
parent a3dc1b1957
commit dfa563c71f
2 changed files with 5 additions and 2 deletions

View File

@@ -8,6 +8,9 @@ print(b'\u1234')
print(bytes())
print(bytes(b'abc'))
# make sure empty bytes is converted correctly
print(str(bytes(), 'utf-8'))
a = b"123"
print(a)
print(str(a))