MCPcopy Index your code
hub / github.com/python/cpython / interpreter_from_capi

Method interpreter_from_capi

Lib/test/test_interpreters/utils.py:523–552  ·  view source on GitHub ↗
(self, config=None, whence=None)

Source from the content-addressed store, hash-verified

521 @requires_test_modules
522 @contextlib.contextmanager
523 def interpreter_from_capi(self, config=None, whence=None):
524 if config is False:
525 if whence is None:
526 whence = _interpreters.WHENCE_LEGACY_CAPI
527 else:
528 assert whence in (_interpreters.WHENCE_LEGACY_CAPI,
529 _interpreters.WHENCE_UNKNOWN), repr(whence)
530 config = None
531 elif config is True:
532 config = _interpreters.new_config('default')
533 elif config is None:
534 if whence not in (
535 _interpreters.WHENCE_LEGACY_CAPI,
536 _interpreters.WHENCE_UNKNOWN,
537 ):
538 config = _interpreters.new_config('legacy')
539 elif isinstance(config, str):
540 config = _interpreters.new_config(config)
541
542 if whence is None:
543 whence = _interpreters.WHENCE_XI
544
545 interpid = _testinternalcapi.create_interpreter(config, whence=whence)
546 try:
547 yield interpid
548 finally:
549 try:
550 _testinternalcapi.destroy_interpreter(interpid)
551 except _interpreters.InterpreterNotFoundError:
552 pass
553
554 @contextlib.contextmanager
555 def interpreter_obj_from_capi(self, config='legacy'):

Callers 8

test_get_configMethod · 0.80
test_whenceMethod · 0.80
test_is_runningMethod · 0.80
test_execMethod · 0.80

Calls 1

new_configMethod · 0.80

Tested by 7

test_get_configMethod · 0.64
test_whenceMethod · 0.64
test_is_runningMethod · 0.64
test_execMethod · 0.64