[New-bugs-announce] [issue2810] _winreg.EnumValue fails when the registry data includes multibyte unicode characters

Daniel Stutzbach report at bugs.python.org
Sat May 10 19:37:34 CEST 2008


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

_winreg.EnumValue raises a WindowsError ("More data is available") if
the registry data includes multibyte unicode characters.

Inspecting PyEnumValue in _winreg.c, I believe I see the problem.  The
function uses RegQueryInfoKey to determine the maximum data and key name
sizes to pass to RegEnumValue.

Unfortunately, RegQueryInfoKey returns the size in number of unicode
characters, while RegEnumValue expects a size in bytes.  This is OK if
all the values are ASCII, but it fails if there are any multibyte
unicode characters.

I believe it would be sufficient to multiply the sizes by 4, since
that's the maximum width of a unicode character.

The bug exists in at least Python 2.5 and Python 3.0 (based on source
code inspection).

References:

RegEnumValue: http://msdn.microsoft.com/en-us/library/ms724865(VS.85).aspx

RegQueryInfoKey:
http://msdn.microsoft.com/en-us/library/ms724902(VS.85).aspx

----------
components: Windows
messages: 66542
nosy: stutzbach
severity: normal
status: open
title: _winreg.EnumValue fails when the registry data includes multibyte unicode characters
type: behavior
versions: Python 2.5, Python 3.0

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2810>
__________________________________


More information about the New-bugs-announce mailing list