[Python-checkins] r77839 - in python/branches/release31-maint: Doc/library/xmlrpc.client.rst
victor.stinner
python-checkins at python.org
Sat Jan 30 03:19:14 CET 2010
Author: victor.stinner
Date: Sat Jan 30 03:19:14 2010
New Revision: 77839
Log:
Merged revisions 77838 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r77838 | victor.stinner | 2010-01-30 03:16:55 +0100 (sam., 30 janv. 2010) | 4 lines
#7801: fix xmlrpclib binary example, open the picture in binary mode
Use also the with syntax (consistent with python trunk example).
........
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Doc/library/xmlrpc.client.rst
Modified: python/branches/release31-maint/Doc/library/xmlrpc.client.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/xmlrpc.client.rst (original)
+++ python/branches/release31-maint/Doc/library/xmlrpc.client.rst Sat Jan 30 03:19:14 2010
@@ -283,9 +283,8 @@
import xmlrpc.client
def python_logo():
- handle = open("python_logo.jpg")
- return xmlrpc.client.Binary(handle.read())
- handle.close()
+ with open("python_logo.jpg", "rb") as handle:
+ return xmlrpc.client.Binary(handle.read())
server = SimpleXMLRPCServer(("localhost", 8000))
print("Listening on port 8000...")
@@ -298,9 +297,8 @@
import xmlrpc.client
proxy = xmlrpc.client.ServerProxy("http://localhost:8000/")
- handle = open("fetched_python_logo.jpg", "w")
- handle.write(proxy.python_logo().data)
- handle.close()
+ with open("fetched_python_logo.jpg", "wb") as handle:
+ handle.write(proxy.python_logo().data)
.. _fault-objects:
More information about the Python-checkins
mailing list