Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[msilib] Obscure exception message when trying to open a non-existent MSI database #56591

Closed
RobinJarry mannequin opened this issue Jun 21, 2011 · 9 comments
Closed

[msilib] Obscure exception message when trying to open a non-existent MSI database #56591

RobinJarry mannequin opened this issue Jun 21, 2011 · 9 comments
Labels
3.7 (EOL) end of life OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@RobinJarry
Copy link
Mannequin

RobinJarry mannequin commented Jun 21, 2011

BPO 12382
Nosy @loewis, @pfmoore, @tjguk, @berkerpeksag, @zware, @zooba
PRs
  • bpo-12382: Make OpenDatabase() raise better exception messages #4528
  • [3.6] bpo-12382: Make OpenDatabase() raise better exception messages (GH-4528) #4538
  • Files
  • 12382_msi-open-error-message.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-11-24.10:32:50.118>
    created_at = <Date 2011-06-21.12:12:16.493>
    labels = ['3.7', 'type-bug', 'library', 'OS-windows']
    title = '[msilib] Obscure exception message when trying to open a non-existent MSI database'
    updated_at = <Date 2017-11-24.10:32:50.113>
    user = 'https://bugs.python.org/RobinJarry'

    bugs.python.org fields:

    activity = <Date 2017-11-24.10:32:50.113>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-11-24.10:32:50.118>
    closer = 'berker.peksag'
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2011-06-21.12:12:16.493>
    creator = 'Robin.Jarry'
    dependencies = []
    files = ['35098']
    hgrepos = []
    issue_num = 12382
    keywords = ['patch']
    message_count = 9.0
    messages = ['138781', '138782', '139024', '139049', '139203', '217552', '306880', '306883', '306884']
    nosy_count = 10.0
    nosy_names = ['loewis', 'paul.moore', 'markmcmahon', 'tim.golden', 'markm', 'Robin.Jarry', 'berker.peksag', 'zach.ware', 'steve.dower', 'tiwilliam']
    pr_nums = ['4528', '4538']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue12382'
    versions = ['Python 3.6', 'Python 3.7']

    @RobinJarry
    Copy link
    Mannequin Author

    RobinJarry mannequin commented Jun 21, 2011

    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
    >>>

    @RobinJarry RobinJarry mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 21, 2011
    @RobinJarry
    Copy link
    Mannequin Author

    RobinJarry mannequin commented Jun 21, 2011

    changed the headline of the defect for something more meaningful :)

    @RobinJarry RobinJarry mannequin changed the 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 Jun 21, 2011
    @markm
    Copy link
    Mannequin

    markm mannequin commented Jun 25, 2011

    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 ?

    @RobinJarry
    Copy link
    Mannequin Author

    RobinJarry mannequin commented Jun 25, 2011

    This sounds OK as long as the error message is explicit :)

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jun 26, 2011

    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.

    @tiwilliam
    Copy link
    Mannequin

    tiwilliam mannequin commented Apr 29, 2014

    Found this a simple fix for an annoying and time consuming error. Patched as discussed earlier and decided to leave the filename out.

    @tiwilliam tiwilliam mannequin added OS-windows and removed stdlib Python modules in the Lib dir labels Apr 29, 2014
    @berkerpeksag
    Copy link
    Member

    New changeset 4864a61 by Berker Peksag in branch 'master':
    bpo-12382: Make OpenDatabase() raise better exception messages (GH-4528)
    4864a61

    @berkerpeksag
    Copy link
    Member

    New changeset bfa89b2 by Berker Peksag (Miss Islington (bot)) in branch '3.6':
    bpo-12382: Make OpenDatabase() raise better exception messages (GH-4528)
    bfa89b2

    @berkerpeksag
    Copy link
    Member

    Thank you for your patch, William. I added a test case, a NEWS entry and committed it to 3.6 and master branches.

    @berkerpeksag berkerpeksag added stdlib Python modules in the Lib dir 3.7 (EOL) end of life labels Nov 24, 2017
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant