diff -r 30a026a25167 Lib/test/test_msilib.py --- a/Lib/test/test_msilib.py Mon Mar 28 19:27:09 2011 +0300 +++ b/Lib/test/test_msilib.py Tue Mar 29 00:27:10 2011 +0200 @@ -1,6 +1,6 @@ """ Test suite for the code in msilib """ import unittest -import os +import os, glob from test.support import run_unittest, import_module msilib = import_module('msilib') @@ -38,6 +38,16 @@ self.assertEqual ( msilib.make_id(".s\x82o?*+rt"), "_.s_o___rt") +class TestDatabase(unittest.TestCase): + def test_open_database(self): + msifiles = glob.glob(os.path.join(os.environ['SystemRoot'], + 'installer', '*.msi')) + if not msifiles: + self.skipTest("Could not find a .msi file to open") + msifile = msifiles[0] + + db = msilib.OpenDatabase(msifile, 1) + self.assertIn('OpenView', dir(db)) def test_main(): run_unittest(__name__) diff -r 30a026a25167 PC/_msi.c --- a/PC/_msi.c Mon Mar 28 19:27:09 2011 +0300 +++ b/PC/_msi.c Tue Mar 29 00:27:10 2011 +0200 @@ -953,7 +953,7 @@ if (!PyArg_ParseTuple(args, "si:MSIOpenDatabase", &path, &persist)) return NULL; - status = MsiOpenDatabase(path, (LPCSTR)persist, &h); + status = MsiOpenDatabase(path, (LPCSTR)persist, &h); if (status != ERROR_SUCCESS) return msierror(status); @@ -1061,6 +1061,9 @@ PyModule_AddIntConstant(m, "PID_APPNAME", PID_APPNAME); PyModule_AddIntConstant(m, "PID_SECURITY", PID_SECURITY); + if (PyType_Ready(&msidb_Type) < 0) + return NULL; + MSIError = PyErr_NewException ("_msi.MSIError", NULL, NULL); if (!MSIError) return NULL;