Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abfeff7

Browse files
committed
Fix a type in the docstrings, and make the module Unicode aware.
1 parent c64c8ea commit abfeff7

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Lib/plat-win/winreg.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
delete a key if it exists
1616
Note: deleteKey may not be recursive on all platforms.
1717
18-
>>> key=createKey( r"HKLM\SOFTWARE\Python\Test" )
18+
>>> key=deleteKey( r"HKLM\SOFTWARE\Python\Test" )
1919
2020
RemoteKey( machine, top_level_key ):
2121
open a key on another machine.
@@ -139,7 +139,7 @@ def _getName( item, nameFromNum ):
139139
except (WindowsError, EnvironmentError):
140140
raise IndexError, item
141141

142-
elif type( item )==StringType:
142+
elif type( item ) in [StringType, UnicodeType]:
143143
keyname=item
144144
else:
145145
raise exceptions.TypeError, \
@@ -300,13 +300,17 @@ def setValue( self, valname, data, regtype=None ):
300300
if regtype:
301301
typeint=regtype.intval
302302
else:
303-
if type( data )==StringType:
303+
if type( data ) in [StringType, UnicodeType]:
304304
typeint=_winreg.REG_SZ
305+
elif type( data )==ListType:
306+
# XXX - _winreg currently only supports lists
307+
# Also, probably should check each element is
308+
# string/unicode.
309+
typeint = _winreg.REG_MULTI_SZ
305310
elif type( data )==IntType:
306311
typeint=_winreg.REG_DWORD
307312
elif type( data )==array.ArrayType:
308313
typeint=_winreg.REG_BINARY
309-
data=data.tostring()
310314
_winreg.SetValueEx( self.handle, valname, 0, typeint, data )
311315

312316
def flush(self ):

0 commit comments

Comments
 (0)