[issue2810] _winreg.EnumValue fails when the registry data includes multibyte unicode characters

Erik Nolte report at bugs.python.org
Thu Oct 2 19:20:27 CEST 2008


Erik Nolte <erik_nolte at acm.org> added the comment:

To reproduce on Windows XP with Python 2.4, 2.5, and 2.6:

1. Import issue_2810.reg (it creates two keys under
HKCU\PythonTestUnicodeKeys: one with a one byte unicode char in the key,
the other with multiple 2-byte unicode chars)

2. Run the following:
import _winreg

key = _winreg.OpenKey( _winreg.HKEY_CURRENT_USER, "PythonTestUnicodeKeys" )

one_byte_key = _winreg.EnumKey( key, 0 )
two_byte_key = _winreg.EnumKey( key, 1 )

_winreg.CloseKey( key )

try:
    unicode( one_byte_key )
except Exception, ex:
    print "EnumKey didn't return a valid string:", ex
    
print "should be unicode, not str:", two_byte_key.__class__
for ch in two_byte_key:
    print ord( ch ),
print ""

----------
nosy: +enolte
versions: +Python 2.4, Python 2.6 -Python 3.0
Added file: http://bugs.python.org/file11681/issue_2810.reg

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


More information about the Python-bugs-list mailing list