Skip to content

Commit bdfe9b6

Browse files
authored
bpo-40275: test.supports imports lazily fnmatch, glob, struct (GH-20810)
1 parent d72b964 commit bdfe9b6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Lib/test/support/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55

66
import contextlib
77
import errno
8-
import fnmatch
98
import functools
10-
import glob
119
import os
1210
import re
1311
import stat
14-
import struct
1512
import sys
1613
import sysconfig
1714
import time
@@ -846,9 +843,11 @@ def python_is_optimized():
846843
_vheader = _header + 'n'
847844

848845
def calcobjsize(fmt):
846+
import struct
849847
return struct.calcsize(_header + fmt + _align)
850848

851849
def calcvobjsize(fmt):
850+
import struct
852851
return struct.calcsize(_vheader + fmt + _align)
853852

854853

@@ -1255,6 +1254,7 @@ def _compile_match_function(patterns):
12551254
# The test.bisect_cmd utility only uses such full test identifiers.
12561255
func = set(patterns).__contains__
12571256
else:
1257+
import fnmatch
12581258
regex = '|'.join(map(fnmatch.translate, patterns))
12591259
# The search *is* case sensitive on purpose:
12601260
# don't use flags=re.IGNORECASE
@@ -1534,6 +1534,7 @@ def _platform_specific(self):
15341534

15351535
if sys.platform == "win32":
15361536
def _platform_specific(self):
1537+
import glob
15371538
import _winapi
15381539

15391540
if os.path.lexists(self.real) and not os.path.exists(self.real):

0 commit comments

Comments
 (0)