10000 bpo-40834: Fix truncate when sending str object with channel (GH-20555) · python/cpython@29c1172 · GitHub
[go: up one dir, main page]

Skip to content

Commit 29c1172

Browse files
authored
bpo-40834: Fix truncate when sending str object with channel (GH-20555)
1 parent 1c209e3 commit 29c1172

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
@@ -1726,7 +1726,7 @@ _str_shared(PyObject *obj, _PyCrossInterpreterData *data)
17261726
struct _shared_str_data *shared = PyMem_NEW(struct _shared_str_data, 1);
17271727
shared->kind = PyUnicode_KIND(obj);
17281728
shared->buffer = PyUnicode_DATA(obj);
1729-
shared->len = PyUnicode_GET_LENGTH(obj) - 1;
1729+
shared->len = PyUnicode_GET_LENGTH(obj);
17301730
data->data = (void *)shared;
17311731
Py_INCREF(obj);
17321732
data->obj = obj; // Will be "released" (decref'ed) when data released.

0 commit comments

Comments
 (0)
0