def test_numeric_literals(self):
self.same_hash(1, 1, 1.0, 1.0+0.0j)
+ self.same_hash(0, 0.0, 0.0+0.0j)
+ self.same_hash(-1, -1.0, -1.0+0.0j)
+ self.same_hash(-2, -2.0, -2.0+0.0j)
def test_coerced_integers(self):
self.same_hash(int(1), int(1), float(1), complex(1),
int('1'), float('1.0'))
+ self.same_hash(int(-2**31), float(-2**31))
+ self.same_hash(int(1-2**31), float(1-2**31))
+ self.same_hash(int(2**31-1), float(2**31-1))
+ # for 64-bit platforms
+ self.same_hash(int(2**31), float(2**31))
+ self.same_hash(int(-2**63), float(-2**63))
def test_coerced_floats(self):
self.same_hash(int(1.23e300), float(1.23e300))
i = -(i);
}
#define LONG_BIT_PyLong_SHIFT (8*sizeof(long) - PyLong_SHIFT)
+ /* The following loop produces a C long x such that (unsigned long)x
+ is congruent to the absolute value of v modulo ULONG_MAX. The
+ resulting x is nonzero if and only if v is. */
while (--i >= 0) {
/* Force a native long #-bits (32 or 64) circular shift */
x = ((x << PyLong_SHIFT) & ~PyLong_MASK) | ((x >> LONG_BIT_PyLong_SHIFT) & PyLong_MASK);
x += v->ob_digit[i];
+ /* If the addition above overflowed (thinking of x as
+ unsigned), we compensate by incrementing. This preserves
+ the value modulo ULONG_MAX. */
+ if ((unsigned long)x < v->ob_digit[i])
+ x++;
}
#undef LONG_BIT_PyLong_SHIFT
x = x * sign;
Py_SetRecursionLimit(int new_limit)
{
recursion_limit = new_limit;
- _Py_CheckRecursionLimit = recursion_limit;
+ _Py_CheckRecursionLimit = recursion_limit;
}
/* the macro Py_EnterRecursiveCall() only calls _Py_CheckRecursiveCall()
where);
return -1;
}
- _Py_CheckRecursionLimit = recursion_limit;
+ _Py_CheckRecursionLimit = recursion_limit;
return 0;
}
Py_MakePendingCalls() above. */
if (--_Py_Ticker < 0) {
- if (*next_instr == SETUP_FINALLY) {
- /* Make the last opcode before
- a try: finally: block uninterruptable. */
- goto fast_next_opcode;
- }
+ if (*next_instr == SETUP_FINALLY) {
+ /* Make the last opcode before
+ a try: finally: block uninterruptable. */
+ goto fast_next_opcode;
+ }
_Py_Ticker = _Py_CheckInterval;
tstate->tick_counter++;
#ifdef WITH_TSC
}
/* pop frame */
- exit_eval_frame:
+exit_eval_frame:
Py_LeaveRecursiveCall();
tstate->frame = f->f_back;
return PyGen_New(f);
}
- retval = PyEval_EvalFrameEx(f,0);
+ retval = PyEval_EvalFrameEx(f,0);
- fail: /* Jump here from prelude on failure */
+fail: /* Jump here from prelude on failure */
/* decref'ing the frame can cause __del__ methods to get invoked,
which can call back into Python. While we're done with the
*/
assert(tstate != NULL);
++tstate->recursion_depth;
- Py_DECREF(f);
+ Py_DECREF(f);
--tstate->recursion_depth;
return retval;
}
represents a jump backwards, call the trace function.
*/
if ((frame->f_lasti < *instr_lb || frame->f_lasti >= *instr_ub)) {
- int line;
- PyAddrPair bounds;
+ int line;
+ PyAddrPair bounds;
- line = PyCode_CheckLineNumber(frame->f_code, frame->f_lasti,
- &bounds);
- if (line >= 0) {
+ line = PyCode_CheckLineNumber(frame->f_code, frame->f_lasti,
+ &bounds);
+ if (line >= 0) {
frame->f_lineno = line;
result = call_trace(func, obj, frame,
PyTrace_LINE, Py_None);
- }
- *instr_lb = bounds.ap_lower;
- *instr_ub = bounds.ap_upper;
+ }
+ *instr_lb = bounds.ap_lower;
+ *instr_ub = bounds.ap_upper;
}
else if (frame->f_lasti <= *instr_prev) {
result = call_trace(func, obj, frame, PyTrace_LINE, Py_None);
PyObject *value = EXT_POP(*pp_stack);
PyObject *key = EXT_POP(*pp_stack);
if (PyDict_GetItem(kwdict, key) != NULL) {
- PyErr_Format(PyExc_TypeError,
- "%.200s%s got multiple values "
- "for keyword argument '%.200s'",
+ PyErr_Format(PyExc_TypeError,
+ "%.200s%s got multiple values "
+ "for keyword argument '%.200s'",
PyEval_GetFuncName(func),
PyEval_GetFuncDesc(func),
PyUnicode_AsString(key));
PCALL(PCALL_OTHER);
#endif
result = PyObject_Call(func, callargs, kwdict);
- ext_call_fail:
+ext_call_fail:
Py_XDECREF(callargs);
Py_XDECREF(kwdict);
Py_XDECREF(stararg);