Skip to content

Commit

Permalink
bpo-40834: Fix truncate when sending str object with channel (pythonG…
Browse files Browse the repository at this point in the history
…H-20555)

(cherry picked from commit 29c1172)

Co-authored-by: An Long <aisk@users.noreply.github.com>
  • Loading branch information
miss-islington and aisk committed Jun 13, 2020
1 parent 166d723 commit 94bb4b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Lib/test/test__xxsubinterpreters.py
Expand Up @@ -378,6 +378,9 @@ def test_bytes(self):
self._assert_values(i.to_bytes(2, 'little', signed=True)
for i in range(-1, 258))

def test_strs(self):
self._assert_values(['hello world', '你好世界', ''])

def test_int(self):
self._assert_values(itertools.chain(range(-1, 258),
[sys.maxsize, -sys.maxsize - 1]))
Expand Down
@@ -0,0 +1 @@
Fix truncate when sending str object with_xxsubinterpreters.channel_send.
2 changes: 1 addition & 1 deletion Python/pystate.c
Expand Up @@ -1708,7 +1708,7 @@ _str_shared(PyObject *obj, _PyCrossInterpreterData *data)
struct _shared_str_data *shared = PyMem_NEW(struct _shared_str_data, 1);
shared->kind = PyUnicode_KIND(obj);
shared->buffer = PyUnicode_DATA(obj);
shared->len = PyUnicode_GET_LENGTH(obj) - 1;
shared->len = PyUnicode_GET_LENGTH(obj);
data->data = (void *)shared;
Py_INCREF(obj);
data->obj = obj; // Will be "released" (decref'ed) when data released.
Expand Down

0 comments on commit 94bb4b7

Please sign in to comment.