msg86038 - (view) |
Author: Daniel Stutzbach (stutzbach)  |
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) *  |
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) *  |
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) *  |
Date: 2010-04-26 22:18 |
Hello See also #8350 Regards |
|
|
msg111174 - (view) |
Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) *  |
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)  |
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. |
|
|