2c8dab7ab4
This prevents a very subtle bug caused by writing e.g. `bytearray('\xfd')` which gives you `(0xc3, 0xbd)`. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
13 lines
287 B
Python
13 lines
287 B
Python
# test construction of bytearray from different objects
|
|
|
|
print(bytearray(b'123'))
|
|
print(bytearray('1234', 'utf-8'))
|
|
print(bytearray('12345', 'utf-8', 'strict'))
|
|
print(bytearray((1, 2)))
|
|
print(bytearray([1, 2]))
|
|
|
|
try:
|
|
print(bytearray('1234'))
|
|
except TypeError:
|
|
print("TypeError")
|