Skip to content

Commit 7181e56

Browse files
committed
gh-161513: simplify _wmi_query per review
Raise OSError directly on ImportError and do not cache query failures: the lazy import placeholder keeps the unavailable state.
1 parent cb7ba0f commit 7181e56

1 file changed

Lines changed: 0 additions & 4 deletions

File tree

‎Lib/platform.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,9 @@ def _syscmd_ver(system='', release='', version='',
328328

329329

330330
def _wmi_query(table, *keys):
331-
global _wmi
332331
try:
333332
_wmi # Force the deferred import.
334333
except ImportError:
335-
_wmi = None
336-
if not _wmi:
337334
raise OSError("not supported")
338335
table = {
339336
"OS": "Win32_OperatingSystem",
@@ -345,7 +342,6 @@ def _wmi_query(table, *keys):
345342
table,
346343
)).split("\0")
347344
except OSError:
348-
_wmi = None
349345
raise OSError("not supported")
350346
split_data = (i.partition("=") for i in data)
351347
dict_data = {i[0]: i[2] for i in split_data}

0 commit comments

Comments
 (0)