More bug 460020. Disable a number of long optimizations for long subclasses.
This commit is contained in:
parent
0280cf79a7
commit
69c2de3ad6
|
@ -1389,6 +1389,30 @@ def inherits():
|
|||
a = octlong(12345)
|
||||
verify(long(a) == 12345L)
|
||||
verify(long(a).__class__ is long)
|
||||
verify((+a).__class__ is long)
|
||||
verify((-a).__class__ is long)
|
||||
verify((-octlong(0)).__class__ is long)
|
||||
verify((a >> 0).__class__ is long)
|
||||
verify((a << 0).__class__ is long)
|
||||
verify((a - 0).__class__ is long)
|
||||
verify((a * 1).__class__ is long)
|
||||
verify((a ** 1).__class__ is long)
|
||||
verify((a // 1).__class__ is long)
|
||||
verify((1 * a).__class__ is long)
|
||||
verify((a | 0).__class__ is long)
|
||||
verify((a ^ 0).__class__ is long)
|
||||
verify((a & -1L).__class__ is long)
|
||||
verify((octlong(0) << 12).__class__ is long)
|
||||
verify((octlong(0) >> 12).__class__ is long)
|
||||
verify(abs(octlong(0)).__class__ is long)
|
||||
|
||||
# Because octlong overrides __add__, we can't check the absence of +0
|
||||
# optimizations using octlong.
|
||||
class longclone(long):
|
||||
pass
|
||||
a = longclone(1)
|
||||
verify((a + 0).__class__ is long)
|
||||
verify((0 + a).__class__ is long)
|
||||
|
||||
class precfloat(float):
|
||||
__slots__ = ['prec']
|
||||
|
|
|
@ -1820,26 +1820,25 @@ long_invert(PyLongObject *v)
|
|||
static PyObject *
|
||||
long_pos(PyLongObject *v)
|
||||
{
|
||||
if (PyLong_CheckExact(v)) {
|
||||
Py_INCREF(v);
|
||||
return (PyObject *)v;
|
||||
}
|
||||
else
|
||||
return _PyLong_Copy(v);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
long_neg(PyLongObject *v)
|
||||
{
|
||||
PyLongObject *z;
|
||||
int i, n;
|
||||
n = ABS(v->ob_size);
|
||||
if (n == 0) {
|
||||
if (v->ob_size == 0 && PyLong_CheckExact(v)) {
|
||||
/* -0 == 0 */
|
||||
Py_INCREF(v);
|
||||
return (PyObject *) v;
|
||||
}
|
||||
z = _PyLong_New(ABS(n));
|
||||
if (z == NULL)
|
||||
return NULL;
|
||||
for (i = 0; i < n; i++)
|
||||
z->ob_digit[i] = v->ob_digit[i];
|
||||
z = (PyLongObject *)_PyLong_Copy(v);
|
||||
if (z != NULL)
|
||||
z->ob_size = -(v->ob_size);
|
||||
return (PyObject *)z;
|
||||
}
|
||||
|
@ -1849,10 +1848,8 @@ long_abs(PyLongObject *v)
|
|||
{
|
||||
if (v->ob_size < 0)
|
||||
return long_neg(v);
|
||||
else {
|
||||
Py_INCREF(v);
|
||||
return (PyObject *)v;
|
||||
}
|
||||
else
|
||||
return long_pos(v);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Reference in New Issue