From bd98ae7590e06e35f7474293b99d380e56f143e2 Mon Sep 17 00:00:00 2001 From: slozier Date: Fri, 21 Oct 2016 23:34:02 -0400 Subject: [PATCH] Fix #777 (#1486) * Fix #777 * Fix for failing test --- Languages/IronPython/IronPython.Modules/_winreg.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Languages/IronPython/IronPython.Modules/_winreg.cs b/Languages/IronPython/IronPython.Modules/_winreg.cs index 10a667e948..fce8db5316 100644 --- a/Languages/IronPython/IronPython.Modules/_winreg.cs +++ b/Languages/IronPython/IronPython.Modules/_winreg.cs @@ -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]; @@ -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) {