diff options
Diffstat (limited to 'python/cache.cc')
| -rw-r--r-- | python/cache.cc | 13 |
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) { |
