diff options
Diffstat (limited to 'Python/ceval.c')
| -rw-r--r-- | Python/ceval.c | 76 | 
1 files changed, 66 insertions, 10 deletions
| diff --git a/Python/ceval.c b/Python/ceval.c index 7656b8e..e09ff34 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1504,6 +1504,18 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)              DISPATCH();          } +        TARGET(BINARY_MATRIX_MULTIPLY) { +            PyObject *right = POP(); +            PyObject *left = TOP(); +            PyObject *res = PyNumber_MatrixMultiply(left, right); +            Py_DECREF(left); +            Py_DECREF(right); +            SET_TOP(res); +            if (res == NULL) +                goto error; +            DISPATCH(); +        } +          TARGET(BINARY_TRUE_DIVIDE) {              PyObject *divisor = POP();              PyObject *dividend = TOP(); @@ -1694,6 +1706,18 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)              DISPATCH();          } +        TARGET(INPLACE_MATRIX_MULTIPLY) { +            PyObject *right = POP(); +            PyObject *left = TOP(); +            PyObject *res = PyNumber_InPlaceMatrixMultiply(left, right); +            Py_DECREF(left); +            Py_DECREF(right); +            SET_TOP(res); +            if (res == NULL) +                goto error; +            DISPATCH(); +        } +          TARGET(INPLACE_TRUE_DIVIDE) {              PyObject *divisor = POP();              PyObject *dividend = TOP(); @@ -3387,10 +3411,11 @@ too_many_positional(PyCodeObject *co, int given, int defcount, PyObject **fastlo     PyEval_EvalFrame() and PyEval_EvalCodeEx() you will need to adjust     the test in the if statements in Misc/gdbinit (pystack and pystackv). */ -PyObject * -PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals, +static PyObject * +_PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,             PyObject **args, int argcount, PyObject **kws, int kwcount, -           PyObject **defs, int defcount, PyObject *kwdefs, PyObject *closure) +           PyObject **defs, int defcount, PyObject *kwdefs, PyObject *closure, +           PyObject *name, PyObject *qualname)  {      PyCodeObject* co = (PyCodeObject*)_co;      PyFrameObject *f; @@ -3582,7 +3607,7 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals,          /* Create a new generator that owns the ready to run frame           * and return that as the value. */ -        return PyGen_New(f); +        return PyGen_NewWithQualName(f, name, qualname);      }      retval = PyEval_EvalFrameEx(f,0); @@ -3601,6 +3626,16 @@ fail: /* Jump here from prelude on failure */      return retval;  } +PyObject * +PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals, +           PyObject **args, int argcount, PyObject **kws, int kwcount, +           PyObject **defs, int defcount, PyObject *kwdefs, PyObject *closure) +{ +    return _PyEval_EvalCodeWithName(_co, globals, locals, +                                    args, argcount, kws, kwcount, +                                    defs, defcount, kwdefs, closure, +                                    NULL, NULL); +}  static PyObject *  special_lookup(PyObject *o, _Py_Identifier *id) @@ -4299,6 +4334,8 @@ fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk)      PyObject *globals = PyFunction_GET_GLOBALS(func);      PyObject *argdefs = PyFunction_GET_DEFAULTS(func);      PyObject *kwdefs = PyFunction_GET_KW_DEFAULTS(func); +    PyObject *name = ((PyFunctionObject *)func) -> func_name; +    PyObject *qualname = ((PyFunctionObject *)func) -> func_qualname;      PyObject **d = NULL;      int nd = 0; @@ -4341,10 +4378,11 @@ fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk)          d = &PyTuple_GET_ITEM(argdefs, 0);          nd = Py_SIZE(argdefs);      } -    return PyEval_EvalCodeEx((PyObject*)co, globals, -                             (PyObject *)NULL, (*pp_stack)-n, na, -                             (*pp_stack)-2*nk, nk, d, nd, kwdefs, -                             PyFunction_GET_CLOSURE(func)); +    return _PyEval_EvalCodeWithName((PyObject*)co, globals, +                                    (PyObject *)NULL, (*pp_stack)-n, na, +                                    (*pp_stack)-2*nk, nk, d, nd, kwdefs, +                                    PyFunction_GET_CLOSURE(func), +                                    name, qualname);  }  static PyObject * @@ -4658,11 +4696,29 @@ static PyObject *  import_from(PyObject *v, PyObject *name)  {      PyObject *x; +    _Py_IDENTIFIER(__name__); +    PyObject *fullmodname, *pkgname;      x = PyObject_GetAttr(v, name); -    if (x == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) { +    if (x != NULL || !PyErr_ExceptionMatches(PyExc_AttributeError)) +        return x; +    /* Issue #17636: in case this failed because of a circular relative +       import, try to fallback on reading the module directly from +       sys.modules. */ +    PyErr_Clear(); +    pkgname = _PyObject_GetAttrId(v, &PyId___name__); +    if (pkgname == NULL) +        return NULL; +    fullmodname = PyUnicode_FromFormat("%U.%U", pkgname, name); +    Py_DECREF(pkgname); +    if (fullmodname == NULL) +        return NULL; +    x = PyDict_GetItem(PyImport_GetModuleDict(), fullmodname); +    if (x == NULL)          PyErr_Format(PyExc_ImportError, "cannot import name %R", name); -    } +    else +        Py_INCREF(x); +    Py_DECREF(fullmodname);      return x;  } | 
