Skip to content

Commit fc967a2

Browse files
committed
Fix test_capi.
1 parent 6c175d3 commit fc967a2

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

Lib/test/test_capi/test_getargs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,7 @@ def test_gh_119213(self):
14451445
use_main_obmalloc=False,
14461446
gil=2,
14471447
check_multi_interp_extensions=True,
1448+
can_handle_signals=True,
14481449
)
14491450
rc = support.run_in_subinterp_with_config(script, **config)
14501451
assert rc == 0

Lib/test/test_capi/test_misc.py

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,8 +1730,9 @@ def test_configured_settings(self):
17301730
DAEMON_THREADS = 1<<11
17311731
FORK = 1<<15
17321732
EXEC = 1<<16
1733+
SIGNALS = 1<<17
17331734
ALL_FLAGS = (OBMALLOC | FORK | EXEC | THREADS | DAEMON_THREADS
1734-
| EXTENSIONS);
1735+
| EXTENSIONS | SIGNALS);
17351736

17361737
features = [
17371738
'obmalloc',
@@ -1741,23 +1742,25 @@ def test_configured_settings(self):
17411742
'daemon_threads',
17421743
'extensions',
17431744
'own_gil',
1745+
'signals',
17441746
]
17451747
kwlist = [f'allow_{n}' for n in features]
17461748
kwlist[0] = 'use_main_obmalloc'
1747-
kwlist[-2] = 'check_multi_interp_extensions'
1748-
kwlist[-1] = 'own_gil'
1749+
kwlist[-3] = 'check_multi_interp_extensions'
1750+
kwlist[-2] = 'own_gil'
1751+
kwlist[-1] = 'can_handle_signals'
17491752

17501753
expected_to_work = {
1751-
(True, True, True, True, True, True, True):
1754+
(True, True, True, True, True, True, True, True):
17521755
(ALL_FLAGS, True),
1753-
(True, False, False, False, False, False, False):
1756+
(True, False, False, False, False, False, False, False):
17541757
(OBMALLOC, False),
1755-
(False, False, False, True, False, True, False):
1758+
(False, False, False, True, False, True, False, False):
17561759
(THREADS | EXTENSIONS, False),
17571760
}
17581761

17591762
expected_to_fail = {
1760-
(False, False, False, False, False, False, False),
1763+
(False, False, False, False, False, False, False, False),
17611764
}
17621765

17631766
# gh-117649: The free-threaded build does not currently allow
@@ -1824,14 +1827,16 @@ def test_overridden_setting_extensions_subinterp_check(self):
18241827
DAEMON_THREADS = 1<<11
18251828
FORK = 1<<15
18261829
EXEC = 1<<16
1827-
BASE_FLAGS = OBMALLOC | FORK | EXEC | THREADS | DAEMON_THREADS
1830+
SIGNALS = 1<<17
1831+
BASE_FLAGS = OBMALLOC | FORK | EXEC | THREADS | DAEMON_THREADS | SIGNALS
18281832
base_kwargs = {
18291833
'use_main_obmalloc': True,
18301834
'allow_fork': True,
18311835
'allow_exec': True,
18321836
'allow_threads': True,
18331837
'allow_daemon_threads': True,
18341838
'own_gil': False,
1839+
'can_handle_signals': True
18351840
}
18361841

18371842
def check(enabled, override):
@@ -1961,6 +1966,7 @@ class InterpreterConfigTests(unittest.TestCase):
19611966
allow_threads=True,
19621967
allow_daemon_threads=False,
19631968
check_multi_interp_extensions=True,
1969+
can_handle_signals=True,
19641970
gil='own',
19651971
),
19661972
'legacy': types.SimpleNamespace(
@@ -1970,6 +1976,7 @@ class InterpreterConfigTests(unittest.TestCase):
19701976
allow_threads=True,
19711977
allow_daemon_threads=True,
19721978
check_multi_interp_extensions=bool(Py_GIL_DISABLED),
1979+
can_handle_signals=False,
19731980
gil='shared',
19741981
),
19751982
'empty': types.SimpleNamespace(
@@ -1979,6 +1986,7 @@ class InterpreterConfigTests(unittest.TestCase):
19791986
allow_threads=False,
19801987
allow_daemon_threads=False,
19811988
check_multi_interp_extensions=False,
1989+
can_handle_signals=False,
19821990
gil='default',
19831991
),
19841992
}
@@ -1991,16 +1999,18 @@ def iter_all_configs(self):
19911999
for allow_threads in (True, False):
19922000
for allow_daemon in (True, False):
19932001
for checkext in (True, False):
1994-
for gil in ('shared', 'own', 'default'):
1995-
yield types.SimpleNamespace(
1996-
use_main_obmalloc=use_main_obmalloc,
1997-
allow_fork=allow_fork,
1998-
allow_exec=allow_exec,
1999-
allow_threads=allow_threads,
2000-
allow_daemon_threads=allow_daemon,
2001-
check_multi_interp_extensions=checkext,
2002-
gil=gil,
2003-
)
2002+
for handle_signals in (True, False):
2003+
for gil in ('shared', 'own', 'default'):
2004+
yield types.SimpleNamespace(
2005+
use_main_obmalloc=use_main_obmalloc,
2006+
allow_fork=allow_fork,
2007+
allow_exec=allow_exec,
2008+
allow_threads=allow_threads,
2009+
allow_daemon_threads=allow_daemon,
2010+
check_multi_interp_extensions=checkext,
2011+
can_handle_signals=handle_signals,
2012+
gil=gil,
2013+
)
20042014

20052015
def assert_ns_equal(self, ns1, ns2, msg=None):
20062016
# This is mostly copied from TestCase.assertDictEqual.
@@ -2175,6 +2185,7 @@ def new_interp(config):
21752185
with self.subTest('main'):
21762186
expected = _interpreters.new_config('legacy')
21772187
expected.gil = 'own'
2188+
expected.can_handle_signals = True
21782189
if Py_GIL_DISABLED:
21792190
expected.check_multi_interp_extensions = False
21802191
interpid, *_ = _interpreters.get_main()

Lib/test/test_threading.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,7 @@ def func():
17981798
allow_threads={allowed},
17991799
allow_daemon_threads={daemon_allowed},
18001800
check_multi_interp_extensions={check_multi_interp_extensions},
1801+
can_handle_signals=True,
18011802
own_gil=False,
18021803
)
18031804
""")

0 commit comments

Comments
 (0)