未验证 提交 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;
} }
if (std::string(((PyTypeObject*)(*obj)->ob_type)->tp_name) // NOLINT
.find("numpy") != std::string::npos) {
auto to = PyNumber_Long(*obj); auto to = PyNumber_Long(*obj);
if (to) { if (to) {
*obj = to; *obj = to;
return true; return true;
} }
}
return false; return false;
} }
...@@ -223,11 +228,14 @@ inline bool PyObject_CheckFloatOrToFloat(PyObject** obj) { ...@@ -223,11 +228,14 @@ 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;
} }
if (std::string(((PyTypeObject*)(*obj)->ob_type)->tp_name) // NOLINT
.find("numpy") != std::string::npos) {
auto to = PyNumber_Float(*obj); auto to = PyNumber_Float(*obj);
if (to) { if (to) {
*obj = to; *obj = to;
return true; return true;
} }
}
return false; return false;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册