New submission from Daniel Stutzbach <dan...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue8334>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to