Content-Length: 396454 | pFad | http://github.com/python/cpython/pull/117490/commits/7e6432c3ea4e3bdc617b7edbdc740030f8d49d95

9E gh-76785: Handle Legacy Interpreters Properly by ericsnowcurrently · Pull Request #117490 · python/cpython · GitHub
Skip to content

gh-76785: Handle Legacy Interpreters Properly #117490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
require_owned -> restrict
  • Loading branch information
ericsnowcurrently committed Apr 11, 2024
commit 7e6432c3ea4e3bdc617b7edbdc740030f8d49d95
11 changes: 5 additions & 6 deletions Lib/test/support/interpreters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ def whence(self):

def is_running(self):
"""Return whether or not the identified interpreter is running."""
# require_owned is okay since this doesn't modify the interpreter.
return _interpreters.is_running(self._id, require_owned=False)
return _interpreters.is_running(self._id)

# Everything past here is available only to interpreters created by
# interpreters.create().
Expand All @@ -195,15 +194,15 @@ def close(self):
Attempting to destroy the current interpreter results
in an InterpreterError.
"""
return _interpreters.destroy(self._id, require_owned=True)
return _interpreters.destroy(self._id, restrict=True)

def prepare_main(self, ns=None, /, **kwargs):
"""Bind the given values into the interpreter's __main__.

The values must be shareable.
"""
ns = dict(ns, **kwargs) if ns is not None else kwargs
_interpreters.set___main___attrs(self._id, ns, require_owned=True)
_interpreters.set___main___attrs(self._id, ns, restrict=True)

def exec(self, code, /):
"""Run the given source code in the interpreter.
Expand All @@ -223,7 +222,7 @@ def exec(self, code, /):
that time, the previous interpreter is allowed to run
in other threads.
"""
excinfo = _interpreters.exec(self._id, code, require_owned=True)
excinfo = _interpreters.exec(self._id, code, restrict=True)
if excinfo is not None:
raise ExecutionFailed(excinfo)

Expand All @@ -243,7 +242,7 @@ def call(self, callable, /):
# XXX Support args and kwargs.
# XXX Support arbitrary callables.
# XXX Support returning the return value (e.g. via pickle).
excinfo = _interpreters.call(self._id, callable, require_owned=True)
excinfo = _interpreters.call(self._id, callable, restrict=True)
if excinfo is not None:
raise ExecutionFailed(excinfo)

Expand Down
10 changes: 5 additions & 5 deletions Lib/test/test_interpreters/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ def test_destroy(self):
with self.subTest('from C-API'):
interpid = _testinternalcapi.create_interpreter()
with self.assertRaisesRegex(InterpreterError, 'unrecognized'):
_interpreters.destroy(interpid, require_owned=True)
_interpreters.destroy(interpid, restrict=True)
self.assertTrue(
self.interp_exists(interpid))
_interpreters.destroy(interpid)
Expand Down Expand Up @@ -1477,7 +1477,7 @@ def test_get_config(self):
orig = _interpreters.new_config('isolated')
with self.interpreter_from_capi(orig) as interpid:
with self.assertRaisesRegex(InterpreterError, 'unrecognized'):
_interpreters.get_config(interpid, require_owned=True)
_interpreters.get_config(interpid, restrict=True)
config = _interpreters.get_config(interpid)
self.assert_ns_equal(config, orig)

Expand Down Expand Up @@ -1528,7 +1528,7 @@ def test_whence(self):
def test_is_running(self):
def check(interpid, expected):
with self.assertRaisesRegex(InterpreterError, 'unrecognized'):
_interpreters.is_running(interpid, require_owned=True)
_interpreters.is_running(interpid, restrict=True)
running = _interpreters.is_running(interpid)
self.assertIs(running, expected)

Expand Down Expand Up @@ -1598,7 +1598,7 @@ def test_exec(self):
with self.interpreter_from_capi() as interpid:
with self.assertRaisesRegex(InterpreterError, 'unrecognized'):
_interpreters.exec(interpid, 'raise Exception("it worked!")',
require_owned=True)
restrict=True)
exc = _interpreters.exec(interpid, 'raise Exception("it worked!")')
self.assertIsNot(exc, None)
self.assertEqual(exc.msg, 'it worked!')
Expand Down Expand Up @@ -1648,7 +1648,7 @@ def test_set___main___attrs(self):
with self.interpreter_from_capi() as interpid:
with self.assertRaisesRegex(InterpreterError, 'unrecognized'):
_interpreters.set___main___attrs(interpid, {'spam': True},
require_owned=True)
restrict=True)
_interpreters.set___main___attrs(interpid, {'spam': True})
rc = _testinternalcapi.exec_interpreter(
interpid,
Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/pull/117490/commits/7e6432c3ea4e3bdc617b7edbdc740030f8d49d95

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy