Merged revisions 81036 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81036 | mark.dickinson | 2010-05-09 21:30:29 +0100 (Sun, 09 May 2010) | 1 line Post-detabification cleanup: whitespace fixes and long line rewraps only. ........
This commit is contained in:
parent
e43baaba73
commit
22b20183d5
|
@ -278,12 +278,12 @@ PyLong_FromDouble(double dval)
|
||||||
neg = 0;
|
neg = 0;
|
||||||
if (Py_IS_INFINITY(dval)) {
|
if (Py_IS_INFINITY(dval)) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"cannot convert float infinity to integer");
|
"cannot convert float infinity to integer");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (Py_IS_NAN(dval)) {
|
if (Py_IS_NAN(dval)) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"cannot convert float NaN to integer");
|
"cannot convert float NaN to integer");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (dval < 0.0) {
|
if (dval < 0.0) {
|
||||||
|
@ -404,7 +404,7 @@ PyLong_AsLongAndOverflow(PyObject *vv, int *overflow)
|
||||||
/* res is already set to -1 */
|
/* res is already set to -1 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit:
|
exit:
|
||||||
if (do_decref) {
|
if (do_decref) {
|
||||||
Py_DECREF(vv);
|
Py_DECREF(vv);
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,7 @@ PyLong_AsSsize_t(PyObject *vv) {
|
||||||
}
|
}
|
||||||
/* else overflow */
|
/* else overflow */
|
||||||
|
|
||||||
overflow:
|
overflow:
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"Python int too large to convert to C ssize_t");
|
"Python int too large to convert to C ssize_t");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -504,7 +504,7 @@ PyLong_AsUnsignedLong(PyObject *vv)
|
||||||
x = 0;
|
x = 0;
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"can't convert negative value to unsigned int");
|
"can't convert negative value to unsigned int");
|
||||||
return (unsigned long) -1;
|
return (unsigned long) -1;
|
||||||
}
|
}
|
||||||
switch (i) {
|
switch (i) {
|
||||||
|
@ -516,7 +516,8 @@ PyLong_AsUnsignedLong(PyObject *vv)
|
||||||
x = (x << PyLong_SHIFT) | v->ob_digit[i];
|
x = (x << PyLong_SHIFT) | v->ob_digit[i];
|
||||||
if ((x >> PyLong_SHIFT) != prev) {
|
if ((x >> PyLong_SHIFT) != prev) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"python int too large to convert to C unsigned long");
|
"python int too large to convert "
|
||||||
|
"to C unsigned long");
|
||||||
return (unsigned long) -1;
|
return (unsigned long) -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,7 +672,7 @@ _PyLong_NumBits(PyObject *vv)
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
Overflow:
|
Overflow:
|
||||||
PyErr_SetString(PyExc_OverflowError, "int has too many bits "
|
PyErr_SetString(PyExc_OverflowError, "int has too many bits "
|
||||||
"to express in a platform size_t");
|
"to express in a platform size_t");
|
||||||
return (size_t)-1;
|
return (size_t)-1;
|
||||||
|
@ -681,7 +682,7 @@ PyObject *
|
||||||
_PyLong_FromByteArray(const unsigned char* bytes, size_t n,
|
_PyLong_FromByteArray(const unsigned char* bytes, size_t n,
|
||||||
int little_endian, int is_signed)
|
int little_endian, int is_signed)
|
||||||
{
|
{
|
||||||
const unsigned char* pstartbyte;/* LSB of bytes */
|
const unsigned char* pstartbyte; /* LSB of bytes */
|
||||||
int incr; /* direction to move pstartbyte */
|
int incr; /* direction to move pstartbyte */
|
||||||
const unsigned char* pendbyte; /* MSB of bytes */
|
const unsigned char* pendbyte; /* MSB of bytes */
|
||||||
size_t numsignificantbytes; /* number of bytes that matter */
|
size_t numsignificantbytes; /* number of bytes that matter */
|
||||||
|
@ -769,8 +770,7 @@ _PyLong_FromByteArray(const unsigned char* bytes, size_t n,
|
||||||
if (accumbits >= PyLong_SHIFT) {
|
if (accumbits >= PyLong_SHIFT) {
|
||||||
/* There's enough to fill a Python digit. */
|
/* There's enough to fill a Python digit. */
|
||||||
assert(idigit < ndigits);
|
assert(idigit < ndigits);
|
||||||
v->ob_digit[idigit] = (digit)(accum &
|
v->ob_digit[idigit] = (digit)(accum & PyLong_MASK);
|
||||||
PyLong_MASK);
|
|
||||||
++idigit;
|
++idigit;
|
||||||
accum >>= PyLong_SHIFT;
|
accum >>= PyLong_SHIFT;
|
||||||
accumbits -= PyLong_SHIFT;
|
accumbits -= PyLong_SHIFT;
|
||||||
|
@ -795,9 +795,9 @@ _PyLong_AsByteArray(PyLongObject* v,
|
||||||
int little_endian, int is_signed)
|
int little_endian, int is_signed)
|
||||||
{
|
{
|
||||||
Py_ssize_t i; /* index into v->ob_digit */
|
Py_ssize_t i; /* index into v->ob_digit */
|
||||||
Py_ssize_t ndigits; /* |v->ob_size| */
|
Py_ssize_t ndigits; /* |v->ob_size| */
|
||||||
twodigits accum; /* sliding register */
|
twodigits accum; /* sliding register */
|
||||||
unsigned int accumbits; /* # bits in accum */
|
unsigned int accumbits; /* # bits in accum */
|
||||||
int do_twos_comp; /* store 2's-comp? is_signed and v < 0 */
|
int do_twos_comp; /* store 2's-comp? is_signed and v < 0 */
|
||||||
digit carry; /* for computing 2's-comp */
|
digit carry; /* for computing 2's-comp */
|
||||||
size_t j; /* # bytes filled */
|
size_t j; /* # bytes filled */
|
||||||
|
@ -810,7 +810,7 @@ _PyLong_AsByteArray(PyLongObject* v,
|
||||||
ndigits = -(Py_SIZE(v));
|
ndigits = -(Py_SIZE(v));
|
||||||
if (!is_signed) {
|
if (!is_signed) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"can't convert negative int to unsigned");
|
"can't convert negative int to unsigned");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
do_twos_comp = 1;
|
do_twos_comp = 1;
|
||||||
|
@ -856,8 +856,7 @@ _PyLong_AsByteArray(PyLongObject* v,
|
||||||
/* Count # of sign bits -- they needn't be stored,
|
/* Count # of sign bits -- they needn't be stored,
|
||||||
* although for signed conversion we need later to
|
* although for signed conversion we need later to
|
||||||
* make sure at least one sign bit gets stored. */
|
* make sure at least one sign bit gets stored. */
|
||||||
digit s = do_twos_comp ? thisdigit ^ PyLong_MASK :
|
digit s = do_twos_comp ? thisdigit ^ PyLong_MASK : thisdigit;
|
||||||
thisdigit;
|
|
||||||
while (s != 0) {
|
while (s != 0) {
|
||||||
s >>= 1;
|
s >>= 1;
|
||||||
accumbits++;
|
accumbits++;
|
||||||
|
@ -917,7 +916,7 @@ _PyLong_AsByteArray(PyLongObject* v,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Overflow:
|
Overflow:
|
||||||
PyErr_SetString(PyExc_OverflowError, "int too big to convert");
|
PyErr_SetString(PyExc_OverflowError, "int too big to convert");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -986,7 +985,7 @@ PyLong_AsVoidPtr(PyObject *vv)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define IS_LITTLE_ENDIAN (int)*(unsigned char*)&one
|
#define IS_LITTLE_ENDIAN (int)*(unsigned char*)&one
|
||||||
#define PY_ABS_LLONG_MIN (0-(unsigned PY_LONG_LONG)PY_LLONG_MIN)
|
#define PY_ABS_LLONG_MIN (0-(unsigned PY_LONG_LONG)PY_LLONG_MIN)
|
||||||
|
|
||||||
/* Create a new long int object from a C PY_LONG_LONG int. */
|
/* Create a new long int object from a C PY_LONG_LONG int. */
|
||||||
|
|
||||||
|
@ -1172,9 +1171,8 @@ PyLong_AsLongLong(PyObject *vv)
|
||||||
case 0: return 0;
|
case 0: return 0;
|
||||||
case 1: return v->ob_digit[0];
|
case 1: return v->ob_digit[0];
|
||||||
}
|
}
|
||||||
res = _PyLong_AsByteArray(
|
res = _PyLong_AsByteArray((PyLongObject *)vv, (unsigned char *)&bytes,
|
||||||
(PyLongObject *)vv, (unsigned char *)&bytes,
|
SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 1);
|
||||||
SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 1);
|
|
||||||
|
|
||||||
/* Plan 9 can't handle PY_LONG_LONG in ? : expressions */
|
/* Plan 9 can't handle PY_LONG_LONG in ? : expressions */
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
|
@ -1205,9 +1203,8 @@ PyLong_AsUnsignedLongLong(PyObject *vv)
|
||||||
case 1: return v->ob_digit[0];
|
case 1: return v->ob_digit[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
res = _PyLong_AsByteArray(
|
res = _PyLong_AsByteArray((PyLongObject *)vv, (unsigned char *)&bytes,
|
||||||
(PyLongObject *)vv, (unsigned char *)&bytes,
|
SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0);
|
||||||
SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0);
|
|
||||||
|
|
||||||
/* Plan 9 can't handle PY_LONG_LONG in ? : expressions */
|
/* Plan 9 can't handle PY_LONG_LONG in ? : expressions */
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
|
@ -1373,7 +1370,7 @@ PyLong_AsLongLongAndOverflow(PyObject *vv, int *overflow)
|
||||||
/* res is already set to -1 */
|
/* res is already set to -1 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit:
|
exit:
|
||||||
if (do_decref) {
|
if (do_decref) {
|
||||||
Py_DECREF(vv);
|
Py_DECREF(vv);
|
||||||
}
|
}
|
||||||
|
@ -1600,9 +1597,9 @@ long_to_decimal_string(PyObject *aa)
|
||||||
}
|
}
|
||||||
/* check for keyboard interrupt */
|
/* check for keyboard interrupt */
|
||||||
SIGCHECK({
|
SIGCHECK({
|
||||||
Py_DECREF(scratch);
|
Py_DECREF(scratch);
|
||||||
return NULL;
|
return NULL;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/* pout should have at least one digit, so that the case when a = 0
|
/* pout should have at least one digit, so that the case when a = 0
|
||||||
works correctly */
|
works correctly */
|
||||||
|
@ -1998,8 +1995,8 @@ digit beyond the first.
|
||||||
twodigits convmax = base;
|
twodigits convmax = base;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
log_base_BASE[base] = log((double)base) /
|
log_base_BASE[base] = (log((double)base) /
|
||||||
log((double)PyLong_BASE);
|
log((double)PyLong_BASE));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
twodigits next = convmax * base;
|
twodigits next = convmax * base;
|
||||||
if (next > PyLong_BASE)
|
if (next > PyLong_BASE)
|
||||||
|
@ -2043,7 +2040,7 @@ digit beyond the first.
|
||||||
c = (digit)_PyLong_DigitValue[Py_CHARMASK(*str++)];
|
c = (digit)_PyLong_DigitValue[Py_CHARMASK(*str++)];
|
||||||
for (i = 1; i < convwidth && str != scan; ++i, ++str) {
|
for (i = 1; i < convwidth && str != scan; ++i, ++str) {
|
||||||
c = (twodigits)(c * base +
|
c = (twodigits)(c * base +
|
||||||
(int)_PyLong_DigitValue[Py_CHARMASK(*str)]);
|
(int)_PyLong_DigitValue[Py_CHARMASK(*str)]);
|
||||||
assert(c < PyLong_BASE);
|
assert(c < PyLong_BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2116,7 +2113,7 @@ digit beyond the first.
|
||||||
long_normalize(z);
|
long_normalize(z);
|
||||||
return (PyObject *) maybe_small_long(z);
|
return (PyObject *) maybe_small_long(z);
|
||||||
|
|
||||||
onError:
|
onError:
|
||||||
Py_XDECREF(z);
|
Py_XDECREF(z);
|
||||||
slen = strlen(orig_str) < 200 ? strlen(orig_str) : 200;
|
slen = strlen(orig_str) < 200 ? strlen(orig_str) : 200;
|
||||||
strobj = PyUnicode_FromStringAndSize(orig_str, slen);
|
strobj = PyUnicode_FromStringAndSize(orig_str, slen);
|
||||||
|
@ -2272,12 +2269,12 @@ x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
|
||||||
single-digit quotient q, remainder in vk[0:size_w]. */
|
single-digit quotient q, remainder in vk[0:size_w]. */
|
||||||
|
|
||||||
SIGCHECK({
|
SIGCHECK({
|
||||||
Py_DECREF(a);
|
Py_DECREF(a);
|
||||||
Py_DECREF(w);
|
Py_DECREF(w);
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
*prem = NULL;
|
*prem = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
})
|
})
|
||||||
|
|
||||||
/* estimate quotient digit q; may overestimate by 1 (rare) */
|
/* estimate quotient digit q; may overestimate by 1 (rare) */
|
||||||
vtop = vk[size_w];
|
vtop = vk[size_w];
|
||||||
|
@ -2303,7 +2300,7 @@ x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
|
||||||
(stwodigits)q * (stwodigits)w0[i];
|
(stwodigits)q * (stwodigits)w0[i];
|
||||||
vk[i] = (digit)z & PyLong_MASK;
|
vk[i] = (digit)z & PyLong_MASK;
|
||||||
zhi = (sdigit)Py_ARITHMETIC_RIGHT_SHIFT(stwodigits,
|
zhi = (sdigit)Py_ARITHMETIC_RIGHT_SHIFT(stwodigits,
|
||||||
z, PyLong_SHIFT);
|
z, PyLong_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add w back if q was too large (this branch taken rarely) */
|
/* add w back if q was too large (this branch taken rarely) */
|
||||||
|
@ -2370,7 +2367,7 @@ _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e)
|
||||||
if (a_size >= (PY_SSIZE_T_MAX - 1) / PyLong_SHIFT + 1 &&
|
if (a_size >= (PY_SSIZE_T_MAX - 1) / PyLong_SHIFT + 1 &&
|
||||||
(a_size > (PY_SSIZE_T_MAX - 1) / PyLong_SHIFT + 1 ||
|
(a_size > (PY_SSIZE_T_MAX - 1) / PyLong_SHIFT + 1 ||
|
||||||
a_bits > (PY_SSIZE_T_MAX - 1) % PyLong_SHIFT + 1))
|
a_bits > (PY_SSIZE_T_MAX - 1) % PyLong_SHIFT + 1))
|
||||||
goto overflow;
|
goto overflow;
|
||||||
a_bits = (a_size - 1) * PyLong_SHIFT + a_bits;
|
a_bits = (a_size - 1) * PyLong_SHIFT + a_bits;
|
||||||
|
|
||||||
/* Shift the first DBL_MANT_DIG + 2 bits of a into x_digits[0:x_size]
|
/* Shift the first DBL_MANT_DIG + 2 bits of a into x_digits[0:x_size]
|
||||||
|
@ -2428,7 +2425,8 @@ _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(1 <= x_size && x_size <= (Py_ssize_t)(sizeof(x_digits)/sizeof(digit)));
|
assert(1 <= x_size &&
|
||||||
|
x_size <= (Py_ssize_t)(sizeof(x_digits)/sizeof(digit)));
|
||||||
|
|
||||||
/* Round, and convert to double. */
|
/* Round, and convert to double. */
|
||||||
x_digits[0] += half_even_correction[x_digits[0] & 7];
|
x_digits[0] += half_even_correction[x_digits[0] & 7];
|
||||||
|
@ -2603,8 +2601,8 @@ x_add(PyLongObject *a, PyLongObject *b)
|
||||||
if (size_a < size_b) {
|
if (size_a < size_b) {
|
||||||
{ PyLongObject *temp = a; a = b; b = temp; }
|
{ PyLongObject *temp = a; a = b; b = temp; }
|
||||||
{ Py_ssize_t size_temp = size_a;
|
{ Py_ssize_t size_temp = size_a;
|
||||||
size_a = size_b;
|
size_a = size_b;
|
||||||
size_b = size_temp; }
|
size_b = size_temp; }
|
||||||
}
|
}
|
||||||
z = _PyLong_New(size_a+1);
|
z = _PyLong_New(size_a+1);
|
||||||
if (z == NULL)
|
if (z == NULL)
|
||||||
|
@ -2639,8 +2637,8 @@ x_sub(PyLongObject *a, PyLongObject *b)
|
||||||
sign = -1;
|
sign = -1;
|
||||||
{ PyLongObject *temp = a; a = b; b = temp; }
|
{ PyLongObject *temp = a; a = b; b = temp; }
|
||||||
{ Py_ssize_t size_temp = size_a;
|
{ Py_ssize_t size_temp = size_a;
|
||||||
size_a = size_b;
|
size_a = size_b;
|
||||||
size_b = size_temp; }
|
size_b = size_temp; }
|
||||||
}
|
}
|
||||||
else if (size_a == size_b) {
|
else if (size_a == size_b) {
|
||||||
/* Find highest digit where a and b differ: */
|
/* Find highest digit where a and b differ: */
|
||||||
|
@ -2768,9 +2766,9 @@ x_mul(PyLongObject *a, PyLongObject *b)
|
||||||
digit *paend = a->ob_digit + size_a;
|
digit *paend = a->ob_digit + size_a;
|
||||||
|
|
||||||
SIGCHECK({
|
SIGCHECK({
|
||||||
Py_DECREF(z);
|
Py_DECREF(z);
|
||||||
return NULL;
|
return NULL;
|
||||||
})
|
})
|
||||||
|
|
||||||
carry = *pz + f * f;
|
carry = *pz + f * f;
|
||||||
*pz++ = (digit)(carry & PyLong_MASK);
|
*pz++ = (digit)(carry & PyLong_MASK);
|
||||||
|
@ -2806,9 +2804,9 @@ x_mul(PyLongObject *a, PyLongObject *b)
|
||||||
digit *pbend = b->ob_digit + size_b;
|
digit *pbend = b->ob_digit + size_b;
|
||||||
|
|
||||||
SIGCHECK({
|
SIGCHECK({
|
||||||
Py_DECREF(z);
|
Py_DECREF(z);
|
||||||
return NULL;
|
return NULL;
|
||||||
})
|
})
|
||||||
|
|
||||||
while (pb < pbend) {
|
while (pb < pbend) {
|
||||||
carry += *pz + *pb++ * f;
|
carry += *pz + *pb++ * f;
|
||||||
|
@ -2832,7 +2830,10 @@ x_mul(PyLongObject *a, PyLongObject *b)
|
||||||
Returns 0 on success, -1 on failure.
|
Returns 0 on success, -1 on failure.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
kmul_split(PyLongObject *n, Py_ssize_t size, PyLongObject **high, PyLongObject **low)
|
kmul_split(PyLongObject *n,
|
||||||
|
Py_ssize_t size,
|
||||||
|
PyLongObject **high,
|
||||||
|
PyLongObject **low)
|
||||||
{
|
{
|
||||||
PyLongObject *hi, *lo;
|
PyLongObject *hi, *lo;
|
||||||
Py_ssize_t size_lo, size_hi;
|
Py_ssize_t size_lo, size_hi;
|
||||||
|
@ -3021,7 +3022,7 @@ k_mul(PyLongObject *a, PyLongObject *b)
|
||||||
|
|
||||||
return long_normalize(ret);
|
return long_normalize(ret);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
Py_XDECREF(ret);
|
Py_XDECREF(ret);
|
||||||
Py_XDECREF(ah);
|
Py_XDECREF(ah);
|
||||||
Py_XDECREF(al);
|
Py_XDECREF(al);
|
||||||
|
@ -3131,7 +3132,7 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
|
||||||
Py_DECREF(bslice);
|
Py_DECREF(bslice);
|
||||||
return long_normalize(ret);
|
return long_normalize(ret);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
Py_DECREF(ret);
|
Py_DECREF(ret);
|
||||||
Py_XDECREF(bslice);
|
Py_XDECREF(bslice);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -3414,7 +3415,7 @@ long_true_divide(PyObject *v, PyObject *w)
|
||||||
here. Both a and b would have to be enormous,
|
here. Both a and b would have to be enormous,
|
||||||
using close to SIZE_T_MAX bytes of memory each. */
|
using close to SIZE_T_MAX bytes of memory each. */
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"intermediate overflow during division");
|
"intermediate overflow during division");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
x = _PyLong_New(a_size + shift_digits + 1);
|
x = _PyLong_New(a_size + shift_digits + 1);
|
||||||
|
@ -3578,7 +3579,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
||||||
if (Py_SIZE(b) < 0) { /* if exponent is negative */
|
if (Py_SIZE(b) < 0) { /* if exponent is negative */
|
||||||
if (c) {
|
if (c) {
|
||||||
PyErr_SetString(PyExc_TypeError, "pow() 2nd argument "
|
PyErr_SetString(PyExc_TypeError, "pow() 2nd argument "
|
||||||
"cannot be negative when 3rd argument specified");
|
"cannot be negative when 3rd argument specified");
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3708,13 +3709,13 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
||||||
}
|
}
|
||||||
goto Done;
|
goto Done;
|
||||||
|
|
||||||
Error:
|
Error:
|
||||||
if (z != NULL) {
|
if (z != NULL) {
|
||||||
Py_DECREF(z);
|
Py_DECREF(z);
|
||||||
z = NULL;
|
z = NULL;
|
||||||
}
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
Done:
|
Done:
|
||||||
if (Py_SIZE(b) > FIVEARY_CUTOFF) {
|
if (Py_SIZE(b) > FIVEARY_CUTOFF) {
|
||||||
for (i = 0; i < 32; ++i)
|
for (i = 0; i < 32; ++i)
|
||||||
Py_XDECREF(table[i]);
|
Py_XDECREF(table[i]);
|
||||||
|
@ -3819,12 +3820,11 @@ long_rshift(PyLongObject *a, PyLongObject *b)
|
||||||
for (i = 0, j = wordshift; i < newsize; i++, j++) {
|
for (i = 0, j = wordshift; i < newsize; i++, j++) {
|
||||||
z->ob_digit[i] = (a->ob_digit[j] >> loshift) & lomask;
|
z->ob_digit[i] = (a->ob_digit[j] >> loshift) & lomask;
|
||||||
if (i+1 < newsize)
|
if (i+1 < newsize)
|
||||||
z->ob_digit[i] |=
|
z->ob_digit[i] |= (a->ob_digit[j+1] << hishift) & himask;
|
||||||
(a->ob_digit[j+1] << hishift) & himask;
|
|
||||||
}
|
}
|
||||||
z = long_normalize(z);
|
z = long_normalize(z);
|
||||||
}
|
}
|
||||||
rshift_error:
|
rshift_error:
|
||||||
return (PyObject *) maybe_small_long(z);
|
return (PyObject *) maybe_small_long(z);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3874,7 +3874,7 @@ long_lshift(PyObject *v, PyObject *w)
|
||||||
else
|
else
|
||||||
assert(!accum);
|
assert(!accum);
|
||||||
z = long_normalize(z);
|
z = long_normalize(z);
|
||||||
lshift_error:
|
lshift_error:
|
||||||
return (PyObject *) maybe_small_long(z);
|
return (PyObject *) maybe_small_long(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3900,7 +3900,7 @@ v_complement(digit *z, digit *a, Py_ssize_t m)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
long_bitwise(PyLongObject *a,
|
long_bitwise(PyLongObject *a,
|
||||||
int op, /* '&', '|', '^' */
|
int op, /* '&', '|', '^' */
|
||||||
PyLongObject *b)
|
PyLongObject *b)
|
||||||
{
|
{
|
||||||
int nega, negb, negz;
|
int nega, negb, negz;
|
||||||
Py_ssize_t size_a, size_b, size_z, i;
|
Py_ssize_t size_a, size_b, size_z, i;
|
||||||
|
@ -4103,15 +4103,15 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
/* We only see this if there's a null byte in x,
|
/* We only see this if there's a null byte in x,
|
||||||
x is a bytes or buffer, *and* a base is given. */
|
x is a bytes or buffer, *and* a base is given. */
|
||||||
PyErr_Format(PyExc_ValueError,
|
PyErr_Format(PyExc_ValueError,
|
||||||
"invalid literal for int() with base %d: %R",
|
"invalid literal for int() with base %d: %R",
|
||||||
base, x);
|
base, x);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return PyLong_FromString(string, NULL, base);
|
return PyLong_FromString(string, NULL, base);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"int() can't convert non-string with explicit base");
|
"int() can't convert non-string with explicit base");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4371,7 +4371,7 @@ long_bit_length(PyLongObject *v)
|
||||||
|
|
||||||
return (PyObject *)result;
|
return (PyObject *)result;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -4633,40 +4633,40 @@ string, use the optional base. It is an error to supply a base when\n\
|
||||||
converting a non-string.");
|
converting a non-string.");
|
||||||
|
|
||||||
static PyNumberMethods long_as_number = {
|
static PyNumberMethods long_as_number = {
|
||||||
(binaryfunc) long_add, /*nb_add*/
|
(binaryfunc)long_add, /*nb_add*/
|
||||||
(binaryfunc) long_sub, /*nb_subtract*/
|
(binaryfunc)long_sub, /*nb_subtract*/
|
||||||
(binaryfunc) long_mul, /*nb_multiply*/
|
(binaryfunc)long_mul, /*nb_multiply*/
|
||||||
long_mod, /*nb_remainder*/
|
long_mod, /*nb_remainder*/
|
||||||
long_divmod, /*nb_divmod*/
|
long_divmod, /*nb_divmod*/
|
||||||
long_pow, /*nb_power*/
|
long_pow, /*nb_power*/
|
||||||
(unaryfunc) long_neg, /*nb_negative*/
|
(unaryfunc)long_neg, /*nb_negative*/
|
||||||
(unaryfunc) long_long, /*tp_positive*/
|
(unaryfunc)long_long, /*tp_positive*/
|
||||||
(unaryfunc) long_abs, /*tp_absolute*/
|
(unaryfunc)long_abs, /*tp_absolute*/
|
||||||
(inquiry) long_bool, /*tp_bool*/
|
(inquiry)long_bool, /*tp_bool*/
|
||||||
(unaryfunc) long_invert, /*nb_invert*/
|
(unaryfunc)long_invert, /*nb_invert*/
|
||||||
long_lshift, /*nb_lshift*/
|
long_lshift, /*nb_lshift*/
|
||||||
(binaryfunc) long_rshift, /*nb_rshift*/
|
(binaryfunc)long_rshift, /*nb_rshift*/
|
||||||
long_and, /*nb_and*/
|
long_and, /*nb_and*/
|
||||||
long_xor, /*nb_xor*/
|
long_xor, /*nb_xor*/
|
||||||
long_or, /*nb_or*/
|
long_or, /*nb_or*/
|
||||||
long_long, /*nb_int*/
|
long_long, /*nb_int*/
|
||||||
0, /*nb_reserved*/
|
0, /*nb_reserved*/
|
||||||
long_float, /*nb_float*/
|
long_float, /*nb_float*/
|
||||||
0, /* nb_inplace_add */
|
0, /* nb_inplace_add */
|
||||||
0, /* nb_inplace_subtract */
|
0, /* nb_inplace_subtract */
|
||||||
0, /* nb_inplace_multiply */
|
0, /* nb_inplace_multiply */
|
||||||
0, /* nb_inplace_remainder */
|
0, /* nb_inplace_remainder */
|
||||||
0, /* nb_inplace_power */
|
0, /* nb_inplace_power */
|
||||||
0, /* nb_inplace_lshift */
|
0, /* nb_inplace_lshift */
|
||||||
0, /* nb_inplace_rshift */
|
0, /* nb_inplace_rshift */
|
||||||
0, /* nb_inplace_and */
|
0, /* nb_inplace_and */
|
||||||
0, /* nb_inplace_xor */
|
0, /* nb_inplace_xor */
|
||||||
0, /* nb_inplace_or */
|
0, /* nb_inplace_or */
|
||||||
long_div, /* nb_floor_divide */
|
long_div, /* nb_floor_divide */
|
||||||
long_true_divide, /* nb_true_divide */
|
long_true_divide, /* nb_true_divide */
|
||||||
0, /* nb_inplace_floor_divide */
|
0, /* nb_inplace_floor_divide */
|
||||||
0, /* nb_inplace_true_divide */
|
0, /* nb_inplace_true_divide */
|
||||||
long_long, /* nb_index */
|
long_long, /* nb_index */
|
||||||
};
|
};
|
||||||
|
|
||||||
PyTypeObject PyLong_Type = {
|
PyTypeObject PyLong_Type = {
|
||||||
|
@ -4722,8 +4722,7 @@ internal representation of integers. The attributes are read only.");
|
||||||
|
|
||||||
static PyStructSequence_Field int_info_fields[] = {
|
static PyStructSequence_Field int_info_fields[] = {
|
||||||
{"bits_per_digit", "size of a digit in bits"},
|
{"bits_per_digit", "size of a digit in bits"},
|
||||||
{"sizeof_digit", "size in bytes of the C type used to "
|
{"sizeof_digit", "size in bytes of the C type used to represent a digit"},
|
||||||
"represent a digit"},
|
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue