]> granicus.if.org Git - python/commitdiff
Merged revisions 77836 via svnmerge from
authorVictor Stinner <victor.stinner@haypocalc.com>
Sat, 30 Jan 2010 02:04:58 +0000 (02:04 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sat, 30 Jan 2010 02:04:58 +0000 (02:04 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77836 | victor.stinner | 2010-01-30 03:00:26 +0100 (sam., 30 janv. 2010) | 2 lines

  #7801: fix xmlrpclib binary example, open the picture in binary mode
........

Doc/library/xmlrpclib.rst

index ee99950f0730ad4c88069a0a970224278f36594f..f2b47369647ecb3c631bf126f91e8fe25d33ab15 100644 (file)
@@ -318,7 +318,7 @@ XMLRPC::
    import xmlrpclib
 
    def python_logo():
-        with open("python_logo.jpg") as handle:
+        with open("python_logo.jpg", "rb") as handle:
             return xmlrpclib.Binary(handle.read())
 
    server = SimpleXMLRPCServer(("localhost", 8000))
@@ -332,7 +332,7 @@ The client gets the image and saves it to a file::
    import xmlrpclib
 
    proxy = xmlrpclib.ServerProxy("http://localhost:8000/")
-   with open("fetched_python_logo.jpg", "w") as handle:
+   with open("fetched_python_logo.jpg", "wb") as handle:
        handle.write(proxy.python_logo().data)
 
 .. _fault-objects: