mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
require a long long data type (closes #27961)
This commit is contained in:
parent
b3b0767861
commit
ed4aa83ff7
32 changed files with 156 additions and 442 deletions
|
@ -113,7 +113,6 @@ int _pysqlite_seterror(sqlite3* db, sqlite3_stmt* st)
|
|||
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),
|
||||
|
@ -124,14 +123,6 @@ _pysqlite_long_from_int64(sqlite_int64 value)
|
|||
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(Py_SAFE_DOWNCAST(value, sqlite_int64, long));
|
||||
}
|
||||
|
||||
|
@ -139,23 +130,13 @@ sqlite_int64
|
|||
_pysqlite_long_as_int64(PyObject * py_val)
|
||||
{
|
||||
int overflow;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
PY_LONG_LONG value = PyLong_AsLongLongAndOverflow(py_val, &overflow);
|
||||
#else
|
||||
long value = PyLong_AsLongAndOverflow(py_val, &overflow);
|
||||
#endif
|
||||
if (value == -1 && PyErr_Occurred())
|
||||
return -1;
|
||||
if (!overflow) {
|
||||
#ifdef HAVE_LONG_LONG
|
||||
# if SIZEOF_LONG_LONG > 8
|
||||
if (-0x8000000000000000LL <= value && value <= 0x7FFFFFFFFFFFFFFFLL)
|
||||
# endif
|
||||
#else
|
||||
# if SIZEOF_LONG > 8
|
||||
if (-0x8000000000000000L <= value && value <= 0x7FFFFFFFFFFFFFFFL)
|
||||
# endif
|
||||
#endif
|
||||
return value;
|
||||
}
|
||||
else if (sizeof(value) < sizeof(sqlite_int64)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue