mirror of
https://github.com/python/cpython.git
synced 2025-08-29 21:25:01 +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
|
@ -2124,7 +2124,7 @@ _PyBuiltin_Init(void)
|
|||
SETBUILTIN("float", &PyFloat_Type);
|
||||
SETBUILTIN("frozenset", &PyFrozenSet_Type);
|
||||
SETBUILTIN("property", &PyProperty_Type);
|
||||
SETBUILTIN("int", &PyInt_Type);
|
||||
SETBUILTIN("int", &PyLong_Type);
|
||||
SETBUILTIN("list", &PyList_Type);
|
||||
SETBUILTIN("long", &PyLong_Type);
|
||||
SETBUILTIN("object", &PyBaseObject_Type);
|
||||
|
|
|
@ -3900,7 +3900,7 @@ _PyEval_SliceIndex(PyObject *v, Py_ssize_t *pi)
|
|||
{
|
||||
if (v != NULL) {
|
||||
Py_ssize_t x;
|
||||
if (PyInt_Check(v)) {
|
||||
if (PyInt_CheckExact(v)) {
|
||||
/* XXX(nnorwitz): I think PyInt_AS_LONG is correct,
|
||||
however, it looks like it should be AsSsize_t.
|
||||
There should be a comment here explaining why.
|
||||
|
|
|
@ -720,9 +720,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
case 'K': { /* long long sized bitfield */
|
||||
unsigned PY_LONG_LONG *p = va_arg(*p_va, unsigned PY_LONG_LONG *);
|
||||
unsigned PY_LONG_LONG ival;
|
||||
if (PyInt_Check(arg))
|
||||
ival = PyInt_AsUnsignedLongMask(arg);
|
||||
else if (PyLong_Check(arg))
|
||||
if (PyLong_Check(arg))
|
||||
ival = PyLong_AsUnsignedLongLongMask(arg);
|
||||
else
|
||||
return converterr("integer<K>", arg, msgbuf, bufsize);
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -60,6 +60,8 @@ static void call_sys_exitfunc(void);
|
|||
static void call_ll_exitfuncs(void);
|
||||
extern void _PyUnicode_Init(void);
|
||||
extern void _PyUnicode_Fini(void);
|
||||
extern int _PyLong_Init(void);
|
||||
extern void PyLong_Fini(void);
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *);
|
||||
|
@ -181,8 +183,8 @@ Py_InitializeEx(int install_sigs)
|
|||
if (!_PyFrame_Init())
|
||||
Py_FatalError("Py_Initialize: can't init frames");
|
||||
|
||||
if (!_PyInt_Init())
|
||||
Py_FatalError("Py_Initialize: can't init ints");
|
||||
if (!_PyLong_Init())
|
||||
Py_FatalError("Py_Initialize: can't init longs");
|
||||
|
||||
_PyFloat_Init();
|
||||
|
||||
|
@ -453,7 +455,7 @@ Py_Finalize(void)
|
|||
PyList_Fini();
|
||||
PySet_Fini();
|
||||
PyString_Fini();
|
||||
PyInt_Fini();
|
||||
PyLong_Fini();
|
||||
PyFloat_Fini();
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
|
|
|
@ -250,7 +250,7 @@ PyTraceBack_Print(PyObject *v, PyObject *f)
|
|||
return -1;
|
||||
}
|
||||
limitv = PySys_GetObject("tracebacklimit");
|
||||
if (limitv && PyInt_Check(limitv)) {
|
||||
if (limitv && PyInt_CheckExact(limitv)) {
|
||||
limit = PyInt_AsLong(limitv);
|
||||
if (limit <= 0)
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue