Skip to content

Commit

Permalink
DO-NOT-MERGE: Explore reasons for ctypes test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
zware committed Apr 7, 2020
1 parent d8acf0d commit e903e8c
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions Lib/test/__main__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
from test.libregrtest import main
main()
import os
import sys

try:
import winreg
except ImportError:
sys.exit(0)

found = False
for d in os.environ['PATH'].split(os.pathsep):
print('Checking', d)
try:
with os.scandir(d) as sd:
for de in sd:
if de.name == '_sqlite3.dll' and de.is_file():
print('Found _sqlite3.dll at', de.path)
found = True
except OSError as e:
print(e)

try:
value = winreg.QueryValueEx(
winreg.OpenKeyEx(
winreg.HKEY_LOCAL_MACHINE,
'SYSTEM\\CurrentControlSet\\Control\\Session Manager'
),
'CWDIllegalInDllSearch'
)
except FileNotFoundError:
print('CWDIllegalInDllSearch not set')
else:
print('CWDIllegalInDllSearch set to', value)
found = True

base_key = winreg.OpenKeyEx(
winreg.HKEY_LOCAL_MACHINE,
'Software\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options'
)
for i in range(winreg.QueryInfoKey(base_key)[0]):
sub_key_name = winreg.EnumKey(base_key, i)
print(sub_key_name)
if 'py' not in sub_key_name:
continue
sub_key = winreg.OpenKeyEx(base_key, sub_key_name)
for j in range(winreg.QueryInfoKey(sub_key)[1]):
name, value, type = winreg.EnumValue(sub_key, j)
if 'CWD' in name:
print(name, value, type)
found = True

if found:
raise FileExistsError('Found it')

0 comments on commit e903e8c

Please sign in to comment.