From: Andrew M. Kuchling Date: Sat, 5 Jun 2004 12:35:58 +0000 (+0000) Subject: [Bug #841757] Patch from /F to allow Unicode strings as struct keys X-Git-Tag: v2.4a1~264 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5962f457b48997dbfb8bcb0769b57cd3fab96148;p=python [Bug #841757] Patch from /F to allow Unicode strings as struct keys --- diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py index 2466e25fe9..e7eb466494 100644 --- a/Lib/xmlrpclib.py +++ b/Lib/xmlrpclib.py @@ -688,12 +688,15 @@ class Marshaller: self.memo[i] = None dump = self.__dump write("\n") - for k in value.keys(): + for k, v in value.items(): write("\n") if type(k) is not StringType: - raise TypeError, "dictionary key must be string" + if unicode and type(k) is UnicodeType: + k = k.encode(self.encoding) + else: + raise TypeError, "dictionary key must be string" write("%s\n" % escape(k)) - dump(value[k], write) + dump(v, write) write("\n") write("\n") del self.memo[i]