1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| 1/0
# LOAD_CONST 0 # LOAD_CONST 1 # BINARY_DIVIDE
[BINARY_DIVIDE] w = POP(); v = TOP(); x = PyNumber_Divide(v,w); Py_DECREF(v); Py_DECREF(w); SET_TOP(x); if( x != NULL) continue; break;
[intobject.c] static PyObject* int_classic_div(PyIntObject* x, PyIntObject* y){ long xi,yi; long d,m; CONVERT_TO_LONG(x,xi); CONVERT_TO_LONG(y,yi); switch (i_divmod(xi,yi,&d,&m)) { case DIVMOD_OK: return PyInt_FromLong(d); case DIVMODE_OVERFLOW: return PyLong_Type.tp_as_number->nb_divide((PyObject *)x. (PyObject *)y); default: return NULL; } }
[intobject.c]
enum divmod_result{ DIVMOD_OK, DIVMOD_OVERFLOW, DIVMOD_ERROR }
static enum divmod_result i_divmod(register long x, register long y, long* p_xdivy, long* p_xmody){ long xdivy,xmody; if(y == 0){ PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); return DIVMOD_ERROR; } ... }
|