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

Skip to content

Commit 26db10a

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 <aisk@users.noreply.github.com>
1 parent 7e57c36 commit 26db10a

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
@@ -392,6 +392,9 @@ def test_bytes(self):
392392
self._assert_values(i.to_bytes(2, 'little', signed=True)
393393
for i in range(-1, 258))
394394

395+
def test_strs(self):
396+
self._assert_values(['hello world', '你好世界', ''])
397+
395398
def test_int(self):
396399
self._assert_values(itertools.chain(range(-1, 258),
397400
[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
@@ -1639,7 +1639,7 @@ _str_shared(PyObject *obj, _PyCrossInterpreterData *data)
16391639
struct _shared_str_data *shared = PyMem_NEW(struct _shared_str_data, 1);
16401640
shared->kind = PyUnicode_KIND(obj);
16411641
shared->buffer = PyUnicode_DATA(obj);
1642-
shared->len = PyUnicode_GET_LENGTH(obj) - 1;
1642+
shared->len = PyUnicode_GET_LENGTH(obj);
16431643
data->data = (void *)shared;
16441644
Py_INCREF(obj);
16451645
data->obj = obj; // Will be "released" (decref'ed) when data released.

0 commit comments

Comments
 (0)
0