未验证 提交 921b0418 编写于 作者: W wanghuancoder 提交者: GitHub

PyNumber_Long only for numpy, test=develop (#33778)

* PyNumber_Long only for numpy, test=develop
上级 6024488d
...@@ -209,11 +209,16 @@ inline bool PyObject_CheckLongOrToLong(PyObject** obj) { ...@@ -209,11 +209,16 @@ inline bool PyObject_CheckLongOrToLong(PyObject** obj) {
PyObject_IsInstance(*obj, (PyObject*)g_varbase_pytype)) { // NOLINT PyObject_IsInstance(*obj, (PyObject*)g_varbase_pytype)) { // NOLINT
return true; return true;
} }
auto to = PyNumber_Long(*obj);
if (to) { if (std::string(((PyTypeObject*)(*obj)->ob_type)->tp_name) // NOLINT
*obj = to; .find("numpy") != std::string::npos) {
return true; auto to = PyNumber_Long(*obj);
if (to) {
*obj = to;
return true;
}
} }
return false; return false;
} }
...@@ -223,10 +228,13 @@ inline bool PyObject_CheckFloatOrToFloat(PyObject** obj) { ...@@ -223,10 +228,13 @@ inline bool PyObject_CheckFloatOrToFloat(PyObject** obj) {
PyObject_IsInstance(*obj, (PyObject*)g_varbase_pytype)) { // NOLINT PyObject_IsInstance(*obj, (PyObject*)g_varbase_pytype)) { // NOLINT
return true; return true;
} }
auto to = PyNumber_Float(*obj); if (std::string(((PyTypeObject*)(*obj)->ob_type)->tp_name) // NOLINT
if (to) { .find("numpy") != std::string::npos) {
*obj = to; auto to = PyNumber_Float(*obj);
return true; if (to) {
*obj = to;
return true;
}
} }
return false; return false;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册