bpo-20486: Implement Database.Close() method in msilib (GH-4141)
This commit is contained in:
parent
3cc4c53a64
commit
a935654f06
|
@ -152,12 +152,18 @@ Database Objects
|
||||||
:c:func:`MsiGetSummaryInformation`. *count* is the maximum number of updated
|
:c:func:`MsiGetSummaryInformation`. *count* is the maximum number of updated
|
||||||
values.
|
values.
|
||||||
|
|
||||||
|
.. method:: Database.Close()
|
||||||
|
|
||||||
|
Close the database object, through :c:func:`MsiCloseHandle`.
|
||||||
|
|
||||||
|
.. versionadded:: 3.7
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
`MSIDatabaseOpenView <https://msdn.microsoft.com/library?url=/library/en-us/msi/setup/msidatabaseopenview.asp>`_
|
`MSIDatabaseOpenView <https://msdn.microsoft.com/library?url=/library/en-us/msi/setup/msidatabaseopenview.asp>`_
|
||||||
`MSIDatabaseCommit <https://msdn.microsoft.com/library?url=/library/en-us/msi/setup/msidatabasecommit.asp>`_
|
`MSIDatabaseCommit <https://msdn.microsoft.com/library?url=/library/en-us/msi/setup/msidatabasecommit.asp>`_
|
||||||
`MSIGetSummaryInformation <https://msdn.microsoft.com/library?url=/library/en-us/msi/setup/msigetsummaryinformation.asp>`_
|
`MSIGetSummaryInformation <https://msdn.microsoft.com/library?url=/library/en-us/msi/setup/msigetsummaryinformation.asp>`_
|
||||||
|
`MsiCloseHandle <https://msdn.microsoft.com/en-us/library/windows/desktop/aa370067(v=vs.85).aspx>`_
|
||||||
|
|
||||||
.. _view-objects:
|
.. _view-objects:
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Implement the ``Database.Close()`` method to help closing MSI database
|
||||||
|
objects.
|
21
PC/_msi.c
21
PC/_msi.c
|
@ -286,14 +286,6 @@ msiobj_dealloc(msiobj* msidb)
|
||||||
PyObject_Del(msidb);
|
PyObject_Del(msidb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject*
|
|
||||||
msiobj_close(msiobj* msidb, PyObject *args)
|
|
||||||
{
|
|
||||||
MsiCloseHandle(msidb->h);
|
|
||||||
msidb->h = 0;
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
msierror(int status)
|
msierror(int status)
|
||||||
{
|
{
|
||||||
|
@ -342,6 +334,17 @@ msierror(int status)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
msidb_close(msiobj* msidb, PyObject *args)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
if ((status = MsiCloseHandle(msidb->h)) != ERROR_SUCCESS) {
|
||||||
|
return msierror(status);
|
||||||
|
}
|
||||||
|
msidb->h = 0;
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************** Record objects **********************/
|
/*************************** Record objects **********************/
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
|
@ -901,6 +904,8 @@ static PyMethodDef db_methods[] = {
|
||||||
PyDoc_STR("Commit() -> None\nWraps MsiDatabaseCommit")},
|
PyDoc_STR("Commit() -> None\nWraps MsiDatabaseCommit")},
|
||||||
{ "GetSummaryInformation", (PyCFunction)msidb_getsummaryinformation, METH_VARARGS,
|
{ "GetSummaryInformation", (PyCFunction)msidb_getsummaryinformation, METH_VARARGS,
|
||||||
PyDoc_STR("GetSummaryInformation(updateCount) -> viewobj\nWraps MsiGetSummaryInformation")},
|
PyDoc_STR("GetSummaryInformation(updateCount) -> viewobj\nWraps MsiGetSummaryInformation")},
|
||||||
|
{ "Close", (PyCFunction)msidb_close, METH_NOARGS,
|
||||||
|
PyDoc_STR("Close() -> None\nWraps MsiCloseHandle")},
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue