Eryk Sun <eryk...@gmail.com> added the comment: PyWin32's win32api.RegQueryValueEx and win32api.RegEnumValue also use the same documented interpretation of REG_MULTI_SZ [1] (i.e. a "sequence of null-terminated strings, terminated by an empty string").
[1]: https://msdn.microsoft.com/en-us/library/ms724884 However, in practice Windows doesn't follow this literal interpretation. For example, the Session Manager (smss.exe) reads the "PendingFileRenameOperations" REG_MULTI_SZ value using the documented runtime library function RtlQueryRegistryValues [2]. By default, this function calls the specified QueryRoutine for each null-terminated string when reading a REG_MULTI_SZ value. [2]: https://msdn.microsoft.com/en-us/library/ff562046 I've verified that RtlQueryRegistryValues does not terminate the read on the first empty string, but instead continues to iterate through the entire value. See the attached test script, rtlqueryreg.py. The following output was obtained after two calls to MoveFileEx with the flag MOVEFILE_DELAY_UNTIL_REBOOT that pended operations to delete "foo" and rename "meep" to "bar": PendingFileRenameOperations, REG_SZ, \??\C:\Temp\foo PendingFileRenameOperations, REG_SZ, <empty> PendingFileRenameOperations, REG_SZ, \??\C:\Temp\meep PendingFileRenameOperations, REG_SZ, \??\C:\Temp\bar Currently, winreg terminates reading this value at the first empty string. For example: >>> hkey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, ... r'SYSTEM\CurrentControlSet\Control\Session Manager') >>> winreg.QueryValueEx(hkey, 'PendingFileRenameOperations') (['\\??\\C:\\Temp\\foo'], 7) This behavior is inconsistent with Windows, which I think presents a strong case for the suggested change. As always, there's an issue with introducing breaking changes. It may be too late in the development cycle to introduce this change in 3.7. ---------- nosy: +eryksun stage: -> needs patch type: -> behavior versions: +Python 3.7, Python 3.8 Added file: https://bugs.python.org/file47394/rtlqueryreg.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32587> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com