From ca4408170dd5d2a6bba176409e0f0af1156357a6 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 25 Jun 2009 17:37:23 +0200 Subject: python/cache.cc: Support unicode objects and str objects in Python 2. --- python/cache.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'python/cache.cc') 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(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) { -- cgit v1.2.3