mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
py/objarray: Detect bytearray(str) without an encoding.
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>
This commit is contained in:
committed by
Damien George
parent
f8b0ae32d3
commit
2c8dab7ab4
@@ -5,3 +5,8 @@ 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")
|
||||
|
||||
Reference in New Issue
Block a user