Message 189418 - Python tracker (original) (raw)

Oh, the sqlite3 module has an interesting function:

PyObject * _pysqlite_long_from_int64(sqlite_int64 value) { #ifdef HAVE_LONG_LONG

if SIZEOF_LONG_LONG < 8

if (value > PY_LLONG_MAX || value < PY_LLONG_MIN) {
    return _PyLong_FromByteArray(&value, sizeof(value),
                                 IS_LITTLE_ENDIAN, 1 /* signed */);
}

endif

if SIZEOF_LONG < SIZEOF_LONG_LONG

if (value > LONG_MAX || value < LONG_MIN)
    return PyLong_FromLongLong(value);

endif

#else

if SIZEOF_LONG < 8

if (value > LONG_MAX || value < LONG_MIN) {
    return _PyLong_FromByteArray(&value, sizeof(value),
                                 IS_LITTLE_ENDIAN, 1 /* signed */);
}

endif

#endif return PyLong_FromLong(value); }

If PyLong_FromIntMax_t() is implemented, this function may be simply removed (and replaced with PyLong_FromIntMax_t).