Skip to content

Commit 5cbe361

Browse files
Move the interpreters module to the official stdlib.
1 parent c25d9e1 commit 5cbe361

21 files changed

+48
-56
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Doc/howto/clinic.rst @erlend-aasland
281281
# Subinterpreters
282282
**/*interpreteridobject.* @ericsnowcurrently
283283
**/*crossinterp* @ericsnowcurrently
284-
Lib/test/support/interpreters/ @ericsnowcurrently
284+
Lib/interpreters/ @ericsnowcurrently
285285
Modules/_interp*module.c @ericsnowcurrently
286286
Lib/test/test_interpreters/ @ericsnowcurrently
287287

File renamed without changes.

Lib/test/test__interpchannels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from test.support import import_helper, skip_if_sanitizer
1010

1111
_channels = import_helper.import_module('_interpchannels')
12-
from test.support.interpreters import _crossinterp
12+
from interpreters import _crossinterp
1313
from test.test__interpreters import (
1414
_interpreters,
1515
_run_output,

Lib/test/test_concurrent_futures/test_interpreter_pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
from concurrent.futures.interpreter import (
99
ExecutionFailed, BrokenInterpreterPool,
1010
)
11+
from interpreters import queues
1112
import _interpreters
1213
from test import support
1314
import test.test_asyncio.utils as testasyncio_utils
14-
from test.support.interpreters import queues
1515

1616
from .executor import ExecutorTest, mul
1717
from .util import BaseTestCase, InterpreterPoolMixin, setup_module

Lib/test/test_interpreters/test_api.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
from test.support import import_helper
1414
# Raise SkipTest if subinterpreters not supported.
1515
_interpreters = import_helper.import_module('_interpreters')
16+
import interpreters
1617
from test.support import Py_GIL_DISABLED
17-
from test.support import interpreters
1818
from test.support import force_not_colorized
1919
import test._crossinterp_definitions as defs
20-
from test.support.interpreters import (
20+
from interpreters import (
2121
InterpreterError, InterpreterNotFoundError, ExecutionFailed,
2222
)
2323
from .utils import (
@@ -103,7 +103,7 @@ def test_in_subinterpreter(self):
103103
main, = interpreters.list_all()
104104
interp = interpreters.create()
105105
out = _run_output(interp, dedent("""
106-
from test.support import interpreters
106+
import interpreters
107107
interp = interpreters.create()
108108
print(interp.id)
109109
"""))
@@ -166,7 +166,7 @@ def test_subinterpreter(self):
166166
main = interpreters.get_main()
167167
interp = interpreters.create()
168168
out = _run_output(interp, dedent("""
169-
from test.support import interpreters
169+
import interpreters
170170
cur = interpreters.get_current()
171171
print(cur.id)
172172
"""))
@@ -183,7 +183,7 @@ def test_idempotent(self):
183183
with self.subTest('subinterpreter'):
184184
interp = interpreters.create()
185185
out = _run_output(interp, dedent("""
186-
from test.support import interpreters
186+
import interpreters
187187
cur = interpreters.get_current()
188188
print(id(cur))
189189
cur = interpreters.get_current()
@@ -195,7 +195,7 @@ def test_idempotent(self):
195195
with self.subTest('per-interpreter'):
196196
interp = interpreters.create()
197197
out = _run_output(interp, dedent("""
198-
from test.support import interpreters
198+
import interpreters
199199
cur = interpreters.get_current()
200200
print(id(cur))
201201
"""))
@@ -552,7 +552,7 @@ def test_from_current(self):
552552
main, = interpreters.list_all()
553553
interp = interpreters.create()
554554
out = _run_output(interp, dedent(f"""
555-
from test.support import interpreters
555+
import interpreters
556556
interp = interpreters.Interpreter({interp.id})
557557
try:
558558
interp.close()
@@ -569,7 +569,7 @@ def test_from_sibling(self):
569569
self.assertEqual(set(interpreters.list_all()),
570570
{main, interp1, interp2})
571571
interp1.exec(dedent(f"""
572-
from test.support import interpreters
572+
import interpreters
573573
interp2 = interpreters.Interpreter({interp2.id})
574574
interp2.close()
575575
interp3 = interpreters.create()
@@ -776,7 +776,7 @@ def eggs():
776776
ham()
777777
""")
778778
scriptfile = self.make_script('script.py', tempdir, text="""
779-
from test.support import interpreters
779+
import interpreters
780780
781781
def script():
782782
import spam
@@ -797,7 +797,7 @@ def script():
797797
~~~~~~~~~~~^^^^^^^^
798798
{interpmod_line.strip()}
799799
raise ExecutionFailed(excinfo)
800-
test.support.interpreters.ExecutionFailed: RuntimeError: uh-oh!
800+
interpreters.ExecutionFailed: RuntimeError: uh-oh!
801801
802802
Uncaught in the interpreter:
803803
@@ -1251,7 +1251,7 @@ def run(text):
12511251
# no module indirection
12521252
with self.subTest('no indirection'):
12531253
text = run(f"""
1254-
from test.support import interpreters
1254+
import interpreters
12551255
12561256
def spam():
12571257
# This a global var...
@@ -1271,7 +1271,7 @@ def run(interp, func):
12711271
""")
12721272
with self.subTest('indirect as func, direct interp'):
12731273
text = run(f"""
1274-
from test.support import interpreters
1274+
import interpreters
12751275
import mymod
12761276
12771277
def spam():
@@ -1287,7 +1287,7 @@ def spam():
12871287

12881288
# indirect as func, indirect interp
12891289
new_mod('mymod', f"""
1290-
from test.support import interpreters
1290+
import interpreters
12911291
def run(func):
12921292
interp = interpreters.create()
12931293
return interp.call(func)

Lib/test/test_interpreters/test_channels.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from test.support import import_helper
99
# Raise SkipTest if subinterpreters not supported.
1010
_channels = import_helper.import_module('_interpchannels')
11-
from test.support import interpreters
12-
from test.support.interpreters import channels
11+
import interpreters
12+
from interpreters import channels
1313
from .utils import _run_output, TestBase
1414

1515

@@ -171,7 +171,7 @@ def test_send_recv_main(self):
171171
def test_send_recv_same_interpreter(self):
172172
interp = interpreters.create()
173173
interp.exec(dedent("""
174-
from test.support.interpreters import channels
174+
from interpreters import channels
175175
r, s = channels.create()
176176
orig = b'spam'
177177
s.send_nowait(orig)
@@ -244,7 +244,7 @@ def test_send_recv_nowait_main_with_default(self):
244244
def test_send_recv_nowait_same_interpreter(self):
245245
interp = interpreters.create()
246246
interp.exec(dedent("""
247-
from test.support.interpreters import channels
247+
from interpreters import channels
248248
r, s = channels.create()
249249
orig = b'spam'
250250
s.send_nowait(orig)
@@ -387,7 +387,7 @@ def common(rch, sch, unbound=None, presize=0):
387387
interp = interpreters.create()
388388

389389
_run_output(interp, dedent(f"""
390-
from test.support.interpreters import channels
390+
from interpreters import channels
391391
sch = channels.SendChannel({sch.id})
392392
obj1 = b'spam'
393393
obj2 = b'eggs'
@@ -482,7 +482,7 @@ def test_send_cleared_with_subinterpreter_mixed(self):
482482
self.assertEqual(_channels.get_count(rch.id), 0)
483483

484484
_run_output(interp, dedent(f"""
485-
from test.support.interpreters import channels
485+
from interpreters import channels
486486
sch = channels.SendChannel({sch.id})
487487
sch.send_nowait(1, unbounditems=channels.UNBOUND)
488488
sch.send_nowait(2, unbounditems=channels.UNBOUND_ERROR)
@@ -518,15 +518,15 @@ def test_send_cleared_with_subinterpreter_multiple(self):
518518

519519
sch.send_nowait(1)
520520
_run_output(interp1, dedent(f"""
521-
from test.support.interpreters import channels
521+
from interpreters import channels
522522
rch = channels.RecvChannel({rch.id})
523523
sch = channels.SendChannel({sch.id})
524524
obj1 = rch.recv()
525525
sch.send_nowait(2, unbounditems=channels.UNBOUND)
526526
sch.send_nowait(obj1, unbounditems=channels.UNBOUND_REMOVE)
527527
"""))
528528
_run_output(interp2, dedent(f"""
529-
from test.support.interpreters import channels
529+
from interpreters import channels
530530
rch = channels.RecvChannel({rch.id})
531531
sch = channels.SendChannel({sch.id})
532532
obj2 = rch.recv()

Lib/test/test_interpreters/test_lifecycle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_sys_path_0(self):
119119
# The main interpreter's sys.path[0] should be used by subinterpreters.
120120
script = '''
121121
import sys
122-
from test.support import interpreters
122+
import interpreters
123123
124124
orig = sys.path[0]
125125
@@ -170,7 +170,7 @@ def test_gh_109793(self):
170170
# is reported, even when subinterpreters get cleaned up at the end.
171171
import subprocess
172172
argv = [sys.executable, '-c', '''if True:
173-
from test.support import interpreters
173+
import interpreters
174174
interp = interpreters.create()
175175
raise Exception
176176
''']

0 commit comments

Comments
 (0)