mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
Issue #9425: zipimporter_repr() uses unicode
This commit is contained in:
parent
60fe8d902d
commit
028dd97dfb
1 changed files with 7 additions and 12 deletions
|
|
@ -188,19 +188,14 @@ zipimporter_dealloc(ZipImporter *self)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
zipimporter_repr(ZipImporter *self)
|
zipimporter_repr(ZipImporter *self)
|
||||||
{
|
{
|
||||||
char *archive = "???";
|
if (self->archive == NULL)
|
||||||
char *prefix = "";
|
return PyUnicode_FromString("<zipimporter object \"???\">");
|
||||||
|
else if (self->prefix != NULL && PyUnicode_GET_SIZE(self->prefix) != 0)
|
||||||
if (self->archive != NULL && PyUnicode_Check(self->archive))
|
return PyUnicode_FromFormat("<zipimporter object \"%.300U%c%.150U\">",
|
||||||
archive = _PyUnicode_AsString(self->archive);
|
self->archive, SEP, self->prefix);
|
||||||
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);
|
|
||||||
else
|
else
|
||||||
return PyUnicode_FromFormat("<zipimporter object \"%.300s\">",
|
return PyUnicode_FromFormat("<zipimporter object \"%.300U\">",
|
||||||
archive);
|
self->archive);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return fullname.split(".")[-1] */
|
/* return fullname.split(".")[-1] */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue