Issue 5774: _winreg.OpenKey() is documented with keyword arguments, but doesn't take them (original) (raw)

Created on 2009-04-16 19:06 by stutzbach, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue5774.patch brian.curtin,2010-01-13 02:56 fixed tab/space issue. patch against r77458
Messages (6)
msg86038 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2009-04-16 19:06
I noticed this in 2.6, but I imagine it affects 2.7, and 3.x as well. The documentation for _winreg.OpenKey reads in part: _winreg.OpenKey(key, sub_key[, res=0][, sam=KEY_READ]) However: >>> import _winreg >>> _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, 'Software', sam=_winreg.KEY_ALL_ACCESS) Traceback (most recent call last): File "", line 1, in TypeError: OpenKey() takes no keyword arguments Probably the OpenKey implementation should be updated to use PyArg_ParseTupleAndKeywords instead of PyArg_ParseTuple?
msg94906 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2009-11-04 22:27
Attached is a patch against trunk r76107 which fixes OpenKey to take keyword arguments as the documentation states. There is also a small fix to test_winreg - the third param to OpenKey on line 45 is the `res` positional param, which should always be zero according to the doc. The parameter passed is supposed to be the `sam` parameter, which is now passed as a kwarg. There is no actual change to the test results. While looking at this, I'm not sure I see the need for OpenKeyEx - it just points to OpenKey. At the very least, it's parameter list in the documentation is incorrect.
msg104107 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-04-24 17:28
I changed the documentation to reflect that OpenKey, CreateKeyEx, and DeleteKeyEx (latter two are 2.7/3.2 only) do not take keyword arguments, but they have default values. Done in r80445-r80448. I created a feature request in #8521 to implement keyword arguments.
msg104282 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-04-26 22:18
Hello See also #8350 Regards
msg111174 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-07-22 14:13
Please rename "sam" to something readable, "access" for example. And the "reserved" parameter should really go, at least not be documented.
msg111175 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2010-07-22 14:27
+1 on better names, -1 on removing the reserved parameter The parameters of OpenKey mirror those of the underlying RegOpenKey call. If we remove the reserved parameter, then: 1) Any code currently using the sam parameter will break, since it's currently only positional 2) If Microsoft later makes the reserved parameter do something, then we will have to reinsert a parameter before sam or have our arguments in a different order than RegOpenKey For what it's worth, RegOpenKey names the parameters: hKey, lpSubKey, ulOptions, and samDesired.
History
Date User Action Args
2022-04-11 14:56:47 admin set github: 50024
2010-07-22 14:27:35 stutzbach set messages: +
2010-07-22 14:13:04 amaury.forgeotdarc set nosy: + amaury.forgeotdarcmessages: +
2010-04-26 22🔞26 eric.araujo set nosy: + eric.araujomessages: +
2010-04-24 17:28:39 brian.curtin set status: open -> closedassignee: brian.curtincomponents: + Documentation, - Library (Lib)versions: + Python 3.1, Python 2.7, Python 3.2resolution: fixedmessages: + stage: patch review -> resolved
2010-01-13 02:56:08 brian.curtin set keywords: + needs reviewfiles: + issue5774.patch
2010-01-13 02:54:40 brian.curtin set files: - issue5774_20091104_v1.patch
2010-01-13 02:09:07 brian.curtin set priority: normaltype: behaviorstage: patch review
2009-11-04 22:27:14 brian.curtin set files: + issue5774_20091104_v1.patchnosy: + brian.curtinmessages: + keywords: + patch
2009-04-16 19:06:11 stutzbach create