This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: registry functions don't handle null characters
Type: Stage:
Components: Windows Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: mhammond Nosy List: amaury.forgeotdarc, loewis, mhammond
Priority: normal Keywords:

Created on 2003-01-21 23:09 by mhammond, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (3)
msg60302 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2003-01-21 23:09
As determined via
http://mail.python.org/pipermail/python-win32/2003-January/000745.html

Registry *value names* (not just the data values) can
contain embedded NULL characters, and indeed appear to
be Unicode - ie, WinNT registry uses Unicode natively,
and the value names are MBCS encoded in the "A" API
version of these functions.

_winreg.EnumValue, _winreg.EnumKey (and the same in the
win32api module) are affected.

I wonder if a fix to this should actually return
Unicode objects if a high-byte exists?  At the very
least, we must use the "length" of the valuename
returned, rather than assuming null termination.
msg60303 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-01-22 09:15
Logged In: YES 
user_id=21627

The "traditional" Python approach is to return a byte string
if possible, for compatibility, and a Unicode object otherwise.

"If possible" often means "if the system default encoding
permits", or, as in _tkinter, "if the string is plain ASCII".

I expect one day people will complain that they can't access
certain registry keys, because those use characters not
supported in CP_ACP.

So it might be reasonable to use the *W functions
throughout, and convert to byte strings if they are ASCII,
and to Unicode objects otherwise. For incoming byte strings,
you probably have to assume they are CP_ACP encoded, for
compatibility with earlier Python releases.
msg76892 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-12-04 16:23
"""I expect one day people will complain that they can't access
certain registry keys, because those use characters not
supported in CP_ACP.
"""

These people should migrate to python 3.0.
History
Date User Action Args
2022-04-10 16:06:10adminsetgithub: 37818
2008-12-04 16:23:11amaury.forgeotdarcsetstatus: open -> closed
nosy: + amaury.forgeotdarc
resolution: out of date
messages: + msg76892
2003-01-21 23:09:39mhammondcreate