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: can't close opened database #64685

Closed
gentoo90 mannequin opened this issue Feb 2, 2014 · 11 comments
Closed

msilib: can't close opened database #64685

gentoo90 mannequin opened this issue Feb 2, 2014 · 11 comments
Labels
3.7 (EOL) end of life easy OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@gentoo90
Copy link
Mannequin

gentoo90 mannequin commented Feb 2, 2014

BPO 20486
Nosy @loewis, @tjguk, @berkerpeksag, @zware, @zooba, @xoviat
PRs
  • bpo-20486: Implement Database.Close() method in msilib #4141
  • Files
  • Add_ability_to_close_MSI_database_.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-07.13:01:57.607>
    created_at = <Date 2014-02-02.15:37:29.664>
    labels = ['3.7', 'easy', 'type-bug', 'library', 'OS-windows']
    title = "msilib: can't close opened database"
    updated_at = <Date 2017-11-07.13:01:57.605>
    user = 'https://bugs.python.org/gentoo90'

    bugs.python.org fields:

    activity = <Date 2017-11-07.13:01:57.605>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-11-07.13:01:57.607>
    closer = 'berker.peksag'
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2014-02-02.15:37:29.664>
    creator = 'gentoo90'
    dependencies = []
    files = ['46056']
    hgrepos = []
    issue_num = 20486
    keywords = ['patch', 'easy']
    message_count = 11.0
    messages = ['209992', '235809', '283638', '283641', '283648', '284089', '284119', '305022', '305075', '305748', '305749']
    nosy_count = 7.0
    nosy_names = ['loewis', 'tim.golden', 'berker.peksag', 'zach.ware', 'steve.dower', 'gentoo90', 'xoviat']
    pr_nums = ['4141']
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue20486'
    versions = ['Python 3.7']

    @gentoo90
    Copy link
    Mannequin Author

    gentoo90 mannequin commented Feb 2, 2014

    In Python 2.7.6 can't find any way to close MSI database after finish working with it.
    As a result database is locked and can't be opened by any other application until Python process is finished.

        import msilib
        db = msilib.OpenDatabase('test.msi', msilib.MSIDBOPEN_TRANSACT)
        view = db.OpenView("SELECT File, Component_, FileName FROM File")
        view.Execute(None)
        r1 = view.Fetch()
        r1.SetString(3,"test.txt")
        view.Modify(msilib.MSIMODIFY_UPDATE, r1)
        view.Close()
        db.Commit()
        del db
        db2 = msilib.OpenDatabase('test.msi', msilib.MSIDBOPEN_TRANSACT)
    MSIError: 1: 2203 2: test.msi 3: -2147287008
    

    @gentoo90 gentoo90 mannequin added stdlib Python modules in the Lib dir OS-windows type-bug An unexpected behavior, bug, or error labels Feb 2, 2014
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Feb 12, 2015

    Sorry folks I can't try this myself as I'm not running 2.7 and I don't know how to create the test.msi file.

    @xoviat
    Copy link
    Mannequin

    xoviat mannequin commented Dec 19, 2016

    This is still present in Python 3.5. There is no way to unlock the MSI file without killing the Python process first.

    @zooba
    Copy link
    Member

    zooba commented Dec 19, 2016

    Guessing the msiobj_close function in PC/_msi.c ought to be exposed.

    Patches welcome.

    @zooba zooba added easy 3.7 (EOL) end of life labels Dec 19, 2016
    @xoviat
    Copy link
    Mannequin

    xoviat mannequin commented Dec 19, 2016

    I will prefix this by saying that I have not contributed to the Python source before and this patch is probably wrong, but here is my attempt at a fix.

    @berkerpeksag
    Copy link
    Member

    Thanks for the patch, 12345. Steve knows better, but I think the method should be named "Close" instead of "close" like _msi.View's Close method.

    Also, I couldn't apply your patch:

    $ hg imp http://bugs.python.org/file45971/Add_ability_to_close_MSI_database_.patch
    applying http://bugs.python.org/file45971/Add_ability_to_close_MSI_database_.patch
    unable to find '_msi.c' for patching
    patching file _msi.c
    2 out of 2 hunks FAILED -- saving rejects to file _msi.c.rej
    abort: patch failed to apply

    You may want to read https://docs.python.org/devguide/patch.html for details about creating a patch.

    @xoviat
    Copy link
    Mannequin

    xoviat mannequin commented Dec 27, 2016

    The method is now capitalized. Unfortunately, none of the methods are compliant with PEP formatting, but it's far too late to do anything about that.

    @berkerpeksag
    Copy link
    Member

    xoviat, would you like to send your patch as a pull request on GitHub? It would be nice to add a simple test that the new Close() works correctly. I can do that if you don't have time, thank you!

    Steve, can we apply this to bugfix branches?

    @xoviat
    Copy link
    Mannequin

    xoviat mannequin commented Oct 26, 2017

    Unfortunately, this issue has taken on a much lower importance for me, and
    as such, I won't be able to address it. Sorry about that.

    2017-10-26 0:01 GMT-05:00 Berker Peksag <report@bugs.python.org>:

    Berker Peksag <berker.peksag@gmail.com> added the comment:

    xoviat, would you like to send your patch as a pull request on GitHub? It
    would be nice to add a simple test that the new Close() works correctly. I
    can do that if you don't have time, thank you!

    Steve, can we apply this to bugfix branches?

    ----------
    versions: -Python 3.5


    Python tracker <report@bugs.python.org>
    <https://bugs.python.org/issue20486\>


    @berkerpeksag
    Copy link
    Member

    New changeset a935654 by Berker Peksag in branch 'master':
    bpo-20486: Implement Database.Close() method in msilib (GH-4141)
    a935654

    @berkerpeksag
    Copy link
    Member

    Thank you, all. The OP's snippet should work now:

    >>> import msilib as m
    >>> db = m.OpenDatabase('py33.msi', m.MSIDBOPEN_TRANSACT)
    >>> db.Commit()
    >>> db2 = m.OpenDatabase('py33.msi', m.MSIDBOPEN_TRANSACT)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    _msi.MSIError: 1: 2203 2: py33.msi 3: -2147287008
    >>> db.Close()
    >>> db2 = m.OpenDatabase('py33.msi', m.MSIDBOPEN_TRANSACT)

    I didn't backport this to bugfix branches since we added a new public function to the API.

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

    2 participants