Skip to content

Commit 955fed1

Browse files
committed
Address CR
1 parent a9aa5e2 commit 955fed1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

mypyc/lib-rt/librt_internal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ read_bytes_internal(PyObject *data) {
367367
_CHECK_READ(data, sizeof(CPyTagged), NULL)
368368
size = _READ(data, Py_ssize_t)
369369
}
370-
// Read byes content.
370+
// Read bytes content.
371371
char *buf = ((BufferObject *)data)->buf;
372372
_CHECK_READ(data, size, NULL)
373373
PyObject *res = PyBytes_FromStringAndSize(
@@ -394,10 +394,10 @@ static char
394394
write_bytes_internal(PyObject *data, PyObject *value) {
395395
_CHECK_BUFFER(data, CPY_NONE_ERROR)
396396

397-
Py_ssize_t size = PyBytes_GET_SIZE(value);
398397
const char *chunk = PyBytes_AsString(value);
399398
if (unlikely(chunk == NULL))
400399
return CPY_NONE_ERROR;
400+
Py_ssize_t size = PyBytes_GET_SIZE(value);
401401

402402
Py_ssize_t need;
403403
// Write length.

mypyc/test-data/run-classes.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,6 +2735,9 @@ def test_buffer_roundtrip() -> None:
27352735
write_bool(b, False)
27362736
write_bytes(b, b"bar")
27372737
write_bytes(b, b"bar" * 100)
2738+
write_bytes(b, b"")
2739+
write_bytes(b, b"a" * 127)
2740+
write_bytes(b, b"a" * 128)
27382741
write_float(b, 0.1)
27392742
write_int(b, 0)
27402743
write_int(b, 1)
@@ -2756,6 +2759,9 @@ def test_buffer_roundtrip() -> None:
27562759
assert read_bool(b) is False
27572760
assert read_bytes(b) == b"bar"
27582761
assert read_bytes(b) == b"bar" * 100
2762+
assert read_bytes(b) == b""
2763+
assert read_bytes(b) == b"a" * 127
2764+
assert read_bytes(b) == b"a" * 128
27592765
assert read_float(b) == 0.1
27602766
assert read_int(b) == 0
27612767
assert read_int(b) == 1
@@ -2812,6 +2818,9 @@ def test_buffer_roundtrip_interpreted() -> None:
28122818
write_bool(b, False)
28132819
write_bytes(b, b"bar")
28142820
write_bytes(b, b"bar" * 100)
2821+
write_bytes(b, b"")
2822+
write_bytes(b, b"a" * 127)
2823+
write_bytes(b, b"a" * 128)
28152824
write_float(b, 0.1)
28162825
write_int(b, 0)
28172826
write_int(b, 1)
@@ -2833,6 +2842,9 @@ def test_buffer_roundtrip_interpreted() -> None:
28332842
assert read_bool(b) is False
28342843
assert read_bytes(b) == b"bar"
28352844
assert read_bytes(b) == b"bar" * 100
2845+
assert read_bytes(b) == b""
2846+
assert read_bytes(b) == b"a" * 127
2847+
assert read_bytes(b) == b"a" * 128
28362848
assert read_float(b) == 0.1
28372849
assert read_int(b) == 0
28382850
assert read_int(b) == 1

0 commit comments

Comments
 (0)