]> granicus.if.org Git - python/commitdiff
bpo-12239: Make GetProperty() return None for VT_EMPTY (GH-4539)
authorBerker Peksag <berker.peksag@gmail.com>
Fri, 24 Nov 2017 15:11:18 +0000 (18:11 +0300)
committerGitHub <noreply@github.com>
Fri, 24 Nov 2017 15:11:18 +0000 (18:11 +0300)
The previous behavior was to raise an exception

    NotImplementedError: result of type 0

when the value of the property is VT_EMPTY.

Lib/test/test_msilib.py
Misc/NEWS.d/next/Library/2017-11-24-14-07-55.bpo-12239.Nj3A0x.rst [new file with mode: 0644]
PC/_msi.c

index 4093134195a26eb2953987ef8d7359bdfc4bff83..6d89ca4b77321eb0d29a7967449463f8e186d1fb 100644 (file)
@@ -53,6 +53,13 @@ class MsiDatabaseTestCase(unittest.TestCase):
             msilib.OpenDatabase(db_path, msilib.MSIDBOPEN_CREATE)
         self.assertEqual(str(cm.exception), 'create failed')
 
+    def test_get_property_vt_empty(self):
+        db, db_path = init_database()
+        summary = db.GetSummaryInformation(0)
+        self.assertIsNone(summary.GetProperty(msilib.PID_SECURITY))
+        db.Close()
+        self.addCleanup(unlink, db_path)
+
 
 class Test_make_id(unittest.TestCase):
     #http://msdn.microsoft.com/en-us/library/aa369212(v=vs.85).aspx
diff --git a/Misc/NEWS.d/next/Library/2017-11-24-14-07-55.bpo-12239.Nj3A0x.rst b/Misc/NEWS.d/next/Library/2017-11-24-14-07-55.bpo-12239.Nj3A0x.rst
new file mode 100644 (file)
index 0000000..20d9477
--- /dev/null
@@ -0,0 +1,2 @@
+Make :meth:`msilib.SummaryInformation.GetProperty` return ``None`` when the
+value of property is ``VT_EMPTY``.  Initial patch by Mark Mc Mahon.
index 8cc1fd59dd1926a974101ce5fc6b7d858810b475..000d81f139f3541364043cbce19f9931adb602a6 100644 (file)
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -575,6 +575,8 @@ summary_getproperty(msiobj* si, PyObject *args)
             if (sval != sbuf)
                 free(sval);
             return result;
+        case VT_EMPTY:
+            Py_RETURN_NONE;
     }
     PyErr_Format(PyExc_NotImplementedError, "result of type %d", type);
     return NULL;