diff options
| author | Thea Flowers <me@thea.codes> | 2020-05-14 21:16:26 -0700 |
|---|---|---|
| committer | Thea Flowers <me@thea.codes> | 2020-05-14 21:52:58 -0700 |
| commit | fe3e8ee02c08e78691ebad293796985c9589824f (patch) | |
| tree | c6004fedb3e3d1f8e1c5ade244cf06fbda843d13 /py/persistentcode.h | |
| parent | bd78ab3c2812f7772021be7863f89a9650589d80 (diff) | |
Add bytearray.decode() for CPython compatibility
CPython has a `decode()` method on `bytearray`. This adds that method using the code from `bytes.decode`.
Test program:
```python
byte_boi = bytes([0x6D, 0x65, 0x65, 0x70])
print(byte_boi) # b'meep'
byte_boi_str = byte_boi.decode("utf-8")
print(byte_boi_str) # meep
byte_array_boi = bytearray(byte_boi)
print(byte_array_boi) # bytearray(b'meep')
byte_array_boi_str = byte_array_boi.decode("utf-8")
print(byte_array_boi_str) # meep
print(byte_array_boi_str == byte_boi_str) # True
```
Diffstat (limited to 'py/persistentcode.h')
0 files changed, 0 insertions, 0 deletions
