[New-bugs-announce] [issue8334] winreg.QueryValue should return bytes, not unicode

Daniel Stutzbach report at bugs.python.org
Wed Apr 7 17:52:25 CEST 2010


New submission from Daniel Stutzbach <daniel at stutzbachenterprises.com>:

The Windows RegQueryValue function returns a registry value without returning the corresponding type information (e.g., REG_SZ for string, REG_BINARY for binary data, REG_DWORD for a 32-bit number, etc.).

The corresponding wrapper winreg.QueryValue currently calls PyUnicode_FromUnicode on the return data, which is fine if the type happens to be REG_SZ, but gibberish for anything else.  Since the format of data is unknown, it should return a bytes object rather than a unicode object.

If the user wants a REG_SZ converted to the unicode type automatically, than can use winreg.QueryValueEx instead.  QueryValueEx wraps RegQueryValueEx which *does* return the type information of the underlying value.  QueryValueEx uses the type information to convert to an appropriate Python type if possible (or returns a bytes object for unsupported types).

----------
components: Library (Lib), Windows
messages: 102543
nosy: stutzbach
severity: normal
status: open
title: winreg.QueryValue should return bytes, not unicode
type: behavior
versions: Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8334>
_______________________________________


More information about the New-bugs-announce mailing list