Issue #9425: zipimporter_repr() uses unicode

This commit is contained in:
Victor Stinner 2010-08-17 00:04:48 +00:00
parent 60fe8d902d
commit 028dd97dfb
1 changed files with 7 additions and 12 deletions

View File

@ -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] */