Explicit conversion from PyLong to Variant
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
Since Python an arbitrary length long it is not easy to determine which VARIANT type is suitable. This patch checks the sign and the size of the long value and converts the long in the following way
x < LLONG_MIN --> VT_R8
LLONG_MIN <= x < LONG_MIN --> VT_I8
LONG_MIN <= x < LONG_MAX --> VT_I4
LONG_MAX < x <= ULONG_MAX --> VT_UI4
ULONG_MAX < x <= LLONG_MAX --> VT_I8
LLONG_MAX < x <= ULLONG_MAX --> VT_UI8
ULLONG_MAX < x --> VT_R8
which adds the conversion to VT_UI8 and is different from the current way:
x < LLONG_MIN --> VT_R8
LLONG_MIN <= x < LONG_MIN --> VT_I8
LONG_MIN <= x < LONG_MAX --> VT_I4
LONG_MAX < x <= ULONG_MAX --> VT_UI4
ULONG_MAX < x <= LLONG_MAX --> VT_I8
LLONG_MAX < x --> VT_R8
Long conversion diff.
4320:cbcbd126551c