diff options
author | Julian Andres Klode <jak@debian.org> | 2015-06-10 11:26:51 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2015-06-10 11:27:53 +0200 |
commit | 71e5ac2cc7d08de11e4adddd4f8fbd26a04cfd73 (patch) | |
tree | 9f41deb824a4a5ea738a36e765a2916468d6c882 | |
parent | 47bbca79a52b04a6fed39c53b9e6a98350e95695 (diff) | |
download | python-apt-71e5ac2cc7d08de11e4adddd4f8fbd26a04cfd73.tar.gz |
python/cache.cc: Handle deprecation of pkgCache::PkgIterator::Section()
Ignore the deprecation from the C++ compiler and generate a warning for
the Python interpreter. Also, remove the section from the representation
of the package.
-rw-r--r-- | python/cache.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/python/cache.cc b/python/cache.cc index c0f1eded..17ccc252 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -596,7 +596,16 @@ PyTypeObject PyGroupList_Type = MkGet(PackageGetName,PyString_FromString(Pkg.Name())) MkGet(PackageGetArch,PyString_FromString(Pkg.Arch())) -MkGet(PackageGetSection,Safe_FromString(Pkg.Section())) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +static PyObject *PackageGetSection(PyObject *Self,void*) +{ + pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(Self); + if (PyErr_WarnEx(PyExc_DeprecationWarning, "Package.section is deprecated, use Version.section instead", 1) == -1) + return NULL; + return Safe_FromString(Pkg.Section()); +} +#pragma GCC diagnostic pop MkGet(PackageGetRevDependsList,CppPyObject_NEW<RDepListStruct>(Owner, &PyDependencyList_Type, Pkg.RevDependsList())) MkGet(PackageGetProvidesList,CreateProvides(Owner,Pkg.ProvidesList())) @@ -728,11 +737,8 @@ static PyGetSetDef PackageGetSet[] = { static PyObject *PackageRepr(PyObject *Self) { pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(Self); - - return PyString_FromFormat("<%s object: name:'%s' section: " - "'%s' id:%u>", Self->ob_type->tp_name, - Pkg.Name(), (Pkg.Section() ? Pkg.Section() : ""), - Pkg->ID); + return PyString_FromFormat("<%s object: name:'%s' id:%u>", Self->ob_type->tp_name, + Pkg.Name(), Pkg->ID); } static const char *package_doc = |