Author: martin.v.loewis
Date: Tue Aug 22 23:41:27 2006
New Revision: 51492
Modified:
python/branches/int_unification/Include/boolobject.h
python/branches/int_unification/Include/intobject.h
python/branches/int_unification/Include/longobject.h
python/branches/int_unification/Modules/_sre.c
python/branches/int_unification/Objects/abstract.c
python/branches/int_unification/Objects/boolobject.c
python/branches/int_unification/Objects/exceptions.c
python/branches/int_unification/Objects/intobject.c
python/branches/int_unification/Objects/listobject.c
python/branches/int_unification/Objects/longobject.c
python/branches/int_unification/Python/bltinmodule.c
python/branches/int_unification/Python/marshal.c
python/branches/int_unification/Python/pythonrun.c
Log:
Drop the int type.
Modified: python/branches/int_unification/Include/boolobject.h
==============================================================================
--- python/branches/int_unification/Include/boolobject.h (original)
+++ python/branches/int_unification/Include/boolobject.h Tue Aug 22 23:41:27 2006
@@ -7,7 +7,10 @@
#endif
-typedef PyIntObject PyBoolObject;
+typedef struct {
+ PyObject_HEAD
+ long ob_ival;
+} PyBoolObject;
PyAPI_DATA(PyTypeObject) PyBool_Type;
@@ -17,10 +20,10 @@
Don't forget to apply Py_INCREF() when returning either!!! */
/* Don't use these directly */
-PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct;
+PyAPI_DATA(PyBoolObject) _Py_FalseStruct, _Py_TrueStruct;
/* Use these macros */
-#define Py_False ((PyObject *) &_Py_ZeroStruct)
+#define Py_False ((PyObject *) &_Py_FalseStruct)
#define Py_True ((PyObject *) &_Py_TrueStruct)
/* Macros for returning Py_True or Py_False, respectively */
Modified: python/branches/int_unification/Include/intobject.h
==============================================================================
--- python/branches/int_unification/Include/intobject.h (original)
+++ python/branches/int_unification/Include/intobject.h Tue Aug 22 23:41:27 2006
@@ -20,34 +20,31 @@
extern "C" {
#endif
+/*
typedef struct {
PyObject_HEAD
long ob_ival;
} PyIntObject;
PyAPI_DATA(PyTypeObject) PyInt_Type;
+*/
-#define PyInt_Check(op) PyObject_TypeCheck(op, &PyInt_Type)
-#define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type)
+#define PyInt_Check(op) PyLong_Check(op)
+#define PyInt_CheckExact(op) (PyLong_CheckExact(op) && _PyLong_FitsInLong(op))
-PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int);
-#ifdef Py_USING_UNICODE
-PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
-#endif
-PyAPI_FUNC(PyObject *) PyInt_FromLong(long);
-PyAPI_FUNC(PyObject *) PyInt_FromSize_t(size_t);
-PyAPI_FUNC(PyObject *) PyInt_FromSsize_t(Py_ssize_t);
-PyAPI_FUNC(long) PyInt_AsLong(PyObject *);
-PyAPI_FUNC(Py_ssize_t) PyInt_AsSsize_t(PyObject *);
-PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *);
-#ifdef HAVE_LONG_LONG
-PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
-#endif
+#define PyInt_FromString PyLong_FromString
+#define PyInt_FromUnicode PyLong_FromUnicode
+#define PyInt_FromLong PyLong_FromLong
+#define PyInt_FromSize_t PyLong_FromSize_t
+#define PyInt_FromSsize_t PyLong_FromSsize_t
+#define PyInt_AsLong PyLong_AsLong
+#define PyInt_AsSsize_t PyLong_AsSsize_t
+#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
+#define PyInt_AsUnsignedLongLongMask PyInt_AsUnsignedLongM
PyAPI_FUNC(long) PyInt_GetMax(void);
-/* Macro, trading safety for speed */
-#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)
+#define PyInt_AS_LONG(op) PyLong_AsLong(op)
/* These aren't really part of the Int object, but they're handy; the protos
* are necessary for systems that need the magic of PyAPI_FUNC and that want
Modified: python/branches/int_unification/Include/longobject.h
==============================================================================
--- python/branches/int_unification/Include/longobject.h (original)
+++ python/branches/int_unification/Include/longobject.h Tue Aug 22 23:41:27 2006
@@ -16,15 +16,16 @@
PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
+PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t);
+PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t);
PyAPI_FUNC(PyObject *) PyLong_FromDouble(double);
PyAPI_FUNC(long) PyLong_AsLong(PyObject *);
+PyAPI_FUNC(ssize_t) PyLong_AsSsize_t(PyObject *);
+PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *);
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
/* For use by intobject.c only */
-PyAPI_FUNC(Py_ssize_t) _PyLong_AsSsize_t(PyObject *);
-PyAPI_FUNC(PyObject *) _PyLong_FromSize_t(size_t);
-PyAPI_FUNC(PyObject *) _PyLong_FromSsize_t(Py_ssize_t);
PyAPI_DATA(int) _PyLong_DigitValue[256];
/* _PyLong_AsScaledDouble returns a double x and an exponent e such that
@@ -34,6 +35,7 @@
be multiplied by SHIFT! There may not be enough room in an int to store
e*SHIFT directly. */
PyAPI_FUNC(double) _PyLong_AsScaledDouble(PyObject *vv, int *e);
+ PyAPI_FUNC(int) _PyLong_FitsInLong(PyObject* vv);
PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
Modified: python/branches/int_unification/Modules/_sre.c
==============================================================================
--- python/branches/int_unification/Modules/_sre.c (original)
+++ python/branches/int_unification/Modules/_sre.c Tue Aug 22 23:41:27 2006
@@ -2748,6 +2748,10 @@
{
Py_ssize_t i;
+ if (index == NULL)
+ /* Default value */
+ return 0;
+
if (PyInt_Check(index))
return PyInt_AsSsize_t(index);
@@ -2898,7 +2902,7 @@
{
Py_ssize_t index;
- PyObject* index_ = Py_False; /* zero */
+ PyObject* index_ = NULL;
if (!PyArg_UnpackTuple(args, "start", 0, 1, &index_))
return NULL;
@@ -2921,7 +2925,7 @@
{
Py_ssize_t index;
- PyObject* index_ = Py_False; /* zero */
+ PyObject* index_ = NULL;
if (!PyArg_UnpackTuple(args, "end", 0, 1, &index_))
return NULL;
@@ -2971,7 +2975,7 @@
{
Py_ssize_t index;
- PyObject* index_ = Py_False; /* zero */
+ PyObject* index_ = NULL;
if (!PyArg_UnpackTuple(args, "span", 0, 1, &index_))
return NULL;
Modified: python/branches/int_unification/Objects/abstract.c
==============================================================================
--- python/branches/int_unification/Objects/abstract.c (original)
+++ python/branches/int_unification/Objects/abstract.c Tue Aug 22 23:41:27 2006
@@ -915,10 +915,6 @@
}
return res;
}
- if (PyInt_Check(o)) { /* A int subclass without nb_int */
- PyIntObject *io = (PyIntObject*)o;
- return PyInt_FromLong(io->ob_ival);
- }
if (PyString_Check(o))
return int_from_string(PyString_AS_STRING(o),
PyString_GET_SIZE(o));
Modified: python/branches/int_unification/Objects/boolobject.c
==============================================================================
--- python/branches/int_unification/Objects/boolobject.c (original)
+++ python/branches/int_unification/Objects/boolobject.c Tue Aug 22 23:41:27 2006
@@ -67,8 +67,10 @@
static PyObject *
bool_and(PyObject *a, PyObject *b)
{
- if (!PyBool_Check(a) || !PyBool_Check(b))
- return PyInt_Type.tp_as_number->nb_and(a, b);
+ if (!PyBool_Check(a) || !PyBool_Check(b)) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
return PyBool_FromLong(
((PyBoolObject *)a)->ob_ival & ((PyBoolObject *)b)->ob_ival);
}
@@ -76,8 +78,10 @@
static PyObject *
bool_or(PyObject *a, PyObject *b)
{
- if (!PyBool_Check(a) || !PyBool_Check(b))
- return PyInt_Type.tp_as_number->nb_or(a, b);
+ if (!PyBool_Check(a) || !PyBool_Check(b)) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
return PyBool_FromLong(
((PyBoolObject *)a)->ob_ival | ((PyBoolObject *)b)->ob_ival);
}
@@ -85,12 +89,20 @@
static PyObject *
bool_xor(PyObject *a, PyObject *b)
{
- if (!PyBool_Check(a) || !PyBool_Check(b))
- return PyInt_Type.tp_as_number->nb_xor(a, b);
+ if (!PyBool_Check(a) || !PyBool_Check(b)) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
return PyBool_FromLong(
((PyBoolObject *)a)->ob_ival ^ ((PyBoolObject *)b)->ob_ival);
}
+static PyObject *
+bool_index(PyObject *a)
+{
+ return PyInt_FromLong(((PyBoolObject *)a)->ob_ival);
+}
+
/* Doc string */
PyDoc_STRVAR(bool_doc,
@@ -139,6 +151,7 @@
0, /* nb_true_divide */
0, /* nb_inplace_floor_divide */
0, /* nb_inplace_true_divide */
+ bool_index, /* nb_index */
};
/* The type object for bool. Note that this cannot be subclassed! */
@@ -147,7 +160,7 @@
PyObject_HEAD_INIT(&PyType_Type)
0,
"bool",
- sizeof(PyIntObject),
+ sizeof(PyBoolObject),
0,
0, /* tp_dealloc */
(printfunc)bool_print, /* tp_print */
@@ -175,7 +188,7 @@
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
- &PyInt_Type, /* tp_base */
+ 0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
@@ -188,12 +201,12 @@
/* The objects representing bool values False and True */
/* Named Zero for link-level compatibility */
-PyIntObject _Py_ZeroStruct = {
+PyBoolObject _Py_FalseStruct = {
PyObject_HEAD_INIT(&PyBool_Type)
0
};
-PyIntObject _Py_TrueStruct = {
+PyBoolObject _Py_TrueStruct = {
PyObject_HEAD_INIT(&PyBool_Type)
1
};
Modified: python/branches/int_unification/Objects/exceptions.c
==============================================================================
--- python/branches/int_unification/Objects/exceptions.c (original)
+++ python/branches/int_unification/Objects/exceptions.c Tue Aug 22 23:41:27 2006
@@ -1233,7 +1233,7 @@
if (PyInt_Check(attr)) {
*value = PyInt_AS_LONG(attr);
} else if (PyLong_Check(attr)) {
- *value = _PyLong_AsSsize_t(attr);
+ *value = PyLong_AsSsize_t(attr);
if (*value == -1 && PyErr_Occurred())
return -1;
} else {
@@ -1520,8 +1520,8 @@
if (!PyArg_ParseTuple(args, "O!O!O!O!O!",
&PyString_Type, &self->encoding,
objecttype, &self->object,
- &PyInt_Type, &self->start,
- &PyInt_Type, &self->end,
+ &PyLong_Type, &self->start,
+ &PyLong_Type, &self->end,
&PyString_Type, &self->reason)) {
self->encoding = self->object = self->start = self->end =
self->reason = NULL;
@@ -1752,8 +1752,8 @@
if (!PyArg_ParseTuple(args, "O!O!O!O!",
&PyUnicode_Type, &self->object,
- &PyInt_Type, &self->start,
- &PyInt_Type, &self->end,
+ &PyLong_Type, &self->start,
+ &PyLong_Type, &self->end,
&PyString_Type, &self->reason)) {
self->object = self->start = self->end = self->reason = NULL;
return -1;
Modified: python/branches/int_unification/Objects/intobject.c
==============================================================================
--- python/branches/int_unification/Objects/intobject.c (original)
+++ python/branches/int_unification/Objects/intobject.c Tue Aug 22 23:41:27 2006
@@ -10,6 +10,7 @@
return LONG_MAX; /* To initialize sys.maxint */
}
+#if 0
/* Integers are quite normal objects, to make object handling uniform.
(Using odd pointers to represent integers would save much space
but require extra checks for this special case throughout the code.)
@@ -1215,3 +1216,4 @@
}
}
}
+#endif /* if 0 */
Modified: python/branches/int_unification/Objects/listobject.c
==============================================================================
--- python/branches/int_unification/Objects/listobject.c (original)
+++ python/branches/int_unification/Objects/listobject.c Tue Aug 22 23:41:27 2006
@@ -869,8 +869,8 @@
if (!PyArg_UnpackTuple(args, "pop", 0, 1, &arg))
return NULL;
if (arg != NULL) {
- if (PyInt_Check(arg))
- i = PyInt_AS_LONG((PyIntObject*) arg);
+ if (PyLong_Check(arg))
+ i = PyLong_AsLong(arg);
else if (!PyArg_ParseTuple(args, "|n:pop", &i))
return NULL;
}
Modified: python/branches/int_unification/Objects/longobject.c
==============================================================================
--- python/branches/int_unification/Objects/longobject.c (original)
+++ python/branches/int_unification/Objects/longobject.c Tue Aug 22 23:41:27 2006
@@ -206,8 +206,6 @@
int sign;
if (vv == NULL || !PyLong_Check(vv)) {
- if (vv != NULL && PyInt_Check(vv))
- return PyInt_AsLong(vv);
PyErr_BadInternalCall();
return -1;
}
@@ -236,15 +234,26 @@
overflow:
PyErr_SetString(PyExc_OverflowError,
- "long int too large to convert to int");
+ "long int too large to convert to long");
return -1;
}
+int
+_PyLong_FitsInLong(PyObject *vv)
+{
+ if (!PyLong_CheckExact(vv)) {
+ PyErr_BadInternalCall();
+ return 0;
+ }
+ /* conservative estimate */
+ return ((PyLongObject*)vv)->ob_size <= 2;
+}
+
/* Get a Py_ssize_t from a long int object.
Returns -1 and sets an error condition if overflow occurs. */
Py_ssize_t
-_PyLong_AsSsize_t(PyObject *vv) {
+PyLong_AsSsize_t(PyObject *vv) {
register PyLongObject *v;
size_t x, prev;
Py_ssize_t i;
@@ -279,7 +288,7 @@
overflow:
PyErr_SetString(PyExc_OverflowError,
- "long int too large to convert to int");
+ "long int too large to convert to ");
return -1;
}
@@ -294,15 +303,6 @@
Py_ssize_t i;
if (vv == NULL || !PyLong_Check(vv)) {
- if (vv != NULL && PyInt_Check(vv)) {
- long val = PyInt_AsLong(vv);
- if (val < 0) {
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to unsigned long");
- return (unsigned long) -1;
- }
- return val;
- }
PyErr_BadInternalCall();
return (unsigned long) -1;
}
@@ -326,6 +326,40 @@
return x;
}
+/* Get a C unsigned long int from a long int object.
+ Returns -1 and sets an error condition if overflow occurs. */
+
+size_t
+PyLong_AsSize_t(PyObject *vv)
+{
+ register PyLongObject *v;
+ size_t x, prev;
+ Py_ssize_t i;
+
+ if (vv == NULL || !PyLong_Check(vv)) {
+ PyErr_BadInternalCall();
+ return (unsigned long) -1;
+ }
+ v = (PyLongObject *)vv;
+ i = v->ob_size;
+ x = 0;
+ if (i < 0) {
+ PyErr_SetString(PyExc_OverflowError,
+ "can't convert negative value to size_t");
+ return (size_t) -1;
+ }
+ while (--i >= 0) {
+ prev = x;
+ x = (x << SHIFT) + v->ob_digit[i];
+ if ((x >> SHIFT) != prev) {
+ PyErr_SetString(PyExc_OverflowError,
+ "long int too large to convert");
+ return (unsigned long) -1;
+ }
+ }
+ return x;
+}
+
/* Get a C unsigned long int from a long int object, ignoring the high bits.
Returns -1 and sets an error condition if an error occurs. */
@@ -338,8 +372,6 @@
int sign;
if (vv == NULL || !PyLong_Check(vv)) {
- if (vv != NULL && PyInt_Check(vv))
- return PyInt_AsUnsignedLongMask(vv);
PyErr_BadInternalCall();
return (unsigned long) -1;
}
@@ -734,24 +766,14 @@
PyObject *
PyLong_FromVoidPtr(void *p)
{
-#if SIZEOF_VOID_P <= SIZEOF_LONG
- if ((long)p < 0)
- return PyLong_FromUnsignedLong((unsigned long)p);
- return PyInt_FromLong((long)p);
-#else
-
#ifndef HAVE_LONG_LONG
# error "PyLong_FromVoidPtr: sizeof(void*) > sizeof(long), but no long long"
#endif
#if SIZEOF_LONG_LONG < SIZEOF_VOID_P
# error "PyLong_FromVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)"
#endif
- /* optimize null pointers */
- if (p == NULL)
- return PyInt_FromLong(0);
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)p);
-#endif /* SIZEOF_VOID_P <= SIZEOF_LONG */
}
/* Get a C pointer from a long object (or an int object in some cases) */
@@ -766,9 +788,7 @@
#if SIZEOF_VOID_P <= SIZEOF_LONG
long x;
- if (PyInt_Check(vv))
- x = PyInt_AS_LONG(vv);
- else if (PyLong_Check(vv) && _PyLong_Sign(vv) < 0)
+ if (PyLong_Check(vv) && _PyLong_Sign(vv) < 0)
x = PyLong_AsLong(vv);
else
x = PyLong_AsUnsignedLong(vv);
@@ -782,9 +802,7 @@
#endif
PY_LONG_LONG x;
- if (PyInt_Check(vv))
- x = PyInt_AS_LONG(vv);
- else if (PyLong_Check(vv) && _PyLong_Sign(vv) < 0)
+ if (PyLong_Check(vv) && _PyLong_Sign(vv) < 0)
x = PyLong_AsLongLong(vv);
else
x = PyLong_AsUnsignedLongLong(vv);
@@ -871,19 +889,19 @@
/* Create a new long int object from a C Py_ssize_t. */
PyObject *
-_PyLong_FromSsize_t(Py_ssize_t ival)
+PyLong_FromSsize_t(Py_ssize_t ival)
{
Py_ssize_t bytes = ival;
int one = 1;
return _PyLong_FromByteArray(
(unsigned char *)&bytes,
- SIZEOF_SIZE_T, IS_LITTLE_ENDIAN, 0);
+ SIZEOF_SIZE_T, IS_LITTLE_ENDIAN, 1);
}
/* Create a new long int object from a C size_t. */
PyObject *
-_PyLong_FromSize_t(size_t ival)
+PyLong_FromSize_t(size_t ival)
{
size_t bytes = ival;
int one = 1;
@@ -909,8 +927,6 @@
if (!PyLong_Check(vv)) {
PyNumberMethods *nb;
PyObject *io;
- if (PyInt_Check(vv))
- return (PY_LONG_LONG)PyInt_AsLong(vv);
if ((nb = vv->ob_type->tp_as_number) == NULL ||
nb->nb_int == NULL) {
PyErr_SetString(PyExc_TypeError, "an integer is required");
@@ -919,11 +935,6 @@
io = (*nb->nb_int) (vv);
if (io == NULL)
return -1;
- if (PyInt_Check(io)) {
- bytes = PyInt_AsLong(io);
- Py_DECREF(io);
- return bytes;
- }
if (PyLong_Check(io)) {
bytes = PyLong_AsLongLong(io);
Py_DECREF(io);
@@ -1010,9 +1021,6 @@
*a = (PyLongObject *) v;
Py_INCREF(v);
}
- else if (PyInt_Check(v)) {
- *a = (PyLongObject *) PyLong_FromLong(PyInt_AS_LONG(v));
- }
else {
return 0;
}
@@ -1020,9 +1028,6 @@
*b = (PyLongObject *) w;
Py_INCREF(w);
}
- else if (PyInt_Check(w)) {
- *b = (PyLongObject *) PyLong_FromLong(PyInt_AS_LONG(w));
- }
else {
Py_DECREF(*a);
return 0;
@@ -2662,11 +2667,6 @@
c = (PyLongObject *)x;
Py_INCREF(x);
}
- else if (PyInt_Check(x)) {
- c = (PyLongObject *)PyLong_FromLong(PyInt_AS_LONG(x));
- if (c == NULL)
- goto Error;
- }
else if (x == Py_None)
c = NULL;
else {
@@ -3155,12 +3155,7 @@
static int
long_coerce(PyObject **pv, PyObject **pw)
{
- if (PyInt_Check(*pw)) {
- *pw = PyLong_FromLong(PyInt_AS_LONG(*pw));
- Py_INCREF(*pv);
- return 0;
- }
- else if (PyLong_Check(*pw)) {
+ if (PyLong_Check(*pw)) {
Py_INCREF(*pv);
Py_INCREF(*pw);
return 0;
@@ -3181,22 +3176,8 @@
static PyObject *
long_int(PyObject *v)
{
- long x;
- x = PyLong_AsLong(v);
- if (PyErr_Occurred()) {
- if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
- PyErr_Clear();
- if (PyLong_CheckExact(v)) {
- Py_INCREF(v);
- return v;
- }
- else
- return _PyLong_Copy((PyLongObject *)v);
- }
- else
- return NULL;
- }
- return PyInt_FromLong(x);
+ Py_INCREF(v);
+ return v;
}
static PyObject *
@@ -3364,7 +3345,7 @@
0, /* tp_as_mapping */
(hashfunc)long_hash, /* tp_hash */
0, /* tp_call */
- 0, /* tp_str */
+ long_repr, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
@@ -3389,3 +3370,42 @@
long_new, /* tp_new */
PyObject_Del, /* tp_free */
};
+
+int
+_PyLong_Init(void)
+{
+ int ival;
+#if 0
+#if NSMALLNEGINTS + NSMALLPOSINTS > 0
+ for (ival = -NSMALLNEGINTS; ival < NSMALLPOSINTS; ival++) {
+ if (!free_list && (free_list = fill_free_list()) == NULL)
+ return 0;
+ /* PyObject_New is inlined */
+ v = free_list;
+ free_list = (PyIntObject *)v->ob_type;
+ PyObject_INIT(v, &PyInt_Type);
+ v->ob_ival = ival;
+ small_ints[ival + NSMALLNEGINTS] = v;
+ }
+#endif
+#endif
+ return 1;
+}
+
+void
+PyLong_Fini(void)
+{
+ int i;
+#if 0
+#if NSMALLNEGINTS + NSMALLPOSINTS > 0
+ PyIntObject **q;
+
+ i = NSMALLNEGINTS + NSMALLPOSINTS;
+ q = small_ints;
+ while (--i >= 0) {
+ Py_XDECREF(*q);
+ *q++ = NULL;
+ }
+#endif
+#endif
+}
Modified: python/branches/int_unification/Python/bltinmodule.c
==============================================================================
--- python/branches/int_unification/Python/bltinmodule.c (original)
+++ python/branches/int_unification/Python/bltinmodule.c Tue Aug 22 23:41:27 2006
@@ -2138,7 +2138,7 @@
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);
Modified: python/branches/int_unification/Python/marshal.c
==============================================================================
--- python/branches/int_unification/Python/marshal.c (original)
+++ python/branches/int_unification/Python/marshal.c Tue Aug 22 23:41:27 2006
@@ -144,31 +144,34 @@
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];
Modified: python/branches/int_unification/Python/pythonrun.c
==============================================================================
--- python/branches/int_unification/Python/pythonrun.c (original)
+++ python/branches/int_unification/Python/pythonrun.c Tue Aug 22 23:41:27 2006
@@ -181,7 +181,7 @@
if (!_PyFrame_Init())
Py_FatalError("Py_Initialize: can't init frames");
- if (!_PyInt_Init())
+ if (!_PyLong_Init())
Py_FatalError("Py_Initialize: can't init ints");
_PyFloat_Init();
@@ -453,7 +453,7 @@
PyList_Fini();
PySet_Fini();
PyString_Fini();
- PyInt_Fini();
+ PyLong_Fini();
PyFloat_Fini();
#ifdef Py_USING_UNICODE