mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
style: pre-commit fixes
This commit is contained in:
parent
efbd12c6a5
commit
655708f434
@ -149,39 +149,39 @@ public:
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if !defined(PYPY_VERSION)
|
#if !defined(PYPY_VERSION)
|
||||||
auto index_check = [](PyObject *o) { return PyIndex_Check(o); };
|
auto index_check = [](PyObject *o) { return PyIndex_Check(o); };
|
||||||
#else
|
#else
|
||||||
// In PyPy 7.3.3, `PyIndex_Check` is implemented by calling `__index__`,
|
// In PyPy 7.3.3, `PyIndex_Check` is implemented by calling `__index__`,
|
||||||
// while CPython only considers the existence of `nb_index`/`__index__`.
|
// while CPython only considers the existence of `nb_index`/`__index__`.
|
||||||
auto index_check = [](PyObject *o) { return hasattr(o, "__index__"); };
|
auto index_check = [](PyObject *o) { return hasattr(o, "__index__"); };
|
||||||
#endif
|
#endif
|
||||||
if (PyFloat_Check(src.ptr())
|
if (PyFloat_Check(src.ptr())
|
||||||
|| (!convert && !PYBIND11_LONG_CHECK(src.ptr()) && !index_check(src.ptr()))) {
|
|| (!convert && !PYBIND11_LONG_CHECK(src.ptr()) && !index_check(src.ptr()))) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle src_or_index = src;
|
|
||||||
// PyPy: 7.3.7's 3.8 does not implement PyLong_*'s __index__ calls.
|
|
||||||
#if defined(PYPY_VERSION)
|
|
||||||
object index;
|
|
||||||
if (!PYBIND11_LONG_CHECK(src.ptr())) { // So: index_check(src.ptr())
|
|
||||||
index = reinterpret_steal<object>(PyNumber_Index(src.ptr()));
|
|
||||||
if (!index) {
|
|
||||||
PyErr_Clear();
|
|
||||||
if (!convert)
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
src_or_index = index;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
handle src_or_index = src;
|
||||||
|
// PyPy: 7.3.7's 3.8 does not implement PyLong_*'s __index__ calls.
|
||||||
|
#if defined(PYPY_VERSION)
|
||||||
|
object index;
|
||||||
|
if (!PYBIND11_LONG_CHECK(src.ptr())) { // So: index_check(src.ptr())
|
||||||
|
index = reinterpret_steal<object>(PyNumber_Index(src.ptr()));
|
||||||
|
if (!index) {
|
||||||
|
PyErr_Clear();
|
||||||
|
if (!convert)
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
src_or_index = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if PYBIND11_IF_CONSTEXPR (std::is_unsigned<py_type>::value) {
|
if PYBIND11_IF_CONSTEXPR (std::is_unsigned<py_type>::value) {
|
||||||
py_value = as_unsigned<py_type>(src_or_index.ptr());
|
py_value = as_unsigned<py_type>(src_or_index.ptr());
|
||||||
} else { // signed integer:
|
} else { // signed integer:
|
||||||
py_value = sizeof(T) <= sizeof(long)
|
py_value = sizeof(T) <= sizeof(long)
|
||||||
? (py_type) PyLong_AsLong(src_or_index.ptr())
|
? (py_type) PyLong_AsLong(src_or_index.ptr())
|
||||||
: (py_type) PYBIND11_LONG_AS_LONGLONG(src_or_index.ptr());
|
: (py_type) PYBIND11_LONG_AS_LONGLONG(src_or_index.ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Python API reported an error
|
// Python API reported an error
|
||||||
|
@ -2011,7 +2011,7 @@ inline str enum_name(handle arg) {
|
|||||||
struct enum_base {
|
struct enum_base {
|
||||||
enum_base(const handle &base, const handle &parent) : m_base(base), m_parent(parent) {}
|
enum_base(const handle &base, const handle &parent) : m_base(base), m_parent(parent) {}
|
||||||
|
|
||||||
template<bool is_arithmetic, bool is_convertible>
|
template <bool is_arithmetic, bool is_convertible>
|
||||||
PYBIND11_NOINLINE void init() {
|
PYBIND11_NOINLINE void init() {
|
||||||
m_base.attr("__entries") = dict();
|
m_base.attr("__entries") = dict();
|
||||||
auto property = handle((PyObject *) &PyProperty_Type);
|
auto property = handle((PyObject *) &PyProperty_Type);
|
||||||
|
Loading…
Reference in New Issue
Block a user