mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
#7801: fix xmlrpclib binary example, open the picture in binary mode
This commit is contained in:
parent
721caaa9ce
commit
75d3fb1ebb
1 changed files with 2 additions and 2 deletions
|
@ -318,7 +318,7 @@ XMLRPC::
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
|
|
||||||
def python_logo():
|
def python_logo():
|
||||||
with open("python_logo.jpg") as handle:
|
with open("python_logo.jpg", "rb") as handle:
|
||||||
return xmlrpclib.Binary(handle.read())
|
return xmlrpclib.Binary(handle.read())
|
||||||
|
|
||||||
server = SimpleXMLRPCServer(("localhost", 8000))
|
server = SimpleXMLRPCServer(("localhost", 8000))
|
||||||
|
@ -332,7 +332,7 @@ The client gets the image and saves it to a file::
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
|
|
||||||
proxy = xmlrpclib.ServerProxy("http://localhost:8000/")
|
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)
|
handle.write(proxy.python_logo().data)
|
||||||
|
|
||||||
.. _fault-objects:
|
.. _fault-objects:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue