Skip to content

Commit 0b281f9

Browse files
authored
bpo-42748: test_asdl_parser now uses exec_module instead of load_module (#23954)
1 parent ea25180 commit 0b281f9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/test/test_asdl_parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for the asdl parser in Parser/asdl.py"""
22

33
import importlib.machinery
4+
import importlib.util
45
import os
56
from os.path import dirname
67
import sys
@@ -26,7 +27,10 @@ def setUpClass(cls):
2627
sys.path.insert(0, parser_dir)
2728
loader = importlib.machinery.SourceFileLoader(
2829
'asdl', os.path.join(parser_dir, 'asdl.py'))
29-
cls.asdl = loader.load_module()
30+
spec = importlib.util.spec_from_loader('asdl', loader)
31+
module = importlib.util.module_from_spec(spec)
32+
loader.exec_module(module)
33+
cls.asdl = module
3034
cls.mod = cls.asdl.parse(os.path.join(parser_dir, 'Python.asdl'))
3135
cls.assertTrue(cls.asdl.check(cls.mod), 'Module validation failed')
3236

0 commit comments

Comments
 (0)