mirror of
https://github.com/python/cpython.git
synced 2025-09-09 02:11:51 +00:00
Merged the int/long unification branch, by very crude means (sorry Thomas!).
I banged on the code (beyond what's in that branch) to make fewer tests fail; the only tests that fail now are: test_descr -- can't pickle ints?! test_pickletools -- ??? test_socket -- See python.org/sf/1619659 test_sqlite -- ??? I'll deal with those later.
This commit is contained in:
parent
5b787e8bc2
commit
ddefaf31b3
46 changed files with 798 additions and 404 deletions
|
@ -144,31 +144,34 @@ w_object(PyObject *v, WFILE *p)
|
|||
else if (v == Py_True) {
|
||||
w_byte(TYPE_TRUE, p);
|
||||
}
|
||||
else if (PyInt_Check(v)) {
|
||||
long x = PyInt_AS_LONG((PyIntObject *)v);
|
||||
else if (PyLong_Check(v)) {
|
||||
long x = PyLong_AsLong(v);
|
||||
if ((x == -1) && PyErr_Occurred()) {
|
||||
PyLongObject *ob = (PyLongObject *)v;
|
||||
PyErr_Clear();
|
||||
w_byte(TYPE_LONG, p);
|
||||
n = ob->ob_size;
|
||||
w_long((long)n, p);
|
||||
if (n < 0)
|
||||
n = -n;
|
||||
for (i = 0; i < n; i++)
|
||||
w_short(ob->ob_digit[i], p);
|
||||
}
|
||||
else {
|
||||
#if SIZEOF_LONG > 4
|
||||
long y = Py_ARITHMETIC_RIGHT_SHIFT(long, x, 31);
|
||||
if (y && y != -1) {
|
||||
w_byte(TYPE_INT64, p);
|
||||
w_long64(x, p);
|
||||
}
|
||||
else
|
||||
long y = Py_ARITHMETIC_RIGHT_SHIFT(long, x, 31);
|
||||
if (y && y != -1) {
|
||||
w_byte(TYPE_INT64, p);
|
||||
w_long64(x, p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
w_byte(TYPE_INT, p);
|
||||
w_long(x, p);
|
||||
w_byte(TYPE_INT, p);
|
||||
w_long(x, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PyLong_Check(v)) {
|
||||
PyLongObject *ob = (PyLongObject *)v;
|
||||
w_byte(TYPE_LONG, p);
|
||||
n = ob->ob_size;
|
||||
w_long((long)n, p);
|
||||
if (n < 0)
|
||||
n = -n;
|
||||
for (i = 0; i < n; i++)
|
||||
w_short(ob->ob_digit[i], p);
|
||||
}
|
||||
else if (PyFloat_Check(v)) {
|
||||
if (p->version > 1) {
|
||||
unsigned char buf[8];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue