Skip to content

Commit 94bb4b7

Browse files
miss-islingtonaisk
andauthored
bpo-40834: Fix truncate when sending str object with channel (GH-20555)
(cherry picked from commit 29c1172) Co-authored-by: An Long <[email protected]>
1 parent 166d723 commit 94bb4b7

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Lib/test/test__xxsubinterpreters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ def test_bytes(self):
378378
self._assert_values(i.to_bytes(2, 'little', signed=True)
379379
for i in range(-1, 258))
380380

381+
def test_strs(self):
382+
self._assert_values(['hello world', '你好世界', ''])
383+
381384
def test_int(self):
382385
self._assert_values(itertools.chain(range(-1, 258),
383386
[sys.maxsize, -sys.maxsize - 1]))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix truncate when sending str object with_xxsubinterpreters.channel_send.

Python/pystate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ _str_shared(PyObject *obj, _PyCrossInterpreterData *data)
17081708
struct _shared_str_data *shared = PyMem_NEW(struct _shared_str_data, 1);
17091709
shared->kind = PyUnicode_KIND(obj);
17101710
shared->buffer = PyUnicode_DATA(obj);
1711-
shared->len = PyUnicode_GET_LENGTH(obj) - 1;
1711+
shared->len = PyUnicode_GET_LENGTH(obj);
17121712
data->data = (void *)shared;
17131713
Py_INCREF(obj);
17141714
data->obj = obj; // Will be "released" (decref'ed) when data released.

0 commit comments

Comments
 (0)