]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-20486: Implement Database.Close() method in msilib (GH-4141)
authorBerker Peksag <berker.peksag@gmail.com>
Tue, 7 Nov 2017 12:58:53 +0000 (15:58 +0300)
committerGitHub <noreply@github.com>
Tue, 7 Nov 2017 12:58:53 +0000 (15:58 +0300)
Doc/library/msilib.rst
Misc/NEWS.d/next/Windows/2017-10-26-23-02-57.bpo-20486.3IdsZ1.rst [new file with mode: 0644]
PC/_msi.c

index 09d00a6edee2ee330de9c317f6e8dcc301bb0aaa..a66e52ca57691d695ee1d812dbf3e4e15288a37f 100644 (file)
@@ -152,12 +152,18 @@ Database Objects
    :c:func:`MsiGetSummaryInformation`.  *count* is the maximum number of updated
    values.
 
+.. method:: Database.Close()
+
+   Close the database object, through :c:func:`MsiCloseHandle`.
+
+   .. versionadded:: 3.7
 
 .. seealso::
 
    `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>`_
    `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:
 
diff --git a/Misc/NEWS.d/next/Windows/2017-10-26-23-02-57.bpo-20486.3IdsZ1.rst b/Misc/NEWS.d/next/Windows/2017-10-26-23-02-57.bpo-20486.3IdsZ1.rst
new file mode 100644 (file)
index 0000000..d65971e
--- /dev/null
@@ -0,0 +1,2 @@
+Implement the ``Database.Close()`` method to help closing MSI database
+objects.
index a15f68450b3e4b917b2be0c2a738040e70cd73a0..df6c881b4ec44fd19f8abfa72fd96deb8505fd2a 100644 (file)
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -286,14 +286,6 @@ msiobj_dealloc(msiobj* msidb)
     PyObject_Del(msidb);
 }
 
-static PyObject*
-msiobj_close(msiobj* msidb, PyObject *args)
-{
-    MsiCloseHandle(msidb->h);
-    msidb->h = 0;
-    Py_RETURN_NONE;
-}
-
 static PyObject*
 msierror(int status)
 {
@@ -342,6 +334,17 @@ msierror(int status)
     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 **********************/
 
 static PyObject*
@@ -901,6 +904,8 @@ static PyMethodDef db_methods[] = {
         PyDoc_STR("Commit() -> None\nWraps MsiDatabaseCommit")},
     { "GetSummaryInformation", (PyCFunction)msidb_getsummaryinformation, METH_VARARGS,
         PyDoc_STR("GetSummaryInformation(updateCount) -> viewobj\nWraps MsiGetSummaryInformation")},
+    { "Close", (PyCFunction)msidb_close, METH_NOARGS,
+        PyDoc_STR("Close() -> None\nWraps MsiCloseHandle")},
     { NULL, NULL }
 };