From 2ebec1f9c86eefc24ee8268b1508772c327eda75 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Thu, 5 Oct 2023 14:11:43 -0400 Subject: [PATCH 1/2] gh-110119: Fix test_importlib `--disable-gil` Windows test failures Use "t" in the expected tag for `--disable-gil` builds in test_tagged_suffix. --- Lib/test/test_importlib/test_windows.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_importlib/test_windows.py b/Lib/test/test_importlib/test_windows.py index a7586b3d95dc14..be9cea524ffb9c 100644 --- a/Lib/test/test_importlib/test_windows.py +++ b/Lib/test/test_importlib/test_windows.py @@ -4,6 +4,7 @@ import os import re import sys +import sysconfig import unittest from test.support import import_helper from contextlib import contextmanager @@ -111,7 +112,9 @@ def test_module_not_found(self): class WindowsExtensionSuffixTests: def test_tagged_suffix(self): suffixes = self.machinery.EXTENSION_SUFFIXES - expected_tag = ".cp{0.major}{0.minor}-{1}.pyd".format(sys.version_info, + threading_tag = "t" if sysconfig.get_config_var("Py_NOGIL") else "" + expected_tag = ".cp{0.major}{0.minor}{1}-{2}.pyd".format(sys.version_info, + threading_tag, re.sub('[^a-zA-Z0-9]', '_', get_platform())) try: untagged_i = suffixes.index(".pyd") From c6b791baa59672704bce5832f56121713d016f1b Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Thu, 5 Oct 2023 15:18:33 -0400 Subject: [PATCH 2/2] Use suggestion from vstinner --- Lib/test/test_importlib/test_windows.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_importlib/test_windows.py b/Lib/test/test_importlib/test_windows.py index be9cea524ffb9c..a60a4c4cebcf1a 100644 --- a/Lib/test/test_importlib/test_windows.py +++ b/Lib/test/test_importlib/test_windows.py @@ -112,10 +112,10 @@ def test_module_not_found(self): class WindowsExtensionSuffixTests: def test_tagged_suffix(self): suffixes = self.machinery.EXTENSION_SUFFIXES - threading_tag = "t" if sysconfig.get_config_var("Py_NOGIL") else "" - expected_tag = ".cp{0.major}{0.minor}{1}-{2}.pyd".format(sys.version_info, - threading_tag, - re.sub('[^a-zA-Z0-9]', '_', get_platform())) + abi_flags = "t" if sysconfig.get_config_var("Py_NOGIL") else "" + ver = sys.version_info + platform = re.sub('[^a-zA-Z0-9]', '_', get_platform()) + expected_tag = f".cp{ver.major}{ver.minor}{abi_flags}-{platform}.pyd" try: untagged_i = suffixes.index(".pyd") except ValueError: