]> git.ipfire.org Git - thirdparty/libvirt.git/commit
python: keep consistent handling of Python integer conversion
authorGuannan Ren <gren@redhat.com>
Fri, 28 Sep 2012 12:29:03 +0000 (20:29 +0800)
committerGuannan Ren <gren@redhat.com>
Mon, 8 Oct 2012 13:54:06 +0000 (21:54 +0800)
commit283f1c4aef8736d61c3965874a837537fea05dbc
tree3c768b8bd6021f40c48247c450de2d885bc526df
parent2832663f597adb0fc06770a92f3826e8129b408c
python: keep consistent handling of Python integer conversion

libvirt_ulonglongUnwrap requires the integer type of python obj.
But libvirt_longlongUnwrap still could handle python obj of
Pyfloat_type which causes the float value to be rounded up
to an integer.

For example
 >>> dom.setSchedulerParameters({'vcpu_quota': 0.88})
 0
libvirt_longlongUnwrap treats 0.88 as a valid value 0

However
 >>> dom.setSchedulerParameters({'cpu_shares': 1000.22})
libvirt_ulonglongUnwrap will throw out an error
"TypeError: an integer is required"

The patch make this consistent.
python/typewrappers.c