summaryrefslogtreecommitdiff
path: root/python/cache.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-06-25 17:37:23 +0200
committerJulian Andres Klode <jak@debian.org>2009-06-25 17:37:23 +0200
commitca4408170dd5d2a6bba176409e0f0af1156357a6 (patch)
tree4d8ed22c889f30391a9395a4f58da3c8139ecfa1 /python/cache.cc
parent4f76b8075e8a6acd8fbaad8693ba456a0dcfc836 (diff)
downloadpython-apt-ca4408170dd5d2a6bba176409e0f0af1156357a6.tar.gz
python/cache.cc: Support unicode objects and str objects in Python 2.
Diffstat (limited to 'python/cache.cc')
-rw-r--r--python/cache.cc13
1 files changed, 6 insertions, 7 deletions
diff --git a/python/cache.cc b/python/cache.cc
index 4ce3178c..2de9c76a 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -219,21 +219,20 @@ static PyGetSetDef PkgCacheGetSet[] = {
{}
};
+
+
// Map access, operator []
static PyObject *CacheMapOp(PyObject *Self,PyObject *Arg)
{
pkgCache *Cache = GetCpp<pkgCache *>(Self);
- if (PyString_Check(Arg) == 0)
- {
- PyObject *repr = PyObject_Repr(Arg);
- PyErr_SetObject(PyExc_TypeError, repr);
- Py_DECREF(repr);
+ // Get the name of the package, unicode and normal strings.
+ const char *Name = PyObject_AsString(Arg);
+ if (Name == NULL)
return 0;
- }
+
// Search for the package
- const char *Name = PyString_AsString(Arg);
pkgCache::PkgIterator Pkg = Cache->FindPkg(Name);
if (Pkg.end() == true)
{