Commit 84370f29 authored by Boxiang Sun's avatar Boxiang Sun

add PyNumber_Negtive support

parent a5474b1c
...@@ -1730,8 +1730,15 @@ extern "C" PyObject* PyNumber_Power(PyObject* v, PyObject* w, PyObject* z) noexc ...@@ -1730,8 +1730,15 @@ extern "C" PyObject* PyNumber_Power(PyObject* v, PyObject* w, PyObject* z) noexc
} }
extern "C" PyObject* PyNumber_Negative(PyObject* o) noexcept { extern "C" PyObject* PyNumber_Negative(PyObject* o) noexcept {
fatalOrError(PyExc_NotImplementedError, "unimplemented"); PyNumberMethods* m;
return nullptr;
if (o == NULL)
return null_error();
m = o->cls->tp_as_number;
if (m && m->nb_negative)
return (*m->nb_negative)(o);
return type_error("bad operand type for unary -: '%.200s'", o);
} }
extern "C" PyObject* PyNumber_Positive(PyObject* o) noexcept { extern "C" PyObject* PyNumber_Positive(PyObject* o) noexcept {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment