Skip to content

Commit 19fb134

Browse files
authored
bpo-12239: Make GetProperty() return None for VT_EMPTY (GH-4539)
The previous behavior was to raise an exception NotImplementedError: result of type 0 when the value of the property is VT_EMPTY.
1 parent 9e87e77 commit 19fb134

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

‎Lib/test/test_msilib.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ def test_database_create_failed(self):
5353
msilib.OpenDatabase(db_path, msilib.MSIDBOPEN_CREATE)
5454
self.assertEqual(str(cm.exception), 'create failed')
5555

56+
def test_get_property_vt_empty(self):
57+
db, db_path = init_database()
58+
summary = db.GetSummaryInformation(0)
59+
self.assertIsNone(summary.GetProperty(msilib.PID_SECURITY))
60+
db.Close()
61+
self.addCleanup(unlink, db_path)
62+
5663

5764
class Test_make_id(unittest.TestCase):
5865
#http://msdn.microsoft.com/en-us/library/aa369212(v=vs.85).aspx
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make :meth:`msilib.SummaryInformation.GetProperty` return ``None`` when the
2+
value of property is ``VT_EMPTY``. Initial patch by Mark Mc Mahon.

‎PC/_msi.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,8 @@ summary_getproperty(msiobj* si, PyObject *args)
575575
if (sval != sbuf)
576576
free(sval);
577577
return result;
578+
case VT_EMPTY:
579+
Py_RETURN_NONE;
578580
}
579581
PyErr_Format(PyExc_NotImplementedError, "result of type %d", type);
580582
return NULL;

0 commit comments

Comments
 (0)