1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2024-10-26 07:55:06 +03:00

Drop support for python 2

python2 will be end of life by the time of the next
libvirt release. All our supported build targets, including
CentOS7, have a python3 build available.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2019-12-04 10:27:36 +00:00
parent e3fa4f22d5
commit b22e4f2441
26 changed files with 71 additions and 381 deletions

View File

@ -3,7 +3,6 @@ os: linux
dist: xenial
python:
- 2.7
- 3.6
env:

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# consolecallback - provide a persistent console that survives guest reboots
import sys, os, logging, libvirt, tty, termios, atexit

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# netdhcpleases - print leases info for given virtual network
import libvirt

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# dominfo - print some information about a domain
import libvirt

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# domipaddrs - print domain interfaces along with their MAC and IP addresses
import libvirt

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# domstart - make sure a given domU is running, if not start it
import libvirt

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# domstart - make sure a given domU is running, if not start it
import libvirt

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# domstart - make sure a given domU is running, if not start it
import libvirt

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# esxlist - list active domains of an ESX host and print some info.
# also demonstrates how to use the libvirt.openAuth() method

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
#
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import libvirt
import threading

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import libvirt
import sys

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Print some host NUMA node statistics
#
# Authors:

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Example of sparse streams usage
#
# Authors:

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Parse topology information from the capabilities XML and use
# them to calculate host topology
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# generate python wrappers from the XML API description
#

View File

@ -4,13 +4,13 @@
* entry points where an automatically generated stub is
* unpractical
*
* Copyright (C) 2012-2013 Red Hat, Inc.
* Copyright (C) 2012-2019 Red Hat, Inc.
*
* Daniel Veillard <veillard@redhat.com>
*/
/* Horrible kludge to work around even more horrible name-space pollution
via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
via Python.h. That file includes /usr/include/python3.x/pyconfig*.h,
which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
#undef HAVE_PTHREAD_H
@ -21,19 +21,11 @@
#include "libvirt-utils.h"
#include "build/libvirt-lxc.h"
#if PY_MAJOR_VERSION > 2
#ifndef __CYGWIN__
extern PyObject *PyInit_libvirtmod_lxc(void);
#else
extern PyObject *PyInit_cygvirtmod_lxc(void);
#endif
#else
# ifndef __CYGWIN__
extern void initlibvirtmod_lxc(void);
# else
extern void initcygvirtmod_lxc(void);
# endif
#endif
#if 0
# define DEBUG_ERROR 1
@ -107,7 +99,6 @@ static PyMethodDef libvirtLxcMethods[] = {
{NULL, NULL, 0, NULL}
};
#if PY_MAJOR_VERSION > 2
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
#ifndef __CYGWIN__
@ -141,25 +132,3 @@ PyInit_cygvirtmod_lxc
return module;
}
#else /* ! PY_MAJOR_VERSION > 2 */
void
# ifndef __CYGWIN__
initlibvirtmod_lxc
# else
initcygvirtmod_lxc
# endif
(void)
{
if (virInitialize() < 0)
return;
/* initialize the python extension module */
Py_InitModule((char *)
# ifndef __CYGWIN__
"libvirtmod_lxc",
# else
"cygvirtmod_lxc",
# endif
libvirtLxcMethods);
}
#endif /* ! PY_MAJOR_VERSION > 2 */

View File

@ -4,13 +4,13 @@
* entry points where an automatically generated stub is
* unpractical
*
* Copyright (C) 2005, 2007-2015 Red Hat, Inc.
* Copyright (C) 2005-2019 Red Hat, Inc.
*
* Daniel Veillard <veillard@redhat.com>
*/
/* Horrible kludge to work around even more horrible name-space pollution
via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
via Python.h. That file includes /usr/include/python3.x/pyconfig*.h,
which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
#undef HAVE_PTHREAD_H
@ -25,19 +25,11 @@
#include "build/libvirt.h"
#include "libvirt-utils.h"
#if PY_MAJOR_VERSION > 2
#ifndef __CYGWIN__
extern PyObject *PyInit_libvirtmod(void);
#else
extern PyObject *PyInit_cygvirtmod(void);
#endif
#else
# ifndef __CYGWIN__
extern void initlibvirtmod(void);
# else
extern void initcygvirtmod(void);
# endif
#endif
#if 0
# define DEBUG_ERROR 1
@ -10553,7 +10545,6 @@ static PyMethodDef libvirtMethods[] = {
{NULL, NULL, 0, NULL}
};
#if PY_MAJOR_VERSION > 2
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
#ifndef __CYGWIN__
@ -10587,25 +10578,3 @@ PyInit_cygvirtmod
return module;
}
#else /* ! PY_MAJOR_VERSION > 2 */
void
# ifndef __CYGWIN__
initlibvirtmod
# else
initcygvirtmod
# endif
(void)
{
if (virInitialize() < 0)
return;
/* initialize the python extension module */
Py_InitModule((char *)
# ifndef __CYGWIN__
"libvirtmod",
# else
"cygvirtmod",
# endif
libvirtMethods);
}
#endif /* ! PY_MAJOR_VERSION > 2 */

