diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2022-12-02 18:36:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-02 18:36:57 (GMT) |
commit | 0547a981ae413248b21a6bb0cb62dda7d236fe45 (patch) | |
tree | 284f9abff17da763537e6087b30452a6f4aeadc9 /Lib | |
parent | ab02262cd0385a2fb5eb8a6ee3cedd4b4bb969f3 (diff) | |
download | cpython-0547a981ae413248b21a6bb0cb62dda7d236fe45.zip cpython-0547a981ae413248b21a6bb0cb62dda7d236fe45.tar.gz cpython-0547a981ae413248b21a6bb0cb62dda7d236fe45.tar.bz2 |
gh-99741: Clean Up the _xxsubinterpreters Module (gh-99940)
This cleanup up resolves a few subtle bugs and makes the implementation for multi-phase init much cleaner.
https://github.com/python/cpython/issues/99741
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test__xxsubinterpreters.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Lib/test/test__xxsubinterpreters.py b/Lib/test/test__xxsubinterpreters.py index 66f29b9..f274b63 100644 --- a/Lib/test/test__xxsubinterpreters.py +++ b/Lib/test/test__xxsubinterpreters.py @@ -386,7 +386,6 @@ class ShareableTypeTests(unittest.TestCase): self._assert_values([ b'spam', 9999, - self.cid, ]) def test_bytes(self): @@ -1213,6 +1212,18 @@ class ChannelIDTests(TestBase): 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): @@ -1545,6 +1556,19 @@ class ChannelTests(TestBase): 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() |