]> granicus.if.org Git - python/commitdiff
Use PyUnicode_FromFormat() directly in
authorWalter Dörwald <walter@livinglogic.de>
Tue, 5 Jun 2007 16:19:33 +0000 (16:19 +0000)
committerWalter Dörwald <walter@livinglogic.de>
Tue, 5 Jun 2007 16:19:33 +0000 (16:19 +0000)
zipimporter_repr().

Modules/zipimport.c

index fd139f250c6cb9cf3d8afcf57d0fca1bda19e5de..b56e6f5a1eca523fe378577e8442cf9594d7f479 100644 (file)
@@ -187,7 +187,6 @@ zipimporter_dealloc(ZipImporter *self)
 static PyObject *
 zipimporter_repr(ZipImporter *self)
 {
-       char buf[500];
        char *archive = "???";
        char *prefix = "";
 
@@ -196,14 +195,11 @@ zipimporter_repr(ZipImporter *self)
        if (self->prefix != NULL && PyString_Check(self->prefix))
                prefix = PyString_AsString(self->prefix);
        if (prefix != NULL && *prefix)
-               PyOS_snprintf(buf, sizeof(buf),
-                             "<zipimporter object \"%.300s%c%.150s\">",
-                             archive, SEP, prefix);
+               return PyUnicode_FromFormat("<zipimporter object \"%.300s%c%.150s\">",
+                                           archive, SEP, prefix);
        else
-               PyOS_snprintf(buf, sizeof(buf),
-                             "<zipimporter object \"%.300s\">",
-                             archive);
-       return PyUnicode_FromString(buf);
+               return PyUnicode_FromFormat("<zipimporter object \"%.300s\">",
+                                           archive);
 }
 
 /* return fullname.split(".")[-1] */