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: _winreg.OpenKey() is documented with keyword arguments, but doesn't take them
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brian.curtin Nosy List: amaury.forgeotdarc, brian.curtin, eric.araujo, stutzbach
Priority: normal Keywords: needs review, patch

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 "<stdin>", line 1, in <module>
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:47adminsetgithub: 50024
2010-07-22 14:27:35stutzbachsetmessages: + msg111175
2010-07-22 14:13:04amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg111174
2010-04-26 22:18:26eric.araujosetnosy: + eric.araujo
messages: + msg104282
2010-04-24 17:28:39brian.curtinsetstatus: open -> closed

assignee: brian.curtin
components: + Documentation, - Library (Lib)
versions: + Python 3.1, Python 2.7, Python 3.2
resolution: fixed
messages: + msg104107
stage: patch review -> resolved
2010-01-13 02:56:08brian.curtinsetkeywords: + needs review
files: + issue5774.patch
2010-01-13 02:54:40brian.curtinsetfiles: - issue5774_20091104_v1.patch
2010-01-13 02:09:07brian.curtinsetpriority: normal
type: behavior
stage: patch review
2009-11-04 22:27:14brian.curtinsetfiles: + issue5774_20091104_v1.patch

nosy: + brian.curtin
messages: + msg94906

keywords: + patch
2009-04-16 19:06:11stutzbachcreate