Index: Lib/test/test_winreg.py =================================================================== --- Lib/test/test_winreg.py (revision 76107) +++ Lib/test/test_winreg.py (working copy) @@ -42,7 +42,7 @@ def delete_tree(self, root, subkey): try: - hkey = OpenKey(root, subkey, KEY_ALL_ACCESS) + hkey = OpenKey(root, subkey, sam=KEY_ALL_ACCESS) except WindowsError: # subkey does not exist return Index: PC/_winreg.c =================================================================== --- PC/_winreg.c (revision 76107) +++ PC/_winreg.c (working copy) @@ -1218,17 +1218,21 @@ } static PyObject * -PyOpenKey(PyObject *self, PyObject *args) +PyOpenKey(PyObject *self, PyObject *args, PyObject *kwargs) { HKEY hKey; PyObject *obKey; + PyObject *samobj = NULL; char *subKey; int res = 0; HKEY retKey; long rc; REGSAM sam = KEY_READ; - if (!PyArg_ParseTuple(args, "Oz|ii:OpenKey", &obKey, &subKey, + + char *kwlist[] = {"key", "sub_key", "res", "sam", 0}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oz|ii:OpenKey", kwlist, &obKey, &subKey, &res, &sam)) return NULL; if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) @@ -1586,8 +1590,8 @@ ExpandEnvironmentStrings_doc }, {"FlushKey", PyFlushKey, METH_VARARGS, FlushKey_doc}, {"LoadKey", PyLoadKey, METH_VARARGS, LoadKey_doc}, - {"OpenKey", PyOpenKey, METH_VARARGS, OpenKey_doc}, - {"OpenKeyEx", PyOpenKey, METH_VARARGS, OpenKeyEx_doc}, + {"OpenKey", (PyCFunction)PyOpenKey, METH_VARARGS|METH_KEYWORDS, OpenKey_doc}, + {"OpenKeyEx", (PyCFunction)PyOpenKey, METH_VARARGS|METH_KEYWORDS, OpenKeyEx_doc}, {"QueryValue", PyQueryValue, METH_VARARGS, QueryValue_doc}, {"QueryValueEx", PyQueryValueEx, METH_VARARGS, QueryValueEx_doc}, {"QueryInfoKey", PyQueryInfoKey, METH_VARARGS, QueryInfoKey_doc},