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.

Title: Nonsense errors reported by msilib.FCICreate for bad argument
Type: behavior Stage: resolved
Components: Extension Modules, Windows Versions: Python 3.4, Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Jeffrey.Armstrong, ezio.melotti, loewis, python-dev, r.david.murray, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2014-07-07 12:53 by Jeffrey.Armstrong, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
_msi.3.4.0.patch Jeffrey.Armstrong, 2014-07-12 20:52 patch for Python 3.4.0
Messages (12)
msg222458 - (view) Author: Jeffrey Armstrong (Jeffrey.Armstrong) * Date: 2014-07-07 12:53
The function fcicreate in PC/_msi.c can return nonsense if the list of files passed to msilib.FCICreate does not contains tuples as expected.  To replicate,

import msilib
msilib.FCICreate("", ["entry.txt"])

The above code will return a ValueError of the format:

ValueError: FCI error 11260524

The error code is meaningless.  If one were to examine the code, you can see in PC/_msi.c:246 (in "current"):

        if (!PyArg_ParseTuple(item, "ss", &filename, &cabname))
            goto err;

If we look at the error handler at PC/_msi.c:262, it assumes that one of the Windows MSI API calls had failed, and will print the contents of the ERF error structure:

    PyErr_Format(PyExc_ValueError, "FCI error %d", erf.erfOper); /* XXX better error type */

In the case where the list does not contain tuples, the value of erf.erfOper was never initialized or set because the error being raised is not due to the Windows MSI API.  The error is highly misleading as it is simply an argument error.
msg222853 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2014-07-12 16:47
Do you want to propose a patch?
msg222883 - (view) Author: Jeffrey Armstrong (Jeffrey.Armstrong) * Date: 2014-07-12 20:52
Attached a patch.  The dangers of using goto...
msg223206 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-07-16 14:16
mslib doesn't have many tests, but it looks like it would be easy enough to add one for this?
msg226597 - (view) Author: Jeffrey Armstrong (Jeffrey.Armstrong) * Date: 2014-09-08 18:58
Is this patch going to be accepted?  It fixes actual incorrect code in msilib, and it seems to have stagnated
msg230583 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2014-11-04 07:19
I haven't had any time to work on Python in the last year, so it may take some more time for me to look into this.
msg230616 - (view) Author: Jeffrey Armstrong (Jeffrey.Armstrong) * Date: 2014-11-04 11:26
There's not much to look into.  If the Python function encounters an argument error, it returns an uninitialized integer as an "error code."  This patch fixes incorrect C code, nothing more.
msg230656 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2014-11-04 21:08
Right, the entire patch might be processed in 30 minutes. I won't have these 30 minutes any time soon.
msg243405 - (view) Author: Jeffrey Armstrong (Jeffrey.Armstrong) * Date: 2015-05-17 15:23
I thought, while I'm here reporting another bug, I'd bump this once more.

There is a patch here, and it corrects clearly broken code.  Should I mark this as "won't fix?"
msg243415 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-05-17 16:53
I'll try to have a look at this later today, but unfortunately can't
guarantee anything (I don't know C, MSI, or _msi very well).
msg243457 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-05-18 05:49
New changeset 41281737d71a by Zachary Ware in branch '3.4':
Issue #21931: Fix error handling in msilib.FCICreate().

New changeset cb0d1d86215e by Zachary Ware in branch 'default':
Closes #21931: Merge with 3.4
msg243459 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-05-18 05:57
It's a simple enough fix, so I went ahead and committed it.  Thanks for the patch!

I've created issue24224 to track the addition of tests to test_msilib (for more than just this issue).
Date User Action Args
2022-04-11 14:58:05adminsetgithub: 66130
2015-05-18 05:57:32zach.waresetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2015-05-18 05:57:13zach.waresetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg243459

stage: resolved -> patch review
2015-05-18 05:49:22python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg243457

resolution: fixed
stage: patch review -> resolved
2015-05-17 16:53:07zach.waresetmessages: + msg243415
2015-05-17 15:23:44Jeffrey.Armstrongsetmessages: + msg243405
2014-11-04 21:08:42loewissetmessages: + msg230656
2014-11-04 11:26:50Jeffrey.Armstrongsetnosy: loewis, tim.golden, ezio.melotti, r.david.murray, zach.ware, steve.dower, Jeffrey.Armstrong
messages: + msg230616
2014-11-04 07:19:06loewissetmessages: + msg230583
2014-11-01 22:19:26ezio.melottisetstage: needs patch -> patch review
2014-09-08 18:58:53Jeffrey.Armstrongsetmessages: + msg226597
2014-07-16 14:16:56r.david.murraysetnosy: + r.david.murray
messages: + msg223206
2014-07-12 20:52:57Jeffrey.Armstrongsetfiles: + _msi.3.4.0.patch
keywords: + patch
messages: + msg222883
2014-07-12 16:47:54ezio.melottisetnosy: + tim.golden, ezio.melotti, loewis, zach.ware, steve.dower
messages: + msg222853

components: + Windows
stage: needs patch
2014-07-07 12:53:10Jeffrey.Armstrongcreate