[Python-checkins] [3.6] bpo-12239: Make GetProperty() return None for VT_EMPTY (GH-4539)

Berker Peksag webhook-mailer at python.org
Fri Nov 24 11:04:42 EST 2017


https://github.com/python/cpython/commit/412f00b839eae2bc07ca08a8e615c3d7dc870646
commit: 412f00b839eae2bc07ca08a8e615c3d7dc870646
branch: 3.6
author: Berker Peksag <berker.peksag at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017-11-24T19:04:40+03:00
summary:

[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 19fb134185ce155bc53f517116fca73093ba55e9)

files:
A Misc/NEWS.d/next/Library/2017-11-24-14-07-55.bpo-12239.Nj3A0x.rst
M Lib/test/test_msilib.py
M PC/_msi.c

diff --git a/Lib/test/test_msilib.py b/Lib/test/test_msilib.py
index eb2c76e69da..fec435e05b7 100644
--- a/Lib/test/test_msilib.py
+++ b/Lib/test/test_msilib.py
@@ -52,6 +52,13 @@ def test_database_create_failed(self):
             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))
+        del db
+        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
index 00000000000..20d94779e44
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2017-11-24-14-07-55.bpo-12239.Nj3A0x.rst
@@ -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.
diff --git a/PC/_msi.c b/PC/_msi.c
index 00755d6375e..a7c8fa3d092 100644
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -578,6 +578,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;



More information about the Python-checkins mailing list