From dfa563c71fead671931e91b786cd649eed517f92 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 4 Oct 2017 17:59:22 +1100 Subject: 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. --- tests/basics/bytes.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/basics/bytes.py') diff --git a/tests/basics/bytes.py b/tests/basics/bytes.py index d3da15c8e..1d97e6b16 100644 --- a/tests/basics/bytes.py +++ b/tests/basics/bytes.py @@ -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)) -- cgit v1.2.3