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: Environment variables are not expanded in _winreg when using REG_EXPAND_SZ.
Type: behavior Stage: resolved
Components: Extension Modules, Windows Versions: Python 2.7
process
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.

Files
File name Uploaded Description Edit
testcase-24042.py rjnienaber, 2011-01-16 18:23
Messages (4)
msg126368 - (view) Author: Richard Nienaber (rjnienaber) Date: 2011-01-16 18:23
According to Microsoft documentation (http://msdn.microsoft.com/en-us/library/ms724884(v=vs.85).aspx) 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: http://ironpython.codeplex.com/workitem/24042
msg126383 - (view) Author: Richard Nienaber (rjnienaber) Date: 2011-01-16 22:28
Further documentation on the RegEnumValue function (used by the _winreg module): http://msdn.microsoft.com/en-us/library/ms724865(v=vs.85).aspx. 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.
History
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