From bfcbfa7c46fce54616b8b71ab27472da16759bf0 Mon Sep 17 00:00:00 2001 From: Skip Montanaro Date: Thu, 24 Apr 2003 19:51:31 +0000 Subject: move imports in Binary class to top level to avoid repeated imports. use cStringIO if available. --- Lib/xmlrpclib.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py index 8c1ef1f..b6cd24b 100644 --- a/Lib/xmlrpclib.py +++ b/Lib/xmlrpclib.py @@ -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("\n") base64.encode(StringIO.StringIO(self.data), out) out.write("\n") -- cgit v0.12