]> granicus.if.org Git - python/commitdiff
move imports in Binary class to top level to avoid repeated imports.
authorSkip Montanaro <skip@pobox.com>
Thu, 24 Apr 2003 19:51:31 +0000 (19:51 +0000)
committerSkip Montanaro <skip@pobox.com>
Thu, 24 Apr 2003 19:51:31 +0000 (19:51 +0000)
use cStringIO if available.

Lib/xmlrpclib.py

index 8c1ef1f93b7100208a28a4da4432836f14bccf34..b6cd24b36e9dbbe502d91a59d9d12afb0c970482 100644 (file)
@@ -386,6 +386,12 @@ def _datetime(data):
 #
 # @param data An 8-bit string containing arbitrary data.
 
+import base64
+try:
+    import cStringIO as StringIO
+except ImportError:
+    import StringIO
+
 class Binary:
     """Wrapper for binary data."""
 
@@ -406,11 +412,9 @@ class Binary:
         return cmp(self.data, other)
 
     def decode(self, data):
-        import base64
         self.data = base64.decodestring(data)
 
     def encode(self, out):
-        import base64, StringIO
         out.write("<value><base64>\n")
         base64.encode(StringIO.StringIO(self.data), out)
         out.write("</base64></value>\n")