mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
[3.14] gh-138192: Fix Context initialization so that all subinterpreters are assigned the MISSING value. (gh-138503) (#138505)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Co-authored-by: Donghee Na <donghee.na@python.org> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
parent
b6fa945ff9
commit
cddb7e6a7a
3 changed files with 13 additions and 4 deletions
|
|
@ -2204,6 +2204,16 @@ class LowLevelTests(TestBase):
|
||||||
whence = eval(text)
|
whence = eval(text)
|
||||||
self.assertEqual(whence, _interpreters.WHENCE_LEGACY_CAPI)
|
self.assertEqual(whence, _interpreters.WHENCE_LEGACY_CAPI)
|
||||||
|
|
||||||
|
def test_contextvars_missing(self):
|
||||||
|
script = f"""
|
||||||
|
import contextvars
|
||||||
|
print(getattr(contextvars.Token, "MISSING", "'doesn't exist'"))
|
||||||
|
"""
|
||||||
|
|
||||||
|
orig = _interpreters.create()
|
||||||
|
text = self.run_and_capture(orig, script)
|
||||||
|
self.assertEqual(text.strip(), "<Token.MISSING>")
|
||||||
|
|
||||||
def test_is_running(self):
|
def test_is_running(self):
|
||||||
def check(interpid, expected):
|
def check(interpid, expected):
|
||||||
with self.assertRaisesRegex(InterpreterError, 'unrecognized'):
|
with self.assertRaisesRegex(InterpreterError, 'unrecognized'):
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix :mod:`contextvars` initialization so that all subinterpreters are assigned the
|
||||||
|
:attr:`~contextvars.Token.MISSING` value.
|
||||||
|
|
@ -1357,11 +1357,8 @@ get_token_missing(void)
|
||||||
PyStatus
|
PyStatus
|
||||||
_PyContext_Init(PyInterpreterState *interp)
|
_PyContext_Init(PyInterpreterState *interp)
|
||||||
{
|
{
|
||||||
if (!_Py_IsMainInterpreter(interp)) {
|
|
||||||
return _PyStatus_OK();
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *missing = get_token_missing();
|
PyObject *missing = get_token_missing();
|
||||||
|
assert(PyUnstable_IsImmortal(missing));
|
||||||
if (PyDict_SetItemString(
|
if (PyDict_SetItemString(
|
||||||
_PyType_GetDict(&PyContextToken_Type), "MISSING", missing))
|
_PyType_GetDict(&PyContextToken_Type), "MISSING", missing))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue