diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2010-06-01 17:14:30 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2010-06-01 17:14:30 +0200 |
| commit | 015acac98dc88fbbca5672c6be678c8dea491a8e (patch) | |
| tree | ea4c6b4a385aa25d96746886589f2928e58891af | |
| parent | e74ead9f918b38bfe8ae5cfe941df4057dcc509e (diff) | |
| download | python-apt-015acac98dc88fbbca5672c6be678c8dea491a8e.tar.gz | |
revert commit 346 (this re-enable the deprecation warnings)
| -rw-r--r-- | apt/__init__.py | 5 | ||||
| -rw-r--r-- | apt/deprecation.py | 13 | ||||
| -rw-r--r-- | apt/package.py | 2 | ||||
| -rw-r--r-- | apt/progress/old.py | 25 | ||||
| -rw-r--r-- | debian/changelog | 4 | ||||
| -rw-r--r-- | python/acquire-item.cc | 7 | ||||
| -rw-r--r-- | python/acquire.cc | 5 | ||||
| -rw-r--r-- | python/apt_pkgmodule.cc | 5 | ||||
| -rw-r--r-- | python/cache.cc | 17 | ||||
| -rw-r--r-- | python/cdrom.cc | 12 | ||||
| -rw-r--r-- | python/depcache.cc | 19 | ||||
| -rw-r--r-- | python/generic.cc | 3 | ||||
| -rw-r--r-- | python/generic.h | 1 | ||||
| -rw-r--r-- | python/pkgmanager.cc | 7 | ||||
| -rw-r--r-- | python/pkgrecords.cc | 7 | ||||
| -rw-r--r-- | python/pkgsrcrecords.cc | 7 | ||||
| -rw-r--r-- | python/sourcelist.cc | 7 | ||||
| -rw-r--r-- | python/tag.cc | 14 |
18 files changed, 68 insertions, 92 deletions
diff --git a/apt/__init__.py b/apt/__init__.py index a8a8b8fc..8b66ad13 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -17,6 +17,11 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +import os +import warnings +if not "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: + warnings.simplefilter('ignore', DeprecationWarning) + # import the core of apt_pkg """High-Level Interface for working with apt.""" import apt_pkg diff --git a/apt/deprecation.py b/apt/deprecation.py index cd33a51b..0f39ad63 100644 --- a/apt/deprecation.py +++ b/apt/deprecation.py @@ -24,7 +24,6 @@ not use it for anything outside the apt package. """ import re import operator -import os import warnings import apt_pkg @@ -50,14 +49,12 @@ class AttributeDeprecatedBy(object): """Issue a DeprecationWarning and return the requested value.""" if obj is None: return getattr(type_, self.attribute, self) - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) + warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) return self.getter(obj or type_) def __set__(self, obj, value): """Issue a DeprecationWarning and set the requested value.""" - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) + warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) setattr(obj, self.attribute, value) @@ -74,8 +71,7 @@ def function_deprecated_by(func, convert_names=True): def deprecated_function(*args, **kwds): """Wrapper around a deprecated function.""" - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn(warning, DeprecationWarning, stacklevel=2) + warnings.warn(warning, DeprecationWarning, stacklevel=2) if convert_names: for key in kwds.keys(): kwds[re.sub('([A-Z])', '_\\1', key).lower()] = kwds.pop(key) @@ -97,8 +93,7 @@ def deprecated_args(func): for key in kwds.keys(): new_key = re.sub('([A-Z])', '_\\1', key).lower() if new_key != key: - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("Deprecated parameter %r" % key) + warnings.warn("Deprecated parameter %r" % key) kwds[new_key] = kwds.pop(key) return func(*args, **kwds) diff --git a/apt/package.py b/apt/package.py index 7dcead02..228a3385 100644 --- a/apt/package.py +++ b/apt/package.py @@ -120,7 +120,7 @@ class DeprecatedProperty(property): self.__doc__ = (doc or fget.__doc__ or '') def __get__(self, obj, type_=None): - if obj is not None and "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: + if obj is not None: warnings.warn("Accessed deprecated property %s.%s, please see the " "Version class for alternatives." % ((obj.__class__.__name__ or type_.__name__), diff --git a/apt/progress/old.py b/apt/progress/old.py index 2d3fdb59..4bd79f2e 100644 --- a/apt/progress/old.py +++ b/apt/progress/old.py @@ -42,9 +42,8 @@ class OpProgress(base.OpProgress): def __init__(self): base.OpProgress.__init__(self) - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("apt.progress.OpProgress is deprecated.", - DeprecationWarning, stacklevel=2) + warnings.warn("apt.progress.OpProgress is deprecated.", + DeprecationWarning, stacklevel=2) subOp = AttributeDeprecatedBy('subop') Op = AttributeDeprecatedBy('op') @@ -55,9 +54,8 @@ class OpTextProgress(OpProgress, text.OpProgress): def __init__(self): text.OpProgress.__init__(self) - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("apt.progress.OpTextProgress is deprecated.", - DeprecationWarning, stacklevel=2) + warnings.warn("apt.progress.OpTextProgress is deprecated.", + DeprecationWarning, stacklevel=2) class FetchProgress(object): @@ -77,9 +75,8 @@ class FetchProgress(object): self.totalBytes = 0 self.totalItems = 0 self.currentCPS = 0 - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("apt.progress.FetchProgress is deprecated.", - DeprecationWarning, stacklevel=2) + warnings.warn("apt.progress.FetchProgress is deprecated.", + DeprecationWarning, stacklevel=2) def start(self): """Called when the fetching starts.""" @@ -178,9 +175,8 @@ class CdromProgress(object): """Report the cdrom add progress.""" def __init__(self): - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("apt.progress.CdromProgress is deprecated.", - DeprecationWarning, stacklevel=2) + warnings.warn("apt.progress.CdromProgress is deprecated.", + DeprecationWarning, stacklevel=2) def askCdromName(self): """Ask for a cdrom name""" @@ -197,9 +193,8 @@ class DumbInstallProgress(base.InstallProgress): def __init__(self): base.InstallProgress.__init__(self) - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("apt.progress.*InstallProgress are deprecated.", - DeprecationWarning, stacklevel=2) + warnings.warn("apt.progress.*InstallProgress are deprecated.", + DeprecationWarning, stacklevel=2) def updateInterface(self): # *_stream were not available in the old progress reporting classes, diff --git a/debian/changelog b/debian/changelog index fd9632ce..ae937e41 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -python-apt (0.7.95ubuntu1) maverick; urgency=low +python-apt (0.7.95ubuntu1) UNRELEASEDmaverick; urgency=low * merge from debian bzr, remaining changes: - different mirror list - + * revert commit 346 (this re-enable the deprecation warnings) * data/templates/gNewSense.info.in, data/templates/gNewSense.mirrors: - add gNewSense template and mirrors, thanks to Karl Goetz diff --git a/python/acquire-item.cc b/python/acquire-item.cc index e94ea352..4b7dc34d 100644 --- a/python/acquire-item.cc +++ b/python/acquire-item.cc @@ -320,10 +320,9 @@ char *doc_GetPkgAcqFile = "GetPkgAcqFile(pkgAquire, uri[, md5, size, descr, shortDescr, destDir, destFile]) -> PkgAcqFile\n"; PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgAcqFile() is " - "deprecated. Please see apt_pkg.AcquireFile() for the " - "replacement", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgAcqFile() is " + "deprecated. Please see apt_pkg.AcquireFile() for the " + "replacement", 1); PyObject *pyfetcher; char *uri, *md5, *descr, *shortDescr, *destDir, *destFile; int size = 0; diff --git a/python/acquire.cc b/python/acquire.cc index 1d750f37..6f9a1412 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -404,9 +404,8 @@ PyTypeObject PyAcquire_Type = { #ifdef COMPAT_0_7 PyObject *GetAcquire(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetAcquire() is deprecated." - " Please see apt_pkg.Acquire() for the replacement.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetAcquire() is deprecated." + " Please see apt_pkg.Acquire() for the replacement.", 1); return PkgAcquireNew(&PyAcquire_Type,Args,0); } #endif diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index c6353fcc..a1e9ada0 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -54,9 +54,8 @@ static PyObject *py_gettext(PyObject *self, PyObject *Args) { static char *doc_newConfiguration = "Construct a configuration instance"; static PyObject *newConfiguration(PyObject *self,PyObject *args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.newConfiguration() is " - "deprecated. Use apt_pkg.Configuration() instead.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.newConfiguration() is " + "deprecated. Use apt_pkg.Configuration() instead.", 1); return CppPyObject_NEW<Configuration*>(NULL, &PyConfiguration_Type, new Configuration()); } #endif diff --git a/python/cache.cc b/python/cache.cc index b0cfb469..e31f6a65 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -120,9 +120,8 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args) #ifdef COMPAT_0_7 static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "Cache.Close() is deprecated, " - "because it causes segfaults. Delete the Cache instead.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "Cache.Close() is deprecated, " + "because it causes segfaults. Delete the Cache instead.", 1); PyObject *CacheFilePy = GetOwner<pkgCache*>(Self); pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy); Cache->Close(); @@ -133,10 +132,9 @@ static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args) static PyObject *PkgCacheOpen(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "Cache.Open() is deprecated, " - "because it causes memory leaks. Create a new Cache instead.", - 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "Cache.Open() is deprecated, " + "because it causes memory leaks. Create a new Cache instead.", + 1); PyObject *CacheFilePy = GetOwner<pkgCache*>(Self); pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy); @@ -1478,9 +1476,8 @@ PyTypeObject PyDependencyList_Type = #ifdef COMPAT_0_7 PyObject *TmpGetCache(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCache() is deprecated. " - "Please see apt_pkg.Cache() for the replacement.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCache() is deprecated. " + "Please see apt_pkg.Cache() for the replacement.", 1); return PkgCacheNew(&PyCache_Type,Args,0); } #endif diff --git a/python/cdrom.cc b/python/cdrom.cc index e6cc8e29..7f89e9d3 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -81,10 +81,9 @@ static PyObject *cdrom_ident(PyObject *Self,PyObject *Args) #ifdef COMPAT_0_7 static PyObject *cdrom_ident_old(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "Method 'Ident' of the " - "'apt_pkg.Cdrom' object is deprecated, use 'ident' instead.", - 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "Method 'Ident' of the " + "'apt_pkg.Cdrom' object is deprecated, use 'ident' instead.", + 1); pkgCdrom &Cdrom = GetCpp<pkgCdrom>(Self); PyObject *pyCdromProgressInst = 0; @@ -169,9 +168,8 @@ PyTypeObject PyCdrom_Type = { #ifdef COMPAT_0_7 PyObject *GetCdrom(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCdrom() is deprecated. " - "Please see apt_pkg.Cdrom() for the replacement.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCdrom() is deprecated. " + "Please see apt_pkg.Cdrom() for the replacement.", 1); return cdrom_new(&PyCdrom_Type,Args,0); } #endif diff --git a/python/depcache.cc b/python/depcache.cc index e7d7d946..cd098f2f 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -766,9 +766,8 @@ PyTypeObject PyDepCache_Type = #ifdef COMPAT_0_7 PyObject *GetDepCache(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetDepCache() is deprecated" - ". Please see apt_pkg.DepCache() for the replacement.",1); + PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetDepCache() is deprecated" + ". Please see apt_pkg.DepCache() for the replacement.",1); return PkgDepCacheNew(&PyDepCache_Type,Args,0); } #endif @@ -801,10 +800,9 @@ static PyObject *PkgProblemResolverNew(PyTypeObject *type,PyObject *Args,PyObjec #ifdef COMPAT_0_7 PyObject *GetPkgProblemResolver(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgProblemResolver() is" - " deprecated. Please see apt_pkg.ProblemResolver() for the " - "replacement.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgProblemResolver() is" + " deprecated. Please see apt_pkg.ProblemResolver() for the " + "replacement.", 1); return PkgProblemResolverNew(&PyProblemResolver_Type,Args,0); } #endif @@ -1093,10 +1091,9 @@ PyTypeObject PyActionGroup_Type = #ifdef COMPAT_0_7 PyObject *GetPkgActionGroup(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgActionGroup() is " - "deprecated. Please see apt_pkg.ActionGroup() for the " - "replacement.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgActionGroup() is " + "deprecated. Please see apt_pkg.ActionGroup() for the " + "replacement.", 1); return PkgActionGroupNew(&PyActionGroup_Type,Args,0); } #endif diff --git a/python/generic.cc b/python/generic.cc index 0719d1bb..e04743ff 100644 --- a/python/generic.cc +++ b/python/generic.cc @@ -102,8 +102,7 @@ PyObject *_PyAptObject_getattro(PyObject *self, PyObject *attr) { strlen(attrname) + 66]; sprintf(warning_string, "Attribute '%s' of the '%s' object is " "deprecated, use '%s' instead.", attrname, cls, newattrname); - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, warning_string, 1); + PyErr_WarnEx(PyExc_DeprecationWarning, warning_string, 1); delete[] warning_string; } else { Py_XINCREF(ptype); diff --git a/python/generic.h b/python/generic.h index 98c6d82b..31c1bc2d 100644 --- a/python/generic.h +++ b/python/generic.h @@ -31,7 +31,6 @@ #include <string> #include <iostream> #include <new> -#include <cstdlib> #if PYTHON_API_VERSION < 1013 typedef int Py_ssize_t; diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index df66c8c7..95e8c27e 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -39,10 +39,9 @@ static PyObject *PkgManagerNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) #ifdef COMPAT_0_7 PyObject *GetPkgManager(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPackageManager() is " - "deprecated. Please see apt_pkg.PackageManager() for the " - "replacement.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPackageManager() is " + "deprecated. Please see apt_pkg.PackageManager() for the " + "replacement.", 1); return PkgManagerNew(&PyPackageManager_Type,Args,0); } #endif diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index efa99b62..8d2cb502 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -221,10 +221,9 @@ PyTypeObject PyPackageRecords_Type = #ifdef COMPAT_0_7 PyObject *GetPkgRecords(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgRecords() is " - "deprecated. Please see apt_pkg.Records() for the " - "replacement.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgRecords() is " + "deprecated. Please see apt_pkg.Records() for the " + "replacement.", 1); return PkgRecordsNew(&PyPackageRecords_Type,Args,0); } #endif diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index da3d0e04..aad3ef7e 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -317,10 +317,9 @@ PyTypeObject PySourceRecords_Type = #ifdef COMPAT_0_7 PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSrcRecords() is " - "deprecated. Please see apt_pkg.SourceRecords() for the " - "replacement.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSrcRecords() is " + "deprecated. Please see apt_pkg.SourceRecords() for the " + "replacement.", 1); if (PyArg_ParseTuple(Args,"") == 0) return 0; diff --git a/python/sourcelist.cc b/python/sourcelist.cc index b04bf5cb..784b161e 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -171,10 +171,9 @@ PyTypeObject PySourceList_Type = #ifdef COMPAT_0_7 PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSourceList() is " - "deprecated. Please see apt_pkg.SourceList() for the " - "replacement.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSourceList() is " + "deprecated. Please see apt_pkg.SourceList() for the " + "replacement.", 1); return PkgSourceListNew(&PySourceList_Type,Args,0); } #endif diff --git a/python/tag.cc b/python/tag.cc index 5db34c1d..9fe12a1a 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -371,10 +371,9 @@ static PyObject *TagSecNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { char *doc_ParseSection = "ParseSection(Text) -> TagSection()\n\nDeprecated."; PyObject *ParseSection(PyObject *self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseSection() is " - "deprecated. Please see apt_pkg.TagSection() for the " - "replacement.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseSection() is " + "deprecated. Please see apt_pkg.TagSection() for the " + "replacement.", 1); return TagSecNew(&PyTagSection_Type,Args,0); } #endif @@ -411,10 +410,9 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) #ifdef COMPAT_0_7 char *doc_ParseTagFile = "ParseTagFile(file) -> TagFile()\n\nDeprecated."; PyObject *ParseTagFile(PyObject *self,PyObject *Args) { - if (getenv("PYTHON_APT_DEPRECATION_WARNINGS") != NULL) - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseTagFile() is " - "deprecated. Please see apt_pkg.TagFile() for the " - "replacement.", 1); + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseTagFile() is " + "deprecated. Please see apt_pkg.TagFile() for the " + "replacement.", 1); return TagFileNew(&PyTagFile_Type,Args,0); } #endif |
