https://github.com/python/cpython/commit/11fc411f98a04947a2a21329c29fe0f35ff52dba
commit: 11fc411f98a04947a2a21329c29fe0f35ff52dba
branch: main
author: AN Long <[email protected]>
committer: vstinner <[email protected]>
date: 2025-11-05T22:49:45+01:00
summary:

gh-140916: Remove unused codes in winreg.c (#140934)

files:
M PC/winreg.c

diff --git a/PC/winreg.c b/PC/winreg.c
index c7bc74728f1ff9..3cc6123fc3ab4d 100644
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -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
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to