]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-140916: Remove unused codes in winreg.c (#140934)
authorAN Long <aisk@users.noreply.github.com>
Wed, 5 Nov 2025 21:49:45 +0000 (06:49 +0900)
committerGitHub <noreply@github.com>
Wed, 5 Nov 2025 21:49:45 +0000 (22:49 +0100)
PC/winreg.c

index c7bc74728f1ff9a65fff44e2c6a08845619b18b1..3cc6123fc3ab4d62e0d11bca618d29f0dd77226c 100644 (file)
@@ -425,19 +425,6 @@ static PyType_Spec pyhkey_type_spec = {
 /************************************************************************
    The public PyHKEY API (well, not public yet :-)
 ************************************************************************/
-PyObject *
-PyHKEY_New(PyObject *m, HKEY hInit)
-{
-    winreg_state *st = _PyModule_GetState(m);
-    PyHKEYObject *key = PyObject_GC_New(PyHKEYObject, st->PyHKEY_Type);
-    if (key == NULL) {
-        return NULL;
-    }
-    key->hkey = hInit;
-    PyObject_GC_Track(key);
-    return (PyObject *)key;
-}
-
 BOOL
 PyHKEY_Close(winreg_state *st, PyObject *ob_handle)
 {
@@ -513,48 +500,6 @@ PyHKEY_FromHKEY(winreg_state *st, HKEY h)
 }
 
 
-/************************************************************************
-  The module methods
-************************************************************************/
-BOOL
-PyWinObject_CloseHKEY(winreg_state *st, PyObject *obHandle)
-{
-    BOOL ok;
-    if (PyHKEY_Check(st, obHandle)) {
-        ok = PyHKEY_Close(st, obHandle);
-    }
-#if SIZEOF_LONG >= SIZEOF_HKEY
-    else if (PyLong_Check(obHandle)) {
-        long rc;
-        Py_BEGIN_ALLOW_THREADS
-        rc = RegCloseKey((HKEY)PyLong_AsLong(obHandle));
-        Py_END_ALLOW_THREADS
-        ok = (rc == ERROR_SUCCESS);
-        if (!ok)
-            PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey");
-    }
-#else
-    else if (PyLong_Check(obHandle)) {
-        long rc;
-        HKEY hkey = (HKEY)PyLong_AsVoidPtr(obHandle);
-        Py_BEGIN_ALLOW_THREADS
-        rc = RegCloseKey(hkey);
-        Py_END_ALLOW_THREADS
-        ok = (rc == ERROR_SUCCESS);
-        if (!ok)
-            PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey");
-    }
-#endif
-    else {
-        PyErr_SetString(
-            PyExc_TypeError,
-            "A handle must be a HKEY object or an integer");
-        return FALSE;
-    }
-    return ok;
-}
-
-
 /*
    Private Helper functions for the registry interfaces