bpo-46297: Fix interpreter crash on startup with multiple PythonPaths set in registry (GH-30466)
This commit is contained in:
parent
74d1663580
commit
c9dc1f491e
@ -734,12 +734,15 @@ class MockWinreg:
|
|||||||
return n.removeprefix(prefix)
|
return n.removeprefix(prefix)
|
||||||
raise OSError("end of enumeration")
|
raise OSError("end of enumeration")
|
||||||
|
|
||||||
def QueryValue(self, hkey):
|
def QueryValue(self, hkey, subkey):
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"QueryValue({hkey})")
|
print(f"QueryValue({hkey}, {subkey})")
|
||||||
hkey = hkey.casefold()
|
hkey = hkey.casefold()
|
||||||
if hkey not in self.open:
|
if hkey not in self.open:
|
||||||
raise RuntimeError("key is not open")
|
raise RuntimeError("key is not open")
|
||||||
|
if subkey:
|
||||||
|
subkey = subkey.casefold()
|
||||||
|
hkey = f'{hkey}\\{subkey}'
|
||||||
try:
|
try:
|
||||||
return self.keys[hkey]
|
return self.keys[hkey]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -400,6 +400,7 @@ Lars Damerow
|
|||||||
Evan Dandrea
|
Evan Dandrea
|
||||||
Eric Daniel
|
Eric Daniel
|
||||||
Scott David Daniels
|
Scott David Daniels
|
||||||
|
Derzsi Dániel
|
||||||
Lawrence D'Anna
|
Lawrence D'Anna
|
||||||
Ben Darnell
|
Ben Darnell
|
||||||
Kushal Das
|
Kushal Das
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
Fixed an interpreter crash on bootup with multiple PythonPaths set in
|
||||||
|
the Windows registry. Patch by Derzsi Dániel.
|
@ -642,19 +642,12 @@ elif not pythonpath:
|
|||||||
i = 0
|
i = 0
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
keyname = winreg.EnumKey(key, i)
|
v = winreg.QueryValue(key, winreg.EnumKey(key, i))
|
||||||
subkey = winreg.OpenKeyEx(key, keyname)
|
except OSError:
|
||||||
if not subkey:
|
break
|
||||||
continue
|
|
||||||
try:
|
|
||||||
v = winreg.QueryValue(subkey)
|
|
||||||
finally:
|
|
||||||
winreg.CloseKey(subkey)
|
|
||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
pythonpath.append(v)
|
pythonpath.append(v)
|
||||||
i += 1
|
i += 1
|
||||||
except OSError:
|
|
||||||
break
|
|
||||||
finally:
|
finally:
|
||||||
winreg.CloseKey(key)
|
winreg.CloseKey(key)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user