Issue20486
Created on 2014-02-02 15:37 by gentoo90, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| Add_ability_to_close_MSI_database_.patch | xoviat, 2016-12-27 17:44 | |||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 4141 | merged | berker.peksag, 2017-10-26 20:06 | |
| Messages (11) | |||
|---|---|---|---|
| msg209992 - (view) | Author: gentoo90 (gentoo90) | Date: 2014-02-02 15:37 | |
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
|
|||
| msg235809 - (view) | Author: Mark Lawrence (BreamoreBoy) * | Date: 2015-02-12 11:27 | |
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. |
|||
| msg283638 - (view) | Author: xoviat (xoviat) | Date: 2016-12-19 18:01 | |
This is still present in Python 3.5. There is no way to unlock the MSI file without killing the Python process first. |
|||
| msg283641 - (view) | Author: Steve Dower (steve.dower) * ![]() |
Date: 2016-12-19 18:20 | |
Guessing the msiobj_close function in PC/_msi.c ought to be exposed. Patches welcome. |
|||
| msg283648 - (view) | Author: xoviat (xoviat) | Date: 2016-12-19 19:53 | |
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. |
|||
| msg284089 - (view) | Author: Berker Peksag (berker.peksag) * ![]() |
Date: 2016-12-27 12:27 | |
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. |
|||
| msg284119 - (view) | Author: xoviat (xoviat) | Date: 2016-12-27 17:44 | |
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. |
|||
| msg305022 - (view) | Author: Berker Peksag (berker.peksag) * ![]() |
Date: 2017-10-26 05:01 | |
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? |
|||
| msg305075 - (view) | Author: xoviat (xoviat) | Date: 2017-10-26 17:58 | |
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> > _______________________________________ > |
|||
| msg305748 - (view) | Author: Berker Peksag (berker.peksag) * ![]() |
Date: 2017-11-07 12:58 | |
New changeset a935654f0613640535fbf0ba190f81d02a63d35c by Berker Peksag in branch 'master': bpo-20486: Implement Database.Close() method in msilib (GH-4141) https://github.com/python/cpython/commit/a935654f0613640535fbf0ba190f81d02a63d35c |
|||
| msg305749 - (view) | Author: Berker Peksag (berker.peksag) * ![]() |
Date: 2017-11-07 13:01 | |
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.
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:58 | admin | set | github: 64685 |
| 2017-11-07 13:01:57 | berker.peksag | set | status: open -> closed versions: - Python 2.7, Python 3.6 messages: + msg305749 resolution: fixed |
| 2017-11-07 12:58:55 | berker.peksag | set | messages: + msg305748 |
| 2017-10-26 20:06:59 | berker.peksag | set | pull_requests: + pull_request4105 |
| 2017-10-26 17:58:04 | xoviat | set | messages: + msg305075 |
| 2017-10-26 05:01:52 | berker.peksag | set | messages:
+ msg305022 versions: - Python 3.5 |
| 2016-12-27 17:45:02 | xoviat | set | files: - Add_ability_to_close_MSI_database_.patch |
| 2016-12-27 17:44:50 | xoviat | set | files:
+ Add_ability_to_close_MSI_database_.patch messages: + msg284119 |
| 2016-12-27 12:27:14 | berker.peksag | set | nosy:
+ berker.peksag messages:
+ msg284089 |
| 2016-12-19 22:26:46 | xoviat | set | files:
+ Add_ability_to_close_MSI_database_.patch keywords: + patch |
| 2016-12-19 22:26:21 | xoviat | set | files: - _msi.c |
| 2016-12-19 22:10:56 | BreamoreBoy | set | nosy:
- BreamoreBoy |
| 2016-12-19 19:53:09 | xoviat | set | files:
+ _msi.c messages: + msg283648 |
| 2016-12-19 18:20:55 | steve.dower | set | priority: normal -> low versions: + Python 3.6, Python 3.7 messages: + msg283641 keywords:
+ easy |
| 2016-12-19 18:01:09 | xoviat | set | nosy:
+ xoviat messages:
+ msg283638 |
| 2015-02-12 11:27:04 | BreamoreBoy | set | nosy:
+ tim.golden, BreamoreBoy, zach.ware, steve.dower messages: + msg235809 |
| 2014-02-02 23:15:10 | ned.deily | set | nosy:
+ loewis |
| 2014-02-02 15:37:29 | gentoo90 | create | |
