]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
mgr/BaseMgrModule: use PyInt_Check() to compatible with py2
authorKefu Chai <kchai@redhat.com>
Fri, 23 Aug 2019 02:36:44 +0000 (10:36 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 23 Aug 2019 14:30:22 +0000 (22:30 +0800)
commitb0ce0b4e139e9eea5629929e8e0b5a7b22dcf8a2
tree9378ea59af7c4a1a22abd464e2a89239fac94a64
parentf61b0a21d6dd14d449122b70c5e8b3dd49eb33ac
mgr/BaseMgrModule: use PyInt_Check() to compatible with py2

in python2, we have both `PyLongObject` and `PyIntObject` for presenting
`long` and `int` types. and in python3, `PyIntObject` is dropped, `int`
is represented using `PyLongObject`. and the related functions like
`PyInt_Check()` and `PyInt_AsLong()` are removed along with
`PyIntObject`.

so we should use different set of functions for converting an `int` python
object to native type in C++. since we don't use `long` for "count" when
calling `MgrModule.set_health_checks()`, in this change, we just define
a macro to unify the difference between python2 and python3.

the same applies to "max_count" parameter of `MgrModule.add_osd_perf_query()`
call.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mgr/BaseMgrModule.cc
src/mgr/PythonCompat.h