summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2010-02-27 17:31:39 +0100
committerJulian Andres Klode <jak@debian.org>2010-02-27 17:31:39 +0100
commita169fd15520d61303639c0dfa2aabec3f6446fb6 (patch)
tree7e791c9c63df5bddae36c4734164a24618bc95b0 /python
parent523c71a6c9b722804c65efdb79daafc56248488f (diff)
downloadpython-apt-a169fd15520d61303639c0dfa2aabec3f6446fb6.tar.gz
* python:
- Handle deprecated attributes and methods in the tp_gettattro slot, this allows us to easily warn if a deprecated function is used.
Diffstat (limited to 'python')
-rw-r--r--python/acquire-item.cc13
-rw-r--r--python/acquire.cc12
-rw-r--r--python/cache.cc88
-rw-r--r--python/cdrom.cc8
-rw-r--r--python/configuration.cc16
-rw-r--r--python/depcache.cc46
-rw-r--r--python/generic.cc62
-rw-r--r--python/generic.h6
-rw-r--r--python/indexfile.cc13
-rw-r--r--python/metaindex.cc8
-rw-r--r--python/pkgmanager.cc7
-rw-r--r--python/pkgrecords.cc19
-rw-r--r--python/pkgsrcrecords.cc14
-rw-r--r--python/sourcelist.cc10
-rw-r--r--python/tag.cc19
15 files changed, 93 insertions, 248 deletions
diff --git a/python/acquire-item.cc b/python/acquire-item.cc
index d5f9ad10..09f0d643 100644
--- a/python/acquire-item.cc
+++ b/python/acquire-item.cc
@@ -128,17 +128,6 @@ static PyGetSetDef acquireitem_getset[] = {
{"is_trusted",acquireitem_get_is_trusted},
{"local",acquireitem_get_local},
{"status",acquireitem_get_status},
-#ifdef COMPAT_0_7
- {"Complete",acquireitem_get_complete},
- {"DescURI",acquireitem_get_desc_uri},
- {"DestFile",acquireitem_get_destfile},
- {"ErrorText",acquireitem_get_error_text},
- {"FileSize",acquireitem_get_filesize},
- {"ID",acquireitem_get_id},
- {"IsTrusted",acquireitem_get_is_trusted},
- {"Local",acquireitem_get_local},
- {"Status",acquireitem_get_status},
-#endif
{}
};
@@ -180,7 +169,7 @@ PyTypeObject PyAcquireItem_Type = {
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT |
diff --git a/python/acquire.cc b/python/acquire.cc
index 5e22280e..cc9ee310 100644
--- a/python/acquire.cc
+++ b/python/acquire.cc
@@ -229,10 +229,6 @@ static PyObject *PkgAcquireShutdown(PyObject *Self,PyObject *Args)
static PyMethodDef PkgAcquireMethods[] = {
{"run",PkgAcquireRun,METH_VARARGS,"Run the fetcher"},
{"shutdown",PkgAcquireShutdown, METH_VARARGS,"Shutdown the fetcher"},
-#ifdef COMPAT_0_7
- {"Run",PkgAcquireRun,METH_VARARGS,"Run the fetcher"},
- {"Shutdown",PkgAcquireShutdown, METH_VARARGS,"Shutdown the fetcher"},
-#endif
{}
};
@@ -284,12 +280,6 @@ static PyGetSetDef PkgAcquireGetSet[] = {
{"workers",PkgAcquireGetWorkers},
{"partial_present",PkgAcquireGetPartialPresent},
{"total_needed",PkgAcquireGetTotalNeeded},
-#ifdef COMPAT_0_7
- {"FetchNeeded",PkgAcquireGetFetchNeeded},
- {"Items",PkgAcquireGetItems},
- {"PartialPresent",PkgAcquireGetPartialPresent},
- {"TotalNeeded",PkgAcquireGetTotalNeeded},
-#endif
{}
};
@@ -354,7 +344,7 @@ PyTypeObject PyAcquire_Type = {
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
(Py_TPFLAGS_DEFAULT | // tp_flags
diff --git a/python/cache.cc b/python/cache.cc
index 5743d9df..3c9bc785 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -153,7 +153,6 @@ static PyMethodDef PkgCacheMethods[] =
{
{"update",PkgCacheUpdate,METH_VARARGS,"Update the cache"},
#ifdef COMPAT_0_7
- {"Update",PkgCacheUpdate,METH_VARARGS,"Update the cache"},
{"Open", PkgCacheOpen, METH_VARARGS,"Open the cache"},
{"Close", PkgCacheClose, METH_VARARGS,"Close the cache"},
#endif
@@ -216,16 +215,6 @@ static PyGetSetDef PkgCacheGetSet[] = {
{"provides_count",PkgCacheGetProvidesCount},
{"ver_file_count",PkgCacheGetVerFileCount},
{"version_count",PkgCacheGetVersionCount},
-#ifdef COMPAT_0_7
- {"DependsCount",PkgCacheGetDependsCount},
- {"FileList",PkgCacheGetFileList},
- {"PackageCount",PkgCacheGetPackageCount},
- {"PackageFileCount",PkgCacheGetPackageFileCount},
- {"Packages",PkgCacheGetPackages},
- {"ProvidesCount",PkgCacheGetProvidesCount},
- {"VerFileCount",PkgCacheGetVerFileCount},
- {"VersionCount",PkgCacheGetVersionCount},
-#endif
{}
};
@@ -349,7 +338,7 @@ PyTypeObject PyCache_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
(Py_TPFLAGS_DEFAULT | // tp_flags
@@ -543,21 +532,6 @@ static PyGetSetDef PackageGetSet[] = {
{"important",PackageGetImportant},
{"version_list",PackageGetVersionList},
{"current_ver",PackageGetCurrentVer},
- #ifdef COMPAT_0_7
- {"Name",PackageGetName},
- {"Section",PackageGetSection},
- {"RevDependsList",PackageGetRevDependsList},
- {"ProvidesList",PackageGetProvidesList},
- {"SelectedState",PackageGetSelectedState},
- {"InstState",PackageGetInstState},
- {"CurrentState",PackageGetCurrentState},
- {"ID",PackageGetID},
- {"Auto",PackageGetAuto},
- {"Essential",PackageGetEssential},
- {"Important",PackageGetImportant},
- {"VersionList",PackageGetVersionList},
- {"CurrentVer",PackageGetCurrentVer},
- #endif
{}
};
@@ -590,7 +564,7 @@ PyTypeObject PyPackage_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags
@@ -641,10 +615,6 @@ static PyGetSetDef DescriptionGetSet[] = {
{"language_code",DescriptionGetLanguageCode},
{"md5",DescriptionGetMd5},
{"file_list",DescriptionGetFileList},
- #ifdef COMPAT_0_7
- {"LanguageCode",DescriptionGetLanguageCode},
- {"FileList",DescriptionGetFileList},
- #endif
{}
};
@@ -675,7 +645,7 @@ PyTypeObject PyDescription_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags
@@ -886,24 +856,6 @@ static PyGetSetDef VersionGetSet[] = {
{"size",VersionGetSize},
{"translated_description",VersionGetTranslatedDescription},
{"ver_str",VersionGetVerStr},
-#ifdef COMPAT_0_7
- {"Arch",VersionGetArch},
- {"DependsList",VersionGetDependsList},
- {"DependsListStr",VersionGetDependsListStr},
- {"Downloadable",VersionGetDownloadable},
- {"FileList",VersionGetFileList},
- {"Hash",VersionGetHash},
- {"ID",VersionGetID},
- {"InstalledSize",VersionGetInstalledSize},
- {"ParentPkg",VersionGetParentPkg},
- {"Priority",VersionGetPriority},
- {"PriorityStr",VersionGetPriorityStr},
- {"ProvidesList",VersionGetProvidesList},
- {"Section",VersionGetSection},
- {"Size",VersionGetSize},
- {"TranslationDescription",VersionGetTranslatedDescription},
- {"VerStr",VersionGetVerStr},
-#endif
{}
};
@@ -926,7 +878,7 @@ PyTypeObject PyVersion_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags
@@ -1053,21 +1005,6 @@ static PyGetSetDef PackageFileGetSet[] = {
{(char*)"site",PackageFile_GetSite},
{(char*)"size",PackageFile_GetSize},
{(char*)"version",PackageFile_GetVersion},
- #ifdef COMPAT_0_7
- {"Architecture",PackageFile_GetArchitecture},
- {"Archive",PackageFile_GetArchive},
- {"Component",PackageFile_GetComponent},
- {"FileName",PackageFile_GetFileName},
- {"ID",PackageFile_GetID},
- {"IndexType",PackageFile_GetIndexType},
- {"Label",PackageFile_GetLabel},
- {"NotAutomatic",PackageFile_GetNotAutomatic},
- {"NotSource",PackageFile_GetNotSource},
- {"Origin",PackageFile_GetOrigin},
- {"Site",PackageFile_GetSite},
- {"Size",PackageFile_GetSize},
- {"Version",PackageFile_GetVersion},
- #endif
{}
};
@@ -1088,7 +1025,7 @@ PyTypeObject PyPackageFile_Type = {
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags
@@ -1158,10 +1095,6 @@ static PyMethodDef DependencyMethods[] =
{
{"smart_target_pkg",DepSmartTargetPkg,METH_VARARGS,"Returns the natural Target or None"},
{"all_targets",DepAllTargets,METH_VARARGS,"Returns all possible Versions that match this dependency"},
-#ifdef COMPAT_0_7
- {"SmartTargetPkg",DepSmartTargetPkg,METH_VARARGS,"Returns the natural Target or None"},
- {"AllTargets",DepAllTargets,METH_VARARGS,"Returns all possible Versions that match this dependency"},
-#endif
{}
};
@@ -1240,15 +1173,6 @@ static PyGetSetDef DependencyGetSet[] = {
{"parent_ver",DependencyGetParentVer},
{"target_pkg",DependencyGetTargetPkg},
{"target_ver",DependencyGetTargetVer},
-#ifdef COMPAT_0_7
- {"CompType",DependencyGetCompType},
- {"DepType",DependencyGetDepType},
- {"ID",DependencyGetID},
- {"ParentPkg",DependencyGetParentPkg},
- {"ParentVer",DependencyGetParentVer},
- {"TargetPkg",DependencyGetTargetPkg},
- {"TargetVer",DependencyGetTargetVer},
-#endif
{}
};
@@ -1272,7 +1196,7 @@ PyTypeObject PyDependency_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags
diff --git a/python/cdrom.cc b/python/cdrom.cc
index 0b9ae578..9eae49dc 100644
--- a/python/cdrom.cc
+++ b/python/cdrom.cc
@@ -78,6 +78,9 @@ static PyObject *cdrom_ident(PyObject *Self,PyObject *Args)
#ifdef COMPAT_0_7
static PyObject *cdrom_ident_old(PyObject *Self,PyObject *Args)
{
+ 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;
@@ -101,8 +104,7 @@ static PyMethodDef cdrom_methods[] = {
{"add",cdrom_add,METH_VARARGS,cdrom_add_doc},
{"ident",cdrom_ident,METH_VARARGS,cdrom_ident_doc},
#ifdef COMPAT_0_7
- {"Add",cdrom_add,METH_VARARGS,"Add(progress) -> Add a cdrom"},
- {"Ident",cdrom_ident_old,METH_VARARGS,"Ident(progress) -> Ident a cdrom"},
+ {"Ident",cdrom_ident_old,METH_VARARGS,"DEPRECATED. DO NOT USE"},
#endif
{}
};
@@ -134,7 +136,7 @@ PyTypeObject PyCdrom_Type = {
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT | // tp_flags
diff --git a/python/configuration.cc b/python/configuration.cc
index 974f6f3d..299e06ec 100644
--- a/python/configuration.cc
+++ b/python/configuration.cc
@@ -446,20 +446,6 @@ static PyMethodDef CnfMethods[] =
{"value_list",CnfValueList,METH_VARARGS,doc_ValueList},
{"my_tag",CnfMyTag,METH_VARARGS,doc_MyTag},
{"clear",CnfClear,METH_VARARGS,doc_Clear},
-#ifdef COMPAT_0_7
- {"Find",CnfFind,METH_VARARGS,doc_Find},
- {"FindFile",CnfFindFile,METH_VARARGS,doc_FindFile},
- {"FindDir",CnfFindDir,METH_VARARGS,doc_FindDir},
- {"FindI",CnfFindI,METH_VARARGS,doc_FindI},
- {"FindB",CnfFindB,METH_VARARGS,doc_FindB},
- {"Set",CnfSet,METH_VARARGS,doc_Set},
- {"Exists",CnfExists,METH_VARARGS,doc_Exists},
- {"SubTree",CnfSubTree,METH_VARARGS,doc_SubTree},
- {"List",CnfList,METH_VARARGS,doc_List},
- {"ValueList",CnfValueList,METH_VARARGS,doc_ValueList},
- {"MyTag",CnfMyTag,METH_VARARGS,doc_MyTag},
- {"Clear",CnfClear,METH_VARARGS,doc_Clear},
-#endif
// Python Special
{"keys",CnfKeys,METH_VARARGS,doc_Keys},
#if PY_MAJOR_VERSION < 3
@@ -498,7 +484,7 @@ PyTypeObject PyConfiguration_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
(Py_TPFLAGS_DEFAULT | // tp_flags
diff --git a/python/depcache.cc b/python/depcache.cc
index 53459c32..8b4e02b5 100644
--- a/python/depcache.cc
+++ b/python/depcache.cc
@@ -569,34 +569,8 @@ static PyMethodDef PkgDepCacheMethods[] =
{"marked_keep",PkgDepCacheMarkedKeep,METH_VARARGS,"Is pkg marked for keep"},
{"marked_reinstall",PkgDepCacheMarkedReinstall,METH_VARARGS,"Is pkg marked for reinstall"},
{"marked_downgrade",PkgDepCacheMarkedDowngrade,METH_VARARGS,"Is pkg marked for downgrade"},
-
// Action
{"commit", PkgDepCacheCommit, METH_VARARGS, "Commit pending changes"},
-#ifdef COMPAT_0_7
- {"Init",PkgDepCacheInit,METH_VARARGS,"Init the depcache (done on construct automatically)"},
- {"GetCandidateVer",PkgDepCacheGetCandidateVer,METH_VARARGS,"Get candidate version"},
- {"SetCandidateVer",PkgDepCacheSetCandidateVer,METH_VARARGS,"Set candidate version"},
- {"Upgrade",PkgDepCacheUpgrade,METH_VARARGS,"Perform Upgrade (optional boolean argument if dist-upgrade should be performed)"},
- {"FixBroken",PkgDepCacheFixBroken,METH_VARARGS,"Fix broken packages"},
- {"ReadPinFile",PkgDepCacheReadPinFile,METH_VARARGS,"Read the pin policy"},
- {"MinimizeUpgrade",PkgDepCacheMinimizeUpgrade, METH_VARARGS,"Go over the entire set of packages and try to keep each package marked for upgrade. If a conflict is generated then the package is restored."},
- {"MarkKeep",PkgDepCacheMarkKeep,METH_VARARGS,"Mark package for keep"},
- {"MarkDelete",PkgDepCacheMarkDelete,METH_VARARGS,"Mark package for delete (optional boolean argument if it should be purged)"},
- {"MarkInstall",PkgDepCacheMarkInstall,METH_VARARGS,"Mark package for Install"},
- {"SetReInstall",PkgDepCacheSetReInstall,METH_VARARGS,"Set if the package should be reinstalled"},
- {"IsUpgradable",PkgDepCacheIsUpgradable,METH_VARARGS,"Is pkg upgradable"},
- {"IsNowBroken",PkgDepCacheIsNowBroken,METH_VARARGS,"Is pkg is now broken"},
- {"IsInstBroken",PkgDepCacheIsInstBroken,METH_VARARGS,"Is pkg broken on the current install"},
- {"IsGarbage",PkgDepCacheIsGarbage,METH_VARARGS,"Is pkg garbage (mark-n-sweep)"},
- {"IsAutoInstalled",PkgDepCacheIsAutoInstalled,METH_VARARGS,"Is pkg marked as auto installed"},
- {"MarkedInstall",PkgDepCacheMarkedInstall,METH_VARARGS,"Is pkg marked for install"},
- {"MarkedUpgrade",PkgDepCacheMarkedUpgrade,METH_VARARGS,"Is pkg marked for upgrade"},
- {"MarkedDelete",PkgDepCacheMarkedDelete,METH_VARARGS,"Is pkg marked for delete"},
- {"MarkedKeep",PkgDepCacheMarkedKeep,METH_VARARGS,"Is pkg marked for keep"},
- {"MarkedReinstall",PkgDepCacheMarkedReinstall,METH_VARARGS,"Is pkg marked for reinstall"},
- {"MarkedDowngrade",PkgDepCacheMarkedDowngrade,METH_VARARGS,"Is pkg marked for downgrade"},
- {"Commit", PkgDepCacheCommit, METH_VARARGS, "Commit pending changes"},
-#endif
{}
};
@@ -641,14 +615,6 @@ static PyGetSetDef PkgDepCacheGetSet[] = {
{"keep_count",PkgDepCacheGetKeepCount},
{"usr_size",PkgDepCacheGetUsrSize},
{"policy",PkgDepCacheGetPolicy},
- #ifdef COMPAT_0_7
- {"BrokenCount",PkgDepCacheGetBrokenCount},
- {"DebSize",PkgDepCacheGetDebSize},
- {"DelCount",PkgDepCacheGetDelCount},
- {"InstCount",PkgDepCacheGetInstCount},
- {"KeepCount",PkgDepCacheGetKeepCount},
- {"UsrSize",PkgDepCacheGetUsrSize},
- #endif
{}
};
@@ -699,7 +665,7 @@ PyTypeObject PyDepCache_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
(Py_TPFLAGS_DEFAULT | // tp_flags
@@ -856,14 +822,6 @@ static PyMethodDef PkgProblemResolverMethods[] =
// Actions
{"resolve", PkgProblemResolverResolve, METH_VARARGS, "Try to intelligently resolve problems by installing and removing packages"},
{"resolve_by_keep", PkgProblemResolverResolveByKeep, METH_VARARGS, "Try to resolv problems only by using keep"},
- #ifdef COMPAT_0_7
- {"Protect", PkgProblemResolverProtect, METH_VARARGS, "Protect(PkgIterator)"},
- {"Remove", PkgProblemResolverRemove, METH_VARARGS, "Remove(PkgIterator)"},
- {"Clear", PkgProblemResolverClear, METH_VARARGS, "Clear(PkgIterator)"},
- {"InstallProtect", PkgProblemResolverInstallProtect, METH_VARARGS, "ProtectInstalled()"},
- {"Resolve", PkgProblemResolverResolve, METH_VARARGS, "Try to intelligently resolve problems by installing and removing packages"},
- {"ResolveByKeep", PkgProblemResolverResolveByKeep, METH_VARARGS, "Try to resolv problems only by using keep"},
- #endif
{}
};
@@ -886,7 +844,7 @@ PyTypeObject PyProblemResolver_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
(Py_TPFLAGS_DEFAULT | // tp_flags
diff --git a/python/generic.cc b/python/generic.cc
index 640f0862..7af34d39 100644
--- a/python/generic.cc
+++ b/python/generic.cc
@@ -48,6 +48,68 @@ PyObject *HandleErrors(PyObject *Res)
PyErr_SetString(PyExc_SystemError,Err.c_str());
return 0;
}
+
+# ifdef COMPAT_0_7
+// Helpers for deprecation.
+
+// Given the name of the old attribute, return the name of the new attribute
+// in a PyObject.
+static PyObject *_PyApt_NewNameForAttribute(const char *attr) {
+ // Some exceptions from the standard algorithm.
+ if (strcasecmp(attr, "FileName") == 0) return PyString_FromString("filename");
+ if (strcasecmp(attr, "DestFile") == 0) return PyString_FromString("destfile");
+ if (strcasecmp(attr, "FileSize") == 0) return PyString_FromString("filesize");
+ if (strcasecmp(attr, "SubTree") == 0) return PyString_FromString("subtree");
+ if (strcasecmp(attr, "ReadPinFile") == 0) return PyString_FromString("read_pinfile");
+ if (strcasecmp(attr, "SetReInstall") == 0) return PyString_FromString("set_reinstall");
+ if (strcasecmp(attr, "URI") == 0) return PyString_FromString("uri");
+ if (strcasecmp(attr, "MD5Hash") == 0) return PyString_FromString("md5_hash");
+ if (strcasecmp(attr, "SHA1Hash") == 0) return PyString_FromString("sha1_hash");
+ if (strcasecmp(attr, "SHA256Hash") == 0) return PyString_FromString("sha256_hash");
+ size_t attrlen = strlen(attr);
+ // Reserve the old name + 5, this should reduce resize to a minimum.
+ string new_name;
+ new_name.reserve(attrlen + 5);
+ for(unsigned int i=0; i < attrlen; i++) {
+ // Replace all uppercase ASCII characters with their lower-case ones.
+ if (attr[i] > 64 && attr[i] < 91) {
+ if (i > 0)
+ new_name += "_";
+ new_name += attr[i] + 32;
+ } else {
+ new_name += attr[i];
+ }
+ }
+ return CppPyString(new_name);
+}
+
+// Handle deprecated attributes by setting a warning and returning the new
+// attribute.
+PyObject *_PyAptObject_getattro(PyObject *self, PyObject *attr) {
+ PyObject *value = PyObject_GenericGetAttr(self, attr);
+ if (value == NULL) {
+ PyObject *ptype, *pvalue, *ptraceback;
+ PyErr_Fetch(&ptype, &pvalue, &ptraceback);
+ const char *attrname = PyObject_AsString(attr);
+ PyObject *newattr = _PyApt_NewNameForAttribute(attrname);
+ value = PyObject_GenericGetAttr(self, newattr);
+ if (value != NULL) {
+ const char *newattrname = PyString_AsString(newattr);
+ const char *cls = self->ob_type->tp_name;
+ char *warning_string = new char[strlen(newattrname) + strlen(cls) +
+ strlen(attrname) + 66];
+ sprintf(warning_string, "Attribute '%s' of the '%s' object is "
+ "deprecated, use '%s' instead.", attrname, cls, newattrname);
+ PyErr_WarnEx(PyExc_DeprecationWarning, warning_string, 1);
+ delete[] warning_string;
+ } else {
+ PyErr_Restore(ptype, pvalue, ptraceback);
+ }
+ Py_DECREF(newattr);
+ }
+ return value;
+}
+# endif //COMPAT_0_7
/*}}}*/
// ListToCharChar - Convert a list to an array of char char /*{{{*/
// ---------------------------------------------------------------------
diff --git a/python/generic.h b/python/generic.h
index 7d2d6d3e..31c1bc2d 100644
--- a/python/generic.h
+++ b/python/generic.h
@@ -227,4 +227,10 @@ PyObject *HandleErrors(PyObject *Res = 0);
const char **ListToCharChar(PyObject *List,bool NullTerm = false);
PyObject *CharCharToList(const char **List,unsigned long Size = 0);
+# ifdef COMPAT_0_7
+PyObject *_PyAptObject_getattro(PyObject *self, PyObject *attr);
+# else
+# define _PyAptObject_getattro 0
+# endif
+
#endif
diff --git a/python/indexfile.cc b/python/indexfile.cc
index e8df9cf2..c6d0b1cc 100644
--- a/python/indexfile.cc
+++ b/python/indexfile.cc
@@ -28,9 +28,6 @@ static PyObject *IndexFileArchiveURI(PyObject *Self,PyObject *Args)
static PyMethodDef IndexFileMethods[] =
{
{"archive_uri",IndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"},
- #ifdef COMPAT_0_7
- {"ArchiveURI",IndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"},
- #endif
{}
};
@@ -76,14 +73,6 @@ static PyGetSetDef IndexFileGetSet[] = {
{"is_trusted",IndexFileGetIsTrusted},
{"label",IndexFileGetLabel},
{"size",IndexFileGetSize},
- #ifdef COMPAT_0_7
- {"Describe",IndexFileGetDescribe},
- {"Exists",IndexFileGetExists},
- {"HasPackages",IndexFileGetHasPackages},
- {"IsTrusted",IndexFileGetIsTrusted},
- {"Label",IndexFileGetLabel},
- {"Size",IndexFileGetSize},
- #endif
{}
};
@@ -107,7 +96,7 @@ PyTypeObject PyIndexFile_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags
diff --git a/python/metaindex.cc b/python/metaindex.cc
index dee54521..2dcade7d 100644
--- a/python/metaindex.cc
+++ b/python/metaindex.cc
@@ -52,12 +52,6 @@ static PyGetSetDef MetaIndexGetSet[] = {
{"index_files",MetaIndexGetIndexFiles},
{"is_trusted",MetaIndexGetIsTrusted},
{"uri",MetaIndexGetURI},
- #ifdef COMPAT_0_7
- {"Dist",MetaIndexGetDist},
- {"IndexFiles",MetaIndexGetIndexFiles},
- {"IsTrusted",MetaIndexGetIsTrusted},
- {"URI",MetaIndexGetURI},
- #endif
{}
};
@@ -91,7 +85,7 @@ PyTypeObject PyMetaIndex_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT, // tp_flags
diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc
index 9b4a9ab7..2fda14ee 100644
--- a/python/pkgmanager.cc
+++ b/python/pkgmanager.cc
@@ -100,11 +100,6 @@ static PyMethodDef PkgManagerMethods[] =
{"get_archives",PkgManagerGetArchives,METH_VARARGS,"Load the selected archives into the fetcher"},
{"do_install",PkgManagerDoInstall,METH_VARARGS,"Do the actual install"},
{"fix_missing",PkgManagerFixMissing,METH_VARARGS,"Fix the install if a pkg couldn't be downloaded"},
-#ifdef COMPAT_0_7
- {"GetArchives",PkgManagerGetArchives,METH_VARARGS,"Load the selected archives into the fetcher"},
- {"DoInstall",PkgManagerDoInstall,METH_VARARGS,"Do the actual install"},
- {"FixMissing",PkgManagerFixMissing,METH_VARARGS,"Fix the install if a pkg couldn't be downloaded"},
-#endif
{}
};
@@ -128,7 +123,7 @@ PyTypeObject PyPackageManager_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
(Py_TPFLAGS_DEFAULT | // tp_flags
diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc
index 1e43b2e8..0e00edcd 100644
--- a/python/pkgrecords.cc
+++ b/python/pkgrecords.cc
@@ -50,9 +50,6 @@ static PyObject *PkgRecordsLookup(PyObject *Self,PyObject *Args)
static PyMethodDef PkgRecordsMethods[] =
{
{"lookup",PkgRecordsLookup,METH_VARARGS,"Changes to a new package"},
- #ifdef COMPAT_0_7
- {"Lookup",PkgRecordsLookup,METH_VARARGS,"Changes to a new package"},
- #endif
{}
};
@@ -132,20 +129,6 @@ static PyGetSetDef PkgRecordsGetSet[] = {
{"short_desc",PkgRecordsGetShortDesc},
{"source_pkg",PkgRecordsGetSourcePkg},
{"source_ver",PkgRecordsGetSourceVer},
-#ifdef COMPAT_0_7
- {"FileName",PkgRecordsGetFileName},
- {"Homepage",PkgRecordsGetHomepage},
- {"LongDesc",PkgRecordsGetLongDesc},
- {"MD5Hash",PkgRecordsGetMD5Hash},
- {"Maintainer",PkgRecordsGetMaintainer},
- {"Name",PkgRecordsGetName},
- {"Record",PkgRecordsGetRecord},
- {"SHA1Hash",PkgRecordsGetSHA1Hash},
- {"SHA256Hash",PkgRecordsGetSHA256Hash},
- {"ShortDesc",PkgRecordsGetShortDesc},
- {"SourcePkg",PkgRecordsGetSourcePkg},
- {"SourceVer",PkgRecordsGetSourceVer},
-#endif
{}
};
@@ -180,7 +163,7 @@ PyTypeObject PyPackageRecords_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
(Py_TPFLAGS_DEFAULT | // tp_flags
diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc
index 41ee6276..95f35f23 100644
--- a/python/pkgsrcrecords.cc
+++ b/python/pkgsrcrecords.cc
@@ -71,10 +71,6 @@ static PyMethodDef PkgSrcRecordsMethods[] =
{
{"lookup",PkgSrcRecordsLookup,METH_VARARGS,doc_PkgSrcRecordsLookup},
{"restart",PkgSrcRecordsRestart,METH_VARARGS,doc_PkgSrcRecordsRestart},
-#ifdef COMPAT_0_7
- {"Lookup",PkgSrcRecordsLookup,METH_VARARGS,doc_PkgSrcRecordsLookup},
- {"Restart",PkgSrcRecordsRestart,METH_VARARGS,doc_PkgSrcRecordsRestart},
-#endif
{}
};
@@ -234,15 +230,7 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = {
{"section",PkgSrcRecordsGetSection},
{"version",PkgSrcRecordsGetVersion},
#ifdef COMPAT_0_7
- {"Binaries",PkgSrcRecordsGetBinaries},
{"BuildDepends",PkgSrcRecordsGetBuildDepends_old,0,"Deprecated function and deprecated output format."},
- {"Files",PkgSrcRecordsGetFiles},
- {"Index",PkgSrcRecordsGetIndex},
- {"Maintainer",PkgSrcRecordsGetMaintainer},
- {"Package",PkgSrcRecordsGetPackage},
- {"Record",PkgSrcRecordsGetRecord},
- {"Section",PkgSrcRecordsGetSection},
- {"Version",PkgSrcRecordsGetVersion},
#endif
{}
};
@@ -274,7 +262,7 @@ PyTypeObject PySourceRecords_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
(Py_TPFLAGS_DEFAULT | // tp_flags
diff --git a/python/sourcelist.cc b/python/sourcelist.cc
index b705d8b8..6184fee3 100644
--- a/python/sourcelist.cc
+++ b/python/sourcelist.cc
@@ -77,11 +77,6 @@ static PyMethodDef PkgSourceListMethods[] =
{"find_index",PkgSourceListFindIndex,METH_VARARGS,doc_PkgSourceListFindIndex},
{"read_main_list",PkgSourceListReadMainList,METH_VARARGS,doc_PkgSourceListReadMainList},
{"get_indexes",PkgSourceListGetIndexes,METH_VARARGS,doc_PkgSourceListGetIndexes},
-#ifdef COMPAT_0_7
- {"FindIndex",PkgSourceListFindIndex,METH_VARARGS,doc_PkgSourceListFindIndex},
- {"ReadMainList",PkgSourceListReadMainList,METH_VARARGS,doc_PkgSourceListReadMainList},
- {"GetIndexes",PkgSourceListGetIndexes,METH_VARARGS,doc_PkgSourceListGetIndexes},
-#endif
{}
};
@@ -104,9 +99,6 @@ static PyObject *PkgSourceListGetList(PyObject *Self,void*)
static PyGetSetDef PkgSourceListGetSet[] = {
{"list",PkgSourceListGetList,0,"A list of MetaIndex() objects.",0},
-#ifdef COMPAT_0_7
- {"List",PkgSourceListGetList,0,"A list of MetaIndex() objects.",0},
-#endif
{}
};
@@ -137,7 +129,7 @@ PyTypeObject PySourceList_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
(Py_TPFLAGS_DEFAULT | // tp_flags
diff --git a/python/tag.cc b/python/tag.cc
index 4971a03d..6d327d27 100644
--- a/python/tag.cc
+++ b/python/tag.cc
@@ -458,12 +458,6 @@ static PyMethodDef TagSecMethods[] =
{"find_raw",TagSecFindRaw,METH_VARARGS,doc_FindRaw},
{"find_flag",TagSecFindFlag,METH_VARARGS,doc_FindFlag},
{"bytes",TagSecBytes,METH_VARARGS,doc_Bytes},
-#ifdef COMPAT_0_7
- {"Find",TagSecFind,METH_VARARGS,doc_Find},
- {"FindRaw",TagSecFindRaw,METH_VARARGS,doc_FindRaw},
- {"FindFlag",TagSecFindFlag,METH_VARARGS,doc_FindFlag},
- {"Bytes",TagSecBytes,METH_VARARGS,doc_Bytes},
-#endif
// Python Special
{"keys",TagSecKeys,METH_VARARGS,doc_Keys},
@@ -503,7 +497,7 @@ PyTypeObject PyTagSection_Type =
0, // tp_hash
0, // tp_call
TagSecStr, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
(Py_TPFLAGS_DEFAULT | // tp_flags
@@ -536,11 +530,6 @@ static PyMethodDef TagFileMethods[] =
{"step",TagFileStep,METH_VARARGS,doc_Step},
{"offset",TagFileOffset,METH_VARARGS,doc_Offset},
{"jump",TagFileJump,METH_VARARGS,doc_Jump},
-#ifdef COMPAT_0_7
- {"Step",TagFileStep,METH_VARARGS,doc_Step},
- {"Offset",TagFileOffset,METH_VARARGS,doc_Offset},
- {"Jump",TagFileJump,METH_VARARGS,doc_Jump},
-#endif
{}
};
@@ -554,12 +543,10 @@ static PyObject *TagFileGetSection(PyObject *Self,void*) {
static PyGetSetDef TagFileGetSet[] = {
{"section",TagFileGetSection,0,"Return a TagSection.",0},
-#ifdef COMPAT_0_7
- {"Section",TagFileGetSection,0,"Return a TagSection.",0},
-#endif
{}
};
+
static char *doc_TagFile = "TagFile(file) -> TagFile() object. \n\n"
"TagFile() objects provide access to debian control files, which consists\n"
"of multiple RFC822-like formatted sections.\n\n"
@@ -593,7 +580,7 @@ PyTypeObject PyTagFile_Type =
0, // tp_hash
0, // tp_call
0, // tp_str
- 0, // tp_getattro
+ _PyAptObject_getattro, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
(Py_TPFLAGS_DEFAULT | // tp_flags