diff options
author | Guido van Rossum <guido@python.org> | 2007-01-14 03:31:43 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-01-14 03:31:43 +0000 |
commit | ddefaf31b366ea84250fc5090837c2b764a04102 (patch) | |
tree | ab3d7b5172f4e6a064165468fc70beb41bdca1d3 /Python/marshal.c | |
parent | 5b787e8bc2dbda5583eee039cb6a6e47c8d8a034 (diff) | |
download | cpython-git-ddefaf31b366ea84250fc5090837c2b764a04102.tar.gz |
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.
Diffstat (limited to 'Python/marshal.c')
-rw-r--r-- | Python/marshal.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/Python/marshal.c b/Python/marshal.c index 1819eacbac..fd1bd72d3b 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -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]; |