summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-03-08 18:58:17 +0100
committerJulian Andres Klode <jak@debian.org>2009-03-08 18:58:17 +0100
commit162844cc03d669fd1aaf4a6cf9424597bb299264 (patch)
treea0887d64151344f48e221d6d41ed922abbc0bc36 /python
parent645c80f504f98332fb8eceb955c13a54e38e5956 (diff)
parent2342bc7c05da5589f166496fe1112b249598648f (diff)
downloadpython-apt-162844cc03d669fd1aaf4a6cf9424597bb299264.tar.gz
* Merge with mvo
Diffstat (limited to 'python')
-rw-r--r--python/apt_pkgmodule.cc1
-rw-r--r--python/apt_pkgmodule.h2
-rw-r--r--python/cache.cc18
-rw-r--r--python/configuration.cc18
4 files changed, 36 insertions, 3 deletions
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index 2e488d58..86732781 100644
--- a/python/apt_pkgmodule.cc
+++ b/python/apt_pkgmodule.cc
@@ -402,6 +402,7 @@ static PyMethodDef methods[] =
// Command line
{"ReadConfigFile",LoadConfig,METH_VARARGS,doc_LoadConfig},
+ {"ReadConfigDir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir},
{"ReadConfigFileISC",LoadConfigISC,METH_VARARGS,doc_LoadConfig},
{"ParseCommandLine",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine},
diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h
index 38486182..e047bcd8 100644
--- a/python/apt_pkgmodule.h
+++ b/python/apt_pkgmodule.h
@@ -23,9 +23,11 @@ extern PyTypeObject VersionType;
extern char *doc_LoadConfig;
extern char *doc_LoadConfigISC;
+extern char *doc_LoadConfigDir;
extern char *doc_ParseCommandLine;
PyObject *LoadConfig(PyObject *Self,PyObject *Args);
PyObject *LoadConfigISC(PyObject *Self,PyObject *Args);
+PyObject *LoadConfigDir(PyObject *Self,PyObject *Args);
PyObject *ParseCommandLine(PyObject *Self,PyObject *Args);
// Tag File Stuff
diff --git a/python/cache.cc b/python/cache.cc
index 1c59bece..0c59f561 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -936,14 +936,26 @@ PyObject *TmpGetCache(PyObject *Self,PyObject *Args)
pkgCacheFile *Cache = new pkgCacheFile();
if(pyCallbackInst != 0) {
+ // sanity check for the progress object, see #497049
+ if (PyObject_HasAttrString(pyCallbackInst, "done") != true) {
+ PyErr_SetString(PyExc_ValueError,
+ "OpProgress object must implement done()");
+ return 0;
+ }
+ if (PyObject_HasAttrString(pyCallbackInst, "update") != true) {
+ PyErr_SetString(PyExc_ValueError,
+ "OpProgress object must implement update()");
+ return 0;
+ }
PyOpProgress progress;
progress.setCallbackInst(pyCallbackInst);
if (Cache->Open(progress,false) == false)
- return HandleErrors();
- } else {
+ return HandleErrors();
+ }
+ else {
OpTextProgress Prog;
if (Cache->Open(Prog,false) == false)
- return HandleErrors();
+ return HandleErrors();
}
CppOwnedPyObject<pkgCacheFile*> *CacheFileObj =
diff --git a/python/configuration.cc b/python/configuration.cc
index f52c3c97..21f70bc1 100644
--- a/python/configuration.cc
+++ b/python/configuration.cc
@@ -330,6 +330,24 @@ PyObject *LoadConfigISC(PyObject *Self,PyObject *Args)
Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
+char *doc_LoadConfigDir = "LoadConfigDir(Configuration,DirName) -> None";
+PyObject *LoadConfigDir(PyObject *Self,PyObject *Args)
+{
+ char *Name = 0;
+ if (PyArg_ParseTuple(Args,"Os",&Self,&Name) == 0)
+ return 0;
+ if (Configuration_Check(Self)== 0)
+ {
+ PyErr_SetString(PyExc_TypeError,"argument 1: expected Configuration.");
+ return 0;
+ }
+
+ if (ReadConfigDir(GetSelf(Self),Name,false) == false)
+ return HandleErrors();
+
+ Py_INCREF(Py_None);
+ return HandleErrors(Py_None);
+}
/*}}}*/
// ParseCommandLine - Wrapper for the command line interface /*{{{*/