FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-99741: Clean Up the _xxsubinterpreters Module by ericsnowcurrently · Pull Request #99940 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (2) .h  (1) .py  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion Include/cpython/pystate.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ struct _xid {

PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *);
PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *);
PyAPI_FUNC(void) _PyCrossInterpreterData_Release(_PyCrossInterpreterData *);
PyAPI_FUNC(int) _PyCrossInterpreterData_Release(_PyCrossInterpreterData *);

PyAPI_FUNC(int) _PyObject_CheckCrossInterpreterData(PyObject *);

Expand Down
26 changes: 25 additions & 1 deletion Lib/test/test__xxsubinterpreters.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ def test_types(self):
self._assert_values([
b'spam',
9999,
self.cid,
])

def test_bytes(self):
Expand Down Expand Up @@ -1213,6 +1212,18 @@ def test_equality(self):
self.assertFalse(cid1 != cid2)
self.assertTrue(cid1 != cid3)

def test_shareable(self):
chan = interpreters.channel_create()

obj = interpreters.channel_create()
interpreters.channel_send(chan, obj)
got = interpreters.channel_recv(chan)

self.assertEqual(got, obj)
self.assertIs(type(got), type(obj))
# XXX Check the following in the channel tests?
#self.assertIsNot(got, obj)


class ChannelTests(TestBase):

Expand Down Expand Up @@ -1545,6 +1556,19 @@ def test_recv_default(self):
self.assertEqual(obj5, b'eggs')
self.assertIs(obj6, default)

def test_recv_sending_interp_destroyed(self):
cid = interpreters.channel_create()
interp = interpreters.create()
interpreters.run_string(interp, dedent(f"""
import _xxsubinterpreters as _interpreters
_interpreters.channel_send({cid}, b'spam')
"""))
interpreters.destroy(interp)

with self.assertRaisesRegex(RuntimeError,
'unrecognized interpreter ID'):
interpreters.channel_recv(cid)

def test_run_string_arg_unresolved(self):
cid = interpreters.channel_create()
interp = interpreters.create()
Expand Down
Loading

Back | FazBrowse Home | New Git URL