homepage

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: dir on return value of msilib.OpenDatabase() crashes python
Type: crash Stage: resolved
Components: Windows Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Special method lookup fails on uninitialized types
View: 26906
Assigned To: Nosy List: amaury.forgeotdarc, loewis, markm, serhiy.storchaka, steve.dower, terry.reedy, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2011年03月28日 15:13 by markm, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
msi_opendatabase.patch amaury.forgeotdarc, 2011年03月28日 22:28 review
msi_opendatabase_2.patch markm, 2011年03月29日 22:10 Patch View, Record & Summary Types also review
support_dir_for_msi_objs.patch markm, 2011年05月21日 01:01 review
Messages (7)
msg132402 - (view) Author: Mark Mc Mahon (markm) * Date: 2011年03月28日 15:13
Running the following code:
>>> import msilib
>>> db = msilib.OpenDatabase('c:/windows/installer/1c7a1.msi', 1)
>>> db
<_msi.Database object at 0x01E230A0>
>>> dir(db)
(Python crashes - tested on current Trunk and Python 2.7.1).
I tried tracking it through the C code - and it seems to be a problem when dir is checking for __dir__ (the pointer in PyObject_GetAttrString seems to be incorrect).
msg132436 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2011年03月28日 22:28
A call to PyType_Ready() fixes the issue, see attached patch.
I added a test that opens a random file in c:\windows\installer, I don't know if this is correct for all Windows version.
msg132539 - (view) Author: Mark Mc Mahon (markm) * Date: 2011年03月29日 22:10
That fixed it - but it seems we need that for the other Types defined in the module.
Regarding testing - would it be a good idea to add an MSI to the test suite - or better to create one during testing (using msilib) and then use that in the tests?
msg136201 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2011年05月18日 02:40
If we can generate a testable MSI file that would be the best. Including a very small pre-generated MSI for the purposes of the test would be acceptable.
As-is, the tests don't pass because my machine has C:\Windows\installer1032円f.msi that gets used for the test, which apparently doesn't work with this functionality, and other machines may end up with the same situation. I'm not sure if that's a bug in the code or in whatever MSI that is, though. The OpenDatabase call returns "unknown error 6e" for both new tests.
msg136418 - (view) Author: Mark Mc Mahon (markm) * Date: 2011年05月21日 01:01
I wasn't so happy trawling through \windows\installer either :) 
Creating an MSI to test is very simple, and actually quicker than I had originally thought. The latest patch (support_dir_for_msi_objs.patch) creates the one and just uses that. Optionally I could create a new one each time setUp()/tearDown(). But was thinking - let's do that if/when we need to :)
The latest patch updates the tests - but no change to the C code.
(I doubt the error you received is a bug in msilib, and I couldn't repro even by opening EVERY MSI in my windows\installer dir. It could be a rights/security issue? The previous test was not opening as READ ONLY - even though it never saved the db, so that may be another reason?)
msg223144 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014年07月15日 20:04
The attached patch is short and sweet and looks okay to my untrained eye. I believe it should apply cleanly as there've been very few changes to _msi.c. Can we have a formal patch review please.
msg277920 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016年10月03日 02:03
This is a generic issue as there are multiple unready types that can raise (or in this case crash) with code that should work. #26906 gives other examples and discussion of possible generic solutions that would make this issue obsolete.
History
Date User Action Args
2022年04月11日 14:57:15adminsetgithub: 55911
2021年10月18日 21:23:54iritkatrielsetstatus: open -> closed
superseder: Special method lookup fails on uninitialized types
resolution: duplicate
stage: patch review -> resolved
2016年10月03日 18:00:19BreamoreBoysetnosy: - BreamoreBoy
2016年10月03日 02:03:26terry.reedysetnosy: + terry.reedy, serhiy.storchaka

messages: + msg277920
versions: + Python 3.5, Python 3.6, Python 3.7, - Python 3.2
2014年07月15日 20:10:26brian.curtinsetnosy: - brian.curtin
2014年07月15日 20:04:14BreamoreBoysetnosy: + BreamoreBoy, tim.golden, zach.ware, steve.dower
messages: + msg223144
2011年05月21日 01:01:56markmsetfiles: + support_dir_for_msi_objs.patch

messages: + msg136418
2011年05月18日 02:40:02brian.curtinsetnosy: + brian.curtin
messages: + msg136201
2011年03月29日 22:10:18markmsetfiles: + msi_opendatabase_2.patch

messages: + msg132539
2011年03月28日 22:28:36amaury.forgeotdarcsetfiles: + msi_opendatabase.patch

nosy: + amaury.forgeotdarc
messages: + msg132436

keywords: + patch
stage: patch review
2011年03月28日 18:47:35eric.araujosetnosy: + loewis
2011年03月28日 15:13:42markmcreate

AltStyle によって変換されたページ (->オリジナル) /