Skip to content

Commit 1165950

Browse files
committed
Account for the RuntimeWarning when import a singlephase init extension under the free-threaded build
1 parent 29b1b68 commit 1165950

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Lib/test/test_embed.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,21 @@ def test_repeated_init_and_inittab(self):
241241

242242
def test_create_module_from_initfunc(self):
243243
out, err = self.run_embedded_interpreter("test_create_module_from_initfunc")
244-
self.assertEqual(err, "")
244+
if support.Py_GIL_DISABLED:
245+
# the test imports a singlephase init extension, so it emits a warning
246+
# under the free-threaded build
247+
expected_runtime_warning = (
248+
"RuntimeWarning: The global interpreter lock (GIL)"
249+
" has been enabled to load module 'embedded_ext'"
250+
)
251+
filtered_err_lines = [
252+
line
253+
for line in err.strip().splitlines()
254+
if expected_runtime_warning not in line
255+
]
256+
self.assertEqual(filtered_err_lines, [])
257+
else:
258+
self.assertEqual(err, "")
245259
self.assertEqual(out,
246260
"<module 'my_test_extension' (static-extension)>\n"
247261
"my_test_extension.executed='yes'\n"

0 commit comments

Comments
 (0)