[New-bugs-announce] [issue21931] Nonsense errors reported by msilib.FCICreate for bad argument

Jeffrey Armstrong report at bugs.python.org
Mon Jul 7 14:53:10 CEST 2014

New submission from Jeffrey Armstrong:

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("test.cab", ["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.

components: Extension Modules
messages: 222458
nosy: Jeffrey.Armstrong
priority: normal
severity: normal
status: open
title: Nonsense errors reported by msilib.FCICreate for bad argument
type: behavior
versions: Python 3.4, Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list