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