]> granicus.if.org Git - python/commitdiff
[Bug #841757] Patch from /F to allow Unicode strings as struct keys
authorAndrew M. Kuchling <amk@amk.ca>
Sat, 5 Jun 2004 12:35:58 +0000 (12:35 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Sat, 5 Jun 2004 12:35:58 +0000 (12:35 +0000)
Lib/xmlrpclib.py

index 2466e25fe9d78418b6331cbc726d7e1e7408d1a9..e7eb4664947949174afd6a0d2007eefe0519149e 100644 (file)
@@ -688,12 +688,15 @@ class Marshaller:
         self.memo[i] = None
         dump = self.__dump
         write("<value><struct>\n")
-        for k in value.keys():
+        for k, v in value.items():
             write("<member>\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("<name>%s</name>\n" % escape(k))
-            dump(value[k], write)
+            dump(v, write)
             write("</member>\n")
         write("</struct></value>\n")
         del self.memo[i]