Commit fe3e8ee
committed
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
```1 parent bd78ab3 commit fe3e8ee
1 file changed
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| |||
546 | 550 | | |
547 | 551 | | |
548 | 552 | | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
549 | 570 | | |
550 | 571 | | |
551 | 572 | | |
552 | 573 | | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
553 | 577 | | |
554 | 578 | | |
555 | 579 | | |
| |||
0 commit comments