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

This commit is contained in:
AN Long 2025-11-06 06:49:45 +09:00 committed by GitHub
parent b83f379a97
commit 11fc411f98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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