From 028dd97dfbabd14687bca109d6328fc734e48eeb Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Aug 2010 00:04:48 +0000 Subject: [PATCH] Issue #9425: zipimporter_repr() uses unicode --- Modules/zipimport.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Modules/zipimport.c b/Modules/zipimport.c index a1ee70b765f..d1c939f984f 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -188,19 +188,14 @@ zipimporter_dealloc(ZipImporter *self) static PyObject * zipimporter_repr(ZipImporter *self) { - char *archive = "???"; - char *prefix = ""; - - if (self->archive != NULL && PyUnicode_Check(self->archive)) - archive = _PyUnicode_AsString(self->archive); - if (self->prefix != NULL && PyUnicode_Check(self->prefix)) - prefix = _PyUnicode_AsString(self->prefix); - if (prefix != NULL && *prefix) - return PyUnicode_FromFormat("", - archive, SEP, prefix); + if (self->archive == NULL) + return PyUnicode_FromString(""); + else if (self->prefix != NULL && PyUnicode_GET_SIZE(self->prefix) != 0) + return PyUnicode_FromFormat("", + self->archive, SEP, self->prefix); else - return PyUnicode_FromFormat("", - archive); + return PyUnicode_FromFormat("", + self->archive); } /* return fullname.split(".")[-1] */