|
12 | 12 | import importlib |
13 | 13 | import importlib.util |
14 | 14 | import os |
15 | | -import platform |
16 | 15 | import re |
17 | 16 | import stat |
18 | 17 | import struct |
19 | | -import subprocess |
20 | 18 | import sys |
21 | 19 | import sysconfig |
22 | 20 | import time |
|
81 | 79 | # The timeout should be long enough for connect(), recv() and send() methods |
82 | 80 | # of socket.socket. |
83 | 81 | LOOPBACK_TIMEOUT = 5.0 |
84 | | -if sys.platform == 'win32' and platform.machine() == 'ARM': |
| 82 | +if sys.platform == 'win32' and ' 32 bit (ARM)' in sys.version: |
85 | 83 | # bpo-37553: test_socket.SendfileUsingSendTest is taking longer than 2 |
86 | 84 | # seconds on Windows ARM32 buildbot |
87 | 85 | LOOPBACK_TIMEOUT = 10 |
@@ -481,6 +479,7 @@ def forget(modname): |
481 | 479 | def _is_gui_available(): |
482 | 480 | if hasattr(_is_gui_available, 'result'): |
483 | 481 | return _is_gui_available.result |
| 482 | + import platform |
484 | 483 | reason = None |
485 | 484 | if sys.platform.startswith('win') and platform.win32_is_iot(): |
486 | 485 | reason = "gui is not available on Windows IoT Core" |
@@ -581,6 +580,7 @@ def _requires_unix_version(sysname, min_version): |
581 | 580 | def decorator(func): |
582 | 581 | @functools.wraps(func) |
583 | 582 | def wrapper(*args, **kw): |
| 583 | + import platform |
584 | 584 | if platform.system() == sysname: |
585 | 585 | version_txt = platform.release().split('-', 1)[0] |
586 | 586 | try: |
@@ -627,6 +627,7 @@ def decorator(func): |
627 | 627 | @functools.wraps(func) |
628 | 628 | def wrapper(*args, **kw): |
629 | 629 | if sys.platform == 'darwin': |
| 630 | + import platform |
630 | 631 | version_txt = platform.mac_ver()[0] |
631 | 632 | try: |
632 | 633 | version = tuple(map(int, version_txt.split('.'))) |
@@ -1607,6 +1608,7 @@ def start(self): |
1607 | 1608 | sys.stderr.flush() |
1608 | 1609 | return |
1609 | 1610 |
|
| 1611 | + import subprocess |
1610 | 1612 | with f: |
1611 | 1613 | watchdog_script = findfile("memory_watchdog.py") |
1612 | 1614 | self.mem_watchdog = subprocess.Popen([sys.executable, watchdog_script], |
@@ -2088,11 +2090,13 @@ def swap_item(obj, item, new_val): |
2088 | 2090 | def args_from_interpreter_flags(): |
2089 | 2091 | """Return a list of command-line arguments reproducing the current |
2090 | 2092 | settings in sys.flags and sys.warnoptions.""" |
| 2093 | + import subprocess |
2091 | 2094 | return subprocess._args_from_interpreter_flags() |
2092 | 2095 |
|
2093 | 2096 | def optim_args_from_interpreter_flags(): |
2094 | 2097 | """Return a list of command-line arguments reproducing the current |
2095 | 2098 | optimization settings in sys.flags.""" |
| 2099 | + import subprocess |
2096 | 2100 | return subprocess._optim_args_from_interpreter_flags() |
2097 | 2101 |
|
2098 | 2102 |
|
@@ -2233,6 +2237,7 @@ def __exit__(self, exc_type, exc_value, exc_tb): |
2233 | 2237 | print("failed to clean up {}: {}".format(link, ex)) |
2234 | 2238 |
|
2235 | 2239 | def _call(self, python, args, env, returncode): |
| 2240 | + import subprocess |
2236 | 2241 | cmd = [python, *args] |
2237 | 2242 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
2238 | 2243 | stderr=subprocess.PIPE, env=env) |
@@ -2261,6 +2266,7 @@ def can_xattr(): |
2261 | 2266 | if not hasattr(os, "setxattr"): |
2262 | 2267 | can = False |
2263 | 2268 | else: |
| 2269 | + import platform |
2264 | 2270 | tmp_dir = tempfile.mkdtemp() |
2265 | 2271 | tmp_fp, tmp_name = tempfile.mkstemp(dir=tmp_dir) |
2266 | 2272 | try: |
@@ -2445,6 +2451,7 @@ def __enter__(self): |
2445 | 2451 | pass |
2446 | 2452 |
|
2447 | 2453 | if sys.platform == 'darwin': |
| 2454 | + import subprocess |
2448 | 2455 | # Check if the 'Crash Reporter' on OSX was configured |
2449 | 2456 | # in 'Developer' mode and warn that it will get triggered |
2450 | 2457 | # when it is. |
@@ -2591,6 +2598,7 @@ def setswitchinterval(interval): |
2591 | 2598 | if is_android and interval < minimum_interval: |
2592 | 2599 | global _is_android_emulator |
2593 | 2600 | if _is_android_emulator is None: |
| 2601 | + import subprocess |
2594 | 2602 | _is_android_emulator = (subprocess.check_output( |
2595 | 2603 | ['getprop', 'ro.kernel.qemu']).strip() == b'1') |
2596 | 2604 | if _is_android_emulator: |
|
0 commit comments