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.

Title: Environment variables are not expanded in _winreg when using REG_EXPAND_SZ.
Type: behavior Stage: resolved
Components: Extension Modules, Windows Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: brian.curtin Nosy List: brian.curtin, rjnienaber
Priority: normal Keywords:

Created on 2011-01-16 18:23 by rjnienaber, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit rjnienaber, 2011-01-16 18:23
Messages (4)
msg126368 - (view) Author: Richard Nienaber (rjnienaber) Date: 2011-01-16 18:23
According to Microsoft documentation ( when using the REG_EXPAND_SZ value type, environment variables (e.g. %programfiles%) should be expanded to their values (e.g. 'C:\Program Files'). 

I've added a test case that reproduces this error.
msg126369 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2011-01-16 19:06
Assigning to myself.
Relevant IronPython issue:
msg126383 - (view) Author: Richard Nienaber (rjnienaber) Date: 2011-01-16 22:28
Further documentation on the RegEnumValue function (used by the _winreg module): The documentation doesn't say whether the string is expanded or not on retrieval. 

Given the current behaviour plus the ExpandEnvironmentStrings function, this seems like a non-issue.
msg178027 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2012-12-24 02:23
Yep. The documentation you linked says "A null-terminated string that contains unexpanded references to environment variables (for example, "%PATH%"). It will be a Unicode or ANSI string depending on whether you use the Unicode or ANSI functions. To expand the environment variable references, use the ExpandEnvironmentStrings function."

Based on that, we're doing the right thing.
Date User Action Args
2022-04-11 14:57:11adminsetgithub: 55128
2012-12-24 02:23:25brian.curtinsetstatus: open -> closed
resolution: not a bug
messages: + msg178027

stage: needs patch -> resolved
2011-01-16 22:28:11rjnienabersetmessages: + msg126383
2011-01-16 19:06:26brian.curtinsetassignee: brian.curtin
type: behavior
components: + Extension Modules, Windows, - Library (Lib)

nosy: + brian.curtin
messages: + msg126369
stage: needs patch
2011-01-16 18:23:27rjnienabercreate