Skip to content

Replace the integer literal assigned to VARIANT.missing with a constant. #821

Description

@junkmd

Assigning 0x80020004 to VARIANT.missing may not be appropriate.

v.vt = VT_ERROR
if sys.version_info >= (3, 0):
v._.VT_I4 = 0x80020004
else:
v._.VT_I4 = 0x80020004L
del v

v.vt = VT_ERROR
v._.VT_I4 = 0x80020004
del v

The line is intended to assign DISP_E_PARAMNOTFOUND to a VARIANT field to create an instance for missing parameters.
0x80020004 is evaluated as an unsigned 32-bit hexadecimal integer in Python, so it is 2147549188, thus it does not match DISP_E_PARAMNOTFOUND(-2147352572).

Since neither -2147352572 nor 2147549188 has caused any errors or behavioral differences in VARIANT, assigning VT_ERROR to the vt field might be the more crucial aspect.
Regardless, this part is highly non-obvious, and this is confusing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions