Re: [PATCH python 11/14] override: Conditionalize use of PyString_Check and PyInt_Check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange <berrange@xxxxxxxxxx> wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
>
> The PyString and PyInt classes are gone in Python 3, so we must
> conditionalize their use to be Python 2 only.
>
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  libvirt-override.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/libvirt-override.c b/libvirt-override.c
> index 9a013ca..77c0af2 100644
> --- a/libvirt-override.c
> +++ b/libvirt-override.c
> @@ -322,7 +322,11 @@ virPyDictToTypedParams(PyObject *dict,
>          }
>
>          if (type == -1) {
> +#if PY_MAJOR_VERSION > 2
> +            if (PyUnicode_Check(value)) {
> +#else
>              if (PyString_Check(value)) {
> +#endif
>                  type = VIR_TYPED_PARAM_STRING;
>              } else if (PyBool_Check(value)) {
>                  type = VIR_TYPED_PARAM_BOOLEAN;
> @@ -332,11 +336,13 @@ virPyDictToTypedParams(PyObject *dict,
>                      type = VIR_TYPED_PARAM_LLONG;
>                  else
>                      type = VIR_TYPED_PARAM_ULLONG;
> +#if PY_MAJOR_VERSION == 2

Every where else in your other patches you did PY_MAJOR_VERSION < 3,
but its not like we're going to support Python 1 but just a note on
inconsistency.

>              } else if (PyInt_Check(value)) {
>                  if (PyInt_AS_LONG(value) < 0)
>                      type = VIR_TYPED_PARAM_LLONG;
>                  else
>                      type = VIR_TYPED_PARAM_ULLONG;
> +#endif
>              } else if (PyFloat_Check(value)) {
>                  type = VIR_TYPED_PARAM_DOUBLE;
>              }
> --
> 1.8.3.1
>
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

ACK.

-- 
Doug Goldstein

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]