This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [msilib] Obscure exception message when trying to open a non-existent MSI database
Type: behavior Stage: resolved
Components: Library (Lib), Windows Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Robin.Jarry, berker.peksag, loewis, markm, markmcmahon, paul.moore, steve.dower, tim.golden, tiwilliam, zach.ware
Priority: normal Keywords: patch

Created on 2011-06-21 12:12 by Robin.Jarry, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
12382_msi-open-error-message.patch tiwilliam, 2014-04-29 21:09 review
Pull Requests
URL Status Linked Edit
PR 4528 merged berker.peksag, 2017-11-23 18:53
PR 4538 merged python-dev, 2017-11-24 09:55
Messages (9)
msg138781 - (view) Author: Robin Jarry (Robin.Jarry) Date: 2011-06-21 12:12
When trying to open a non existing MSI database, an obscure "unknown error 6e" is raised.

Could it be possible to get a more explicit message such as "File not found" or whatever ? 

Thanks :)

Here is a example:

--------------------------------

D:\>ll
total 0
drwxr-xr-x    4 tcinteg  Administ        0 Nov 30  2010 RECYCLER
drwxr-xr-x    0 tcinteg  Administ        0 Jul  6  2009 System Volume Information
drwxr-xr-x    4 tcinteg  Administ        0 Apr 29 16:03 TC
drwxr-xr-x    3 tcinteg  Administ        0 Apr 29 15:43 stgloc

D:\>python
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import msilib
>>> db = msilib.OpenDatabase("I_Do_Not_Exist.msi", msilib.MSIDBOPEN_READONLY)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
_msi.MSIError: unknown error 6e
>>>
msg138782 - (view) Author: Robin Jarry (Robin.Jarry) Date: 2011-06-21 12:18
changed the headline of the defect for something more meaningful :)
msg139024 - (view) Author: Mark Mc Mahon (markm) * Date: 2011-06-25 08:10
The following two error conditions that can be returned by MsiOpenDatabase do not have specific handling:

ERROR_CREATE_FAILED (1631)
    The database could not be created.

ERROR_OPEN_FAILED (110)
    The database could not be opened as requested.

(the messages are those copied from MSDN).

Should extra cases for these go into the case statement in msierror? or should they be handled directly in OpenDatabase.

Does the error text above sound OK - should we add ": '%s'" % msi_file ?
msg139049 - (view) Author: Robin Jarry (Robin.Jarry) Date: 2011-06-25 12:14
This sounds OK as long as the error message is explicit :)
msg139203 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2011-06-26 19:49
I'd add them to msierror, with no inclusion of the file name.

If you want the file name in the exception, you should uniformly apply this to all errors in OpenDatabase, and then subclass MSIError to, say, MSIOpenError which includes a .filename attribute.
msg217552 - (view) Author: William Tisäter (tiwilliam) * Date: 2014-04-29 21:09
Found this a simple fix for an annoying and time consuming error. Patched as discussed earlier and decided to leave the filename out.
msg306880 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-11-24 09:54
New changeset 4864a619dc1cc9092780ccf5a6327e8abf66133d by Berker Peksag in branch 'master':
bpo-12382: Make OpenDatabase() raise better exception messages (GH-4528)
https://github.com/python/cpython/commit/4864a619dc1cc9092780ccf5a6327e8abf66133d
msg306883 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-11-24 10:31
New changeset bfa89b21e119bac7fed4a5decc26f1fff8ec359e by Berker Peksag (Miss Islington (bot)) in branch '3.6':
bpo-12382: Make OpenDatabase() raise better exception messages (GH-4528)
https://github.com/python/cpython/commit/bfa89b21e119bac7fed4a5decc26f1fff8ec359e
msg306884 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-11-24 10:32
Thank you for your patch, William. I added a test case, a NEWS entry and committed it to 3.6 and master branches.
History
Date User Action Args
2022-04-11 14:57:18adminsetgithub: 56591
2017-11-24 10:32:50berker.peksagsetstatus: open -> closed

components: + Library (Lib)
versions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.5
nosy: + paul.moore, zach.ware, steve.dower

messages: + msg306884
resolution: fixed
stage: patch review -> resolved
2017-11-24 10:31:23berker.peksagsetmessages: + msg306883
2017-11-24 09:55:10python-devsetpull_requests: + pull_request4472
2017-11-24 09:54:04berker.peksagsetmessages: + msg306880
2017-11-23 18:53:20berker.peksagsetstage: patch review
pull_requests: + pull_request4464
2017-11-19 07:07:09berker.peksagsetnosy: + berker.peksag
2014-04-29 21:09:12tiwilliamsetfiles: + 12382_msi-open-error-message.patch

components: + Windows, - Library (Lib)
versions: + Python 3.5
keywords: + patch
nosy: + tiwilliam

messages: + msg217552
2011-06-26 19:49:52loewissetmessages: + msg139203
2011-06-25 12:14:20Robin.Jarrysetmessages: + msg139049
2011-06-25 08:10:01markmsetnosy: + markm
messages: + msg139024
2011-06-21 12:23:07tim.goldensetnosy: + markmcmahon, tim.golden
2011-06-21 12:18:05Robin.Jarrysetmessages: + msg138782
title: [msilib] Ambiguous exception message when trying to open a non existing MSI database -> [msilib] Obscure exception message when trying to open a non-existent MSI database
2011-06-21 12:12:16Robin.Jarrycreate