Repository navigation
Commit a5e7761
committed
Skip the codec lookup when decoding empty bytes
BytesCommonBuiltins.DecodeNode, which backs bytes.decode,
bytearray.decode and str(obj, encoding), always went through the
codec, so b''.decode('bogus') and str(b'', 'bogus') raised
LookupError.
CPython's bytes and bytearray decode call PyUnicode_FromEncodedObject,
which returns '' for empty input without looking up the codec outside
dev mode. GraalPy's own PyUnicodeFromEncodedObject already does this
for the C API; DecodeNode now has the same shortcut.
Signed-off-by: Jeongseop Lim <jeongseop_lim@korea.ac.kr>1 parent 7e7182b commit a5e7761
2 files changed
Lines changed: 16 additions & 0 deletions
File tree
- graalpython
- com.oracle.graal.python.test/src/tests
- com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
92 | 102 | | |
93 | 103 | | |
94 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
| 207 | + | |
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
209 | 215 | | |
210 | 216 | | |
211 | 217 | | |
| |||
0 commit comments