Skip to content

Commit 412f00b

Browse files
authored
[3.6] 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. (cherry picked from commit 19fb134)
1 parent bfa89b2 commit 412f00b

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
@@ -52,6 +52,13 @@ def test_database_create_failed(self):
5252
msilib.OpenDatabase(db_path, msilib.MSIDBOPEN_CREATE)
5353
self.assertEqual(str(cm.exception), 'create failed')
5454

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

5663
class Test_make_id(unittest.TestCase):
5764
#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
@@ -578,6 +578,8 @@ summary_getproperty(msiobj* si, PyObject *args)
578578
if (sval != sbuf)
579579
free(sval);
580580
return result;
581+
case VT_EMPTY:
582+
Py_RETURN_NONE;
581583
}
582584
PyErr_Format(PyExc_NotImplementedError, "result of type %d", type);
583585
return NULL;

0 commit comments

Comments
 (0)