View File

@ -12,26 +12,7 @@
%define supported_platform 0
%endif
%define _with_python2 1
%if 0%{?fedora} > 30 || 0%{?rhel} > 7
%define _with_python2 0
%endif
%define _with_python3 0
%if 0%{?fedora} || 0%{?rhel} > 7
%define _with_python3 1
%endif
# Whether py2 packages are assumed to have python2- name prefix
%define py2_versioned_deps 0
%if 0%{?fedora} || 0%{?rhel} > 7
%define py2_versioned_deps 1
%endif
%{!?with_python2: %define with_python2 %{_with_python2}}
%{!?with_python3: %define with_python3 %{_with_python3}}
Summary: The libvirt virtualization API python2 binding
Summary: The libvirt virtualization API python3 binding
Name: libvirt-python
Version: @PY_VERSION@
Release: 1%{?dist}
@ -39,31 +20,13 @@ Source0: http://libvirt.org/sources/python/%{name}-%{version}.tar.gz
Url: http://libvirt.org
License: LGPLv2+
BuildRequires: libvirt-devel == %{version}
%if %{with_python2}
%if %{py2_versioned_deps}
BuildRequires: python2-devel
BuildRequires: python2-nose
BuildRequires: python2-lxml
%else
BuildRequires: python-devel
BuildRequires: python-nose
BuildRequires: python-lxml
%endif
%endif
%if %{with_python3}
BuildRequires: python3-devel
BuildRequires: python3-nose
BuildRequires: python3-lxml
%endif
BuildRequires: gcc
# Don't want provides for python shared objects
%if %{with_python2}
%{?filter_provides_in: %filter_provides_in %{python2_sitearch}/.*\.so}
%endif
%if %{with_python3}
%{?filter_provides_in: %filter_provides_in %{python3_sitearch}/.*\.so}
%endif
%{?filter_setup}
%description
@ -72,23 +35,6 @@ written in the Python programming language to use the interface
supplied by the libvirt library to use the virtualization capabilities
of recent versions of Linux (and other OSes).
%if %{with_python2}
%package -n python2-libvirt
Summary: The libvirt virtualization API python2 binding
Url: http://libvirt.org
License: LGPLv2+
%{?python_provide:%python_provide python2-libvirt}
Provides: libvirt-python = %{version}-%{release}
Obsoletes: libvirt-python <= 3.6.0-1%{?dist}
%description -n python2-libvirt
The python2-libvirt package contains a module that permits applications
written in the Python programming language to use the interface
supplied by the libvirt library to use the virtualization capabilities
of recent versions of Linux (and other OSes).
%endif
%if %{with_python3}
%package -n python3-libvirt
Summary: The libvirt virtualization API python3 binding
Url: http://libvirt.org
@ -99,16 +45,15 @@ Obsoletes: libvirt-python3 <= 3.6.0-1%{?dist}
%description -n python3-libvirt
The python3-libvirt package contains a module that permits applications
written in the Python programming language to use the interface
written in the Python 3.x programming language to use the interface
supplied by the libvirt library to use the virtualization capabilities
of recent versions of Linux (and other OSes).
%endif
%prep
%setup -q
# Unset execute bit for example scripts; it can introduce spurious
# RPM dependencies, like /usr/bin/python which can pull in python2
# RPM dependencies, like /usr/bin/python3
# for the -python3 package
find examples -type f -exec chmod 0644 \{\} \;
@ -118,56 +63,22 @@ echo "This RPM requires either Fedora >= %{min_fedora} or RHEL >= %{min_rhel}"
exit 1
%endif
%if %{with_python2}
%if 0%{?fedora} || 0%{?rhel} >= 8
%py2_build
%else
CFLAGS="$RPM_OPT_FLAGS" %{__python2} setup.py build
%endif
%endif
%if %{with_python3}
%if 0%{?fedora} || 0%{?rhel} >= 8
%py3_build
%else
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
%endif
%endif
%install
%if %{with_python2}
%if 0%{?fedora} || 0%{?rhel} >= 8
%py2_install
%else
%{__python2} setup.py install --skip-build --root=%{buildroot}
%endif
%endif
%if %{with_python3}
%if 0%{?fedora} || 0%{?rhel} >= 8
%py3_install
%else
%{__python3} setup.py install --skip-build --root=%{buildroot}
%endif
%endif
%check
%if %{with_python2}
%{__python2} setup.py test
%endif
%if %{with_python3}
%{__python3} setup.py test
%endif
%if %{with_python2}
%files -n python2-libvirt
%doc ChangeLog AUTHORS NEWS README COPYING COPYING.LESSER examples/
%{python2_sitearch}/libvirt.py*
%{python2_sitearch}/libvirt_qemu.py*
%{python2_sitearch}/libvirt_lxc.py*
%{python2_sitearch}/libvirtmod*
%{python2_sitearch}/*egg-info
%endif
%if %{with_python3}
%files -n python3-libvirt
%doc ChangeLog AUTHORS NEWS README COPYING COPYING.LESSER examples/
%{python3_sitearch}/libvirt.py*
@ -180,6 +91,5 @@ CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
%{python3_sitearch}/__pycache__/libvirtaio.cpython-*.py*
%{python3_sitearch}/libvirtmod*
%{python3_sitearch}/*egg-info
%endif
%changelog

View File

@ -4,13 +4,13 @@
* entry points where an automatically generated stub is
* unpractical
*
* Copyright (C) 2011-2014 Red Hat, Inc.
* Copyright (C) 2011-2019 Red Hat, Inc.
*
* Daniel Veillard <veillard@redhat.com>
*/
/* Horrible kludge to work around even more horrible name-space pollution
via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
via Python.h. That file includes /usr/include/python3.x/pyconfig*.h,
which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
#undef HAVE_PTHREAD_H
@ -21,19 +21,11 @@
#include "libvirt-utils.h"
#include "build/libvirt-qemu.h"
#if PY_MAJOR_VERSION > 2
#ifndef __CYGWIN__
extern PyObject *PyInit_libvirtmod_qemu(void);
#else
extern PyObject *PyInit_cygvirtmod_qemu(void);
#endif
#else
# ifndef __CYGWIN__
extern void initlibvirtmod_qemu(void);
# else
extern void initcygvirtmod_qemu(void);
# endif
#endif
#if 0
# define DEBUG_ERROR 1
@ -351,7 +343,6 @@ static PyMethodDef libvirtQemuMethods[] = {
{NULL, NULL, 0, NULL}
};
#if PY_MAJOR_VERSION > 2
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
#ifndef __CYGWIN__
@ -385,25 +376,3 @@ PyInit_cygvirtmod_qemu
return module;
}
#else /* ! PY_MAJOR_VERSION > 2 */
void
# ifndef __CYGWIN__
initlibvirtmod_qemu
# else
initcygvirtmod_qemu
# endif
(void)
{
if (virInitialize() < 0)
return;
/* initialize the python extension module */
Py_InitModule((char *)
# ifndef __CYGWIN__
"libvirtmod_qemu",
# else
"cygvirtmod_qemu",
# endif
libvirtQemuMethods);
}
#endif /* ! PY_MAJOR_VERSION > 2 */

View File

@ -1,7 +1,7 @@
/*
* libvirt-utils.c: misc helper APIs for python binding
*
* Copyright (C) 2013 Red Hat, Inc.
* Copyright (C) 2013-2019 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -274,11 +274,7 @@ setPyVirTypedParameter(PyObject *info,
int nparams)
{
PyObject *key, *value;
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
int pos = 0;
#else
Py_ssize_t pos = 0;
#endif
virTypedParameterPtr temp = NULL, ret = NULL;
Py_ssize_t size;
ssize_t i;
@ -416,13 +412,6 @@ virPyDictToTypedParamOne(virTypedParameterPtr *params,
type = VIR_TYPED_PARAM_LLONG;
else
type = VIR_TYPED_PARAM_ULLONG;
#if PY_MAJOR_VERSION < 3
} 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;
}
@ -520,11 +509,7 @@ virPyDictToTypedParams(PyObject *dict,
{
PyObject *key;
PyObject *value;
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
int pos = 0;
#else
Py_ssize_t pos = 0;
#endif
virTypedParameterPtr params = NULL;
int n = 0;
int max = 0;

View File

@ -139,11 +139,7 @@ int virReallocN(void *ptrptr, size_t size, size_t count)
void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
# if PY_MAJOR_VERSION > 2
# define libvirt_PyString_Check PyUnicode_Check
# else
# define libvirt_PyString_Check PyString_Check
# endif
#define VIR_N_ELEMENTS(array) (sizeof(array) / sizeof(*(array)))

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys
import lxml

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from distutils.core import setup, Extension, Command
from distutils.command.build import build
@ -17,6 +17,10 @@ import re
import shutil
import time
if sys.version_info[0] != 3:
print("libvirt-python requires Python 3.x to build")
sys.exit(1)
MIN_LIBVIRT = "0.9.11"
MIN_LIBVIRT_LXC = "1.0.2"
@ -341,7 +345,7 @@ setup(name = 'libvirt-python',
description = 'The libvirt virtualization API python binding',
long_description =
'''The libvirt-python package provides a module that permits applications
written in the Python programming language to call the interface
written in the Python 3.x programming language to call the interface
supplied by the libvirt library, to manage the virtualization capabilities
of recent versions of Linux (and other OSes).''',
license = 'LGPLv2+',
@ -362,7 +366,6 @@ of recent versions of Linux (and other OSes).''',
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
]
)

View File

@ -2,141 +2,88 @@
* types.c: converter functions between the internal representation
* and the Python objects
*
* Copyright (C) 2005, 2007, 2012 Red Hat, Inc.
* Copyright (C) 2005-2019 Red Hat, Inc.
*
* Daniel Veillard <veillard@redhat.com>
*/
/* Horrible kludge to work around even more horrible name-space pollution
* via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
* via Python.h. That file includes /usr/include/python3.x/pyconfig*.h,
* which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
#undef HAVE_PTHREAD_H
#include "typewrappers.h"
#include "libvirt-utils.h"
#ifndef Py_CAPSULE_H
typedef void(*PyCapsule_Destructor)(void *, void *);
#endif
static PyObject *
libvirt_buildPyObject(void *cobj,
const char *name,
PyCapsule_Destructor destr)
{
PyObject *ret;
#ifdef Py_CAPSULE_H
ret = PyCapsule_New(cobj, name, destr);
#else
ret = PyCObject_FromVoidPtrAndDesc(cobj, (void *) name, destr);
#endif /* _TEST_CAPSULE */
return ret;
return PyCapsule_New(cobj, name, destr);
}
PyObject *
libvirt_intWrap(int val)
{
PyObject *ret;
#if PY_MAJOR_VERSION > 2
ret = PyLong_FromLong((long) val);
#else
ret = PyInt_FromLong((long) val);
#endif
return ret;
return PyLong_FromLong((long) val);
}
PyObject *
libvirt_uintWrap(uint val)
{
PyObject *ret;
#if PY_MAJOR_VERSION > 2
ret = PyLong_FromLong((long) val);
#else
ret = PyInt_FromLong((long) val);
#endif
return ret;
return PyLong_FromLong((long) val);
}
PyObject *
libvirt_longWrap(long val)
{
PyObject *ret;
ret = PyLong_FromLong(val);
return ret;
return PyLong_FromLong(val);
}
PyObject *
libvirt_ulongWrap(unsigned long val)
{
PyObject *ret;
ret = PyLong_FromLong(val);
return ret;
return PyLong_FromLong(val);
}
PyObject *
libvirt_longlongWrap(long long val)
{
PyObject *ret;
ret = PyLong_FromLongLong(val);
return ret;
return PyLong_FromLongLong(val);
}
PyObject *
libvirt_ulonglongWrap(unsigned long long val)
{
PyObject *ret;
ret = PyLong_FromUnsignedLongLong(val);
return ret;
return PyLong_FromUnsignedLongLong(val);
}
PyObject *
libvirt_charPtrSizeWrap(char *str, Py_ssize_t size)
{
PyObject *ret;
if (str == NULL) {
return VIR_PY_NONE;
}
#if PY_MAJOR_VERSION > 2
ret = PyBytes_FromStringAndSize(str, size);
#else
ret = PyString_FromStringAndSize(str, size);
#endif
return ret;
return PyBytes_FromStringAndSize(str, size);
}
PyObject *
libvirt_charPtrWrap(char *str)
{
PyObject *ret;
if (str == NULL) {
return VIR_PY_NONE;
}
#if PY_MAJOR_VERSION > 2
ret = PyUnicode_FromString(str);
#else
ret = PyString_FromString(str);
#endif
return ret;
return PyUnicode_FromString(str);
}
PyObject *
libvirt_constcharPtrWrap(const char *str)
{
PyObject *ret;
if (str == NULL) {
return VIR_PY_NONE;
}
#if PY_MAJOR_VERSION > 2
ret = PyUnicode_FromString(str);
#else
ret = PyString_FromString(str);
#endif
return ret;
return PyUnicode_FromString(str);
}
PyObject *
@ -163,11 +110,7 @@ libvirt_intUnwrap(PyObject *obj,
* to C long type directly. If it is of PyLong_Type, PyInt_AsLong
* will call PyLong_AsLong() to deal with it automatically.
*/
#if PY_MAJOR_VERSION > 2
long_val = PyLong_AsLong(obj);
#else
long_val = PyInt_AsLong(obj);
#endif
if ((long_val == -1) && PyErr_Occurred())
return -1;
@ -196,11 +139,7 @@ libvirt_uintUnwrap(PyObject *obj,
return -1;
}
#if PY_MAJOR_VERSION > 2
long_val = PyLong_AsLong(obj);
#else
long_val = PyInt_AsLong(obj);
#endif
if ((long_val == -1) && PyErr_Occurred())
return -1;
@ -269,14 +208,7 @@ libvirt_longlongUnwrap(PyObject *obj,
return -1;
}
#if PY_MAJOR_VERSION == 2
/* If obj is of PyInt_Type, PyLong_AsLongLong
* will call PyInt_AsLong() to handle it automatically.
*/
if (PyInt_Check(obj) || PyLong_Check(obj))
#else
if (PyLong_Check(obj))
#endif
llong_val = PyLong_AsLongLong(obj);
else
PyErr_SetString(PyExc_TypeError, "an integer is required");
@ -299,21 +231,7 @@ libvirt_ulonglongUnwrap(PyObject *obj,
return -1;
}
#if PY_MAJOR_VERSION == 2
/* The PyLong_AsUnsignedLongLong doesn't check the type of
* obj, only accept argument of PyLong_Type, so we check it instead.
*/
if (PyInt_Check(obj)) {
long long llong_val = PyInt_AsLong(obj);
if (llong_val < 0)
PyErr_SetString(PyExc_OverflowError,
"negative Python int cannot be converted to C unsigned long long");
else
ullong_val = llong_val;
} else if (PyLong_Check(obj)) {
#else
if (PyLong_Check(obj)) {
#endif
ullong_val = PyLong_AsUnsignedLongLong(obj);
} else {
PyErr_SetString(PyExc_TypeError, "an integer is required");
@ -367,9 +285,7 @@ int
libvirt_charPtrUnwrap(PyObject *obj,
char **str)
{
#if PY_MAJOR_VERSION > 2
PyObject *bytes;
#endif
const char *ret;
*str = NULL;
if (!obj) {
@ -377,21 +293,15 @@ libvirt_charPtrUnwrap(PyObject *obj,
return -1;
}
#if PY_MAJOR_VERSION > 2
if (!(bytes = PyUnicode_AsUTF8String(obj)))
return -1;
ret = PyBytes_AsString(bytes);
#else
ret = PyString_AsString(obj);
#endif
if (ret) {
*str = strdup(ret);
if (!*str)
PyErr_NoMemory();
}
#if PY_MAJOR_VERSION > 2
Py_DECREF(bytes);
#endif
return ret && *str ? 0 : -1;
}
@ -400,10 +310,6 @@ libvirt_charPtrSizeUnwrap(PyObject *obj,
char **str,
Py_ssize_t *size)
{
int ret;
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
int isize;
#endif
*str = NULL;
*size = 0;
if (!obj) {
@ -411,18 +317,7 @@ libvirt_charPtrSizeUnwrap(PyObject *obj,
return -1;
}
#if PY_MAJOR_VERSION > 2
ret = PyBytes_AsStringAndSize(obj, str, size);
#else
# if PY_MINOR_VERSION <= 4
ret = PyString_AsStringAndSize(obj, str, &isize);
*size = isize;
# else
ret = PyString_AsStringAndSize(obj, str, size);
# endif
#endif
return ret;
return PyBytes_AsStringAndSize(obj, str, size);
}
PyObject *

View File

@ -22,11 +22,6 @@
# define ATTRIBUTE_UNUSED
#endif
/* Work around really old python. */
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
typedef ssize_t Py_ssize_t;
#endif
#if !LIBVIR_CHECK_VERSION(4, 5, 0)
typedef struct _virNWFilterBinding *virNWFilterBindingPtr;
#endif