Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

Commit

Permalink
Fix #777 (#1486)
Browse files Browse the repository at this point in the history
* Fix #777

* Fix for failing test
  • Loading branch information
slozier authored and slide committed Oct 22, 2016
1 parent 1def2c3 commit bd98ae7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Languages/IronPython/IronPython.Modules/_winreg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ public static PythonTuple EnumValue(object key, int index) {
}

private static void QueryValueExImpl(SafeRegistryHandle handle, string valueName, out int valueKind, out object value) {
valueName = valueName ?? ""; // it looks like RegQueryValueEx can fail with null, use empty string instead
valueKind = 0;
int dwRet;
byte[] data = new byte[128];
Expand All @@ -278,6 +279,13 @@ private static void QueryValueExImpl(SafeRegistryHandle handle, string valueName
dwRet = RegQueryValueEx(handle, valueName, IntPtr.Zero, out valueKind, data, ref length);
}

if (dwRet == PythonExceptions._WindowsError.ERROR_FILE_NOT_FOUND) {
throw PythonExceptions.CreateThrowable(PythonExceptions.WindowsError, PythonExceptions._WindowsError.ERROR_FILE_NOT_FOUND, "The system cannot find the file specified");
}
if (dwRet != ERROR_SUCCESS) {
throw PythonExceptions.CreateThrowable(PythonExceptions.WindowsError, dwRet);
}

// convert the result into a Python object

switch (valueKind) {
Expand Down

0 comments on commit bd98ae7

Please sign in to comment.