summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-08-17 00:04:48 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-08-17 00:04:48 (GMT)
commit028dd97dfbabd14687bca109d6328fc734e48eeb (patch)
tree2b0e7d0297248b869adfc7e738634f2a338622f3 /Modules
parent60fe8d902d12c0392dbcfaa0ba008f05a55ca460 (diff)
downloadcpython-028dd97dfbabd14687bca109d6328fc734e48eeb.zip
cpython-028dd97dfbabd14687bca109d6328fc734e48eeb.tar.gz
cpython-028dd97dfbabd14687bca109d6328fc734e48eeb.tar.bz2
Issue #9425: zipimporter_repr() uses unicode
Diffstat (limited to 'Modules')
-rw-r--r--Modules/zipimport.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index a1ee70b..d1c939f 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("<zipimporter object \"%.300s%c%.150s\">",
- archive, SEP, prefix);
+ if (self->archive == NULL)
+ return PyUnicode_FromString("<zipimporter object \"???\">");
+ else if (self->prefix != NULL && PyUnicode_GET_SIZE(self->prefix) != 0)
+ return PyUnicode_FromFormat("<zipimporter object \"%.300U%c%.150U\">",
+ self->archive, SEP, self->prefix);
else
- return PyUnicode_FromFormat("<zipimporter object \"%.300s\">",
- archive);
+ return PyUnicode_FromFormat("<zipimporter object \"%.300U\">",
+ self->archive);
}
/* return fullname.split(".")[-1] */