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 Fetch raises MSIError rather than return None #73550

Closed
JasonMatthew mannequin opened this issue Jan 24, 2017 · 3 comments
Closed

msilib Fetch raises MSIError rather than return None #73550

JasonMatthew mannequin opened this issue Jan 24, 2017 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@JasonMatthew
Copy link
Mannequin

JasonMatthew mannequin commented Jan 24, 2017

BPO 29364
Nosy @berkerpeksag
Superseder
  • bpo-1102: Add support for _msi.Record.GetString() and _msi.Record.GetInteger()
  • 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-02-01.19:32:23.738>
    created_at = <Date 2017-01-24.18:54:25.739>
    labels = ['type-bug', 'library']
    title = 'msilib Fetch raises MSIError rather than return None'
    updated_at = <Date 2017-02-01.19:34:04.237>
    user = 'https://bugs.python.org/JasonMatthew'

    bugs.python.org fields:

    activity = <Date 2017-02-01.19:34:04.237>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-02-01.19:32:23.738>
    closer = 'Jason Matthew'
    components = ['Library (Lib)']
    creation = <Date 2017-01-24.18:54:25.739>
    creator = 'Jason Matthew'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 29364
    keywords = []
    message_count = 3.0
    messages = ['286204', '286669', '286679']
    nosy_count = 2.0
    nosy_names = ['berker.peksag', 'Jason Matthew']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '1102'
    type = 'behavior'
    url = 'https://bugs.python.org/issue29364'
    versions = ['Python 2.7']

    @JasonMatthew
    Copy link
    Mannequin Author

    JasonMatthew mannequin commented Jan 24, 2017

    Fairly new to MSIs here. Working towards extracting the same information which is available via Orca graphical interfaces.

    I believe I've hit a bug within _msi.View class, namely the inability to safely determine the number of records in my result.

    Examples I've found depicting how to obtain query results lead me to believe _msi.View.Fetch() will return None if no more rows exist. My development using python 2.7.11, Windows 7 enterprise and 2.7.13, Windows Server 2016, has shown Fetch() will raise a msilib.MSIError when no more rows are available. MSIError is commonly used within msilib which means explicit error handling (or leniency in this case) may incorrectly suppress other error scenarios.

    Entering a bug with the hope either a patch addresses this issue or documentation can be updated to reflect proper usage. Example provided below.

        >>> import msilib
        >>> db = msilib.OpenDatabase("msi-1.0.0.8.msi", msilib.MSIDBOPEN_READONLY)
        >>> v = db.OpenView("select * from Property")
        >>> v.Execute(None)
        >>> while 1:
        ...     r = v.Fetch()
        ...     if not r:break
        ...     print r.GetString(1)
        ...
        UpgradeCode
        WixSharp_UI_INSTALLDIR
        WixSharp_InstallDialogs
        WIXUI_INSTALLDIR
        Manufacturer
        ProductCode
        ProductLanguage
        ProductName
        ProductVersion
        SecureCustomProperties
        Traceback (most recent call last):
          File "<stdin>", line 2, in <module>
        _msi.MSIError: unknown error 103

    @JasonMatthew JasonMatthew mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jan 24, 2017
    @berkerpeksag
    Copy link
    Member

    Thanks for the report, Jason. I think this is a duplicate of bpo-1102. The second patch (_msi_fetch.patch.txt) there should fix your problem (if I read MSDN correctly, 103 is ERROR_NO_MORE_ITEMS.)

    I don't have access to a Windows box at the moment so could you please verify my theory so we can close this as a duplicate?

    @JasonMatthew
    Copy link
    Mannequin Author

    JasonMatthew mannequin commented Feb 1, 2017

    Thanks for pointing that one out Berker. I agree, this is a dup.

    @JasonMatthew JasonMatthew mannequin closed this as completed Feb 1, 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
    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