[Python-checkins] cpython (merge 3.3 -> 3.3): Merge heads.

r.david.murray python-checkins at python.org
Sat Aug 10 18:15:54 CEST 2013


http://hg.python.org/cpython/rev/54998d3d5587
changeset:   85098:54998d3d5587
branch:      3.3
parent:      85094:53d54503fc06
parent:      85096:bc49e82ee013
user:        R David Murray <rdmurray at bitdance.com>
date:        Sat Aug 10 12:08:41 2013 -0400
summary:
  Merge heads.

files:
  Lib/test/test_docxmlrpc.py |  27 ++++++++++++++++++++++---
  Lib/xmlrpc/server.py       |  17 +++++++++------
  Misc/NEWS                  |   3 ++
  3 files changed, 36 insertions(+), 11 deletions(-)


diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py
--- a/Lib/test/test_docxmlrpc.py
+++ b/Lib/test/test_docxmlrpc.py
@@ -54,8 +54,18 @@
             """
             return x + y
 
+        def annotation(x: int):
+            """ Use function annotations. """
+            return x
+
+        class ClassWithAnnotation:
+            def method_annotation(self, x: bytes):
+                return x.decode()
+
         serv.register_function(add)
         serv.register_function(lambda x, y: x-y)
+        serv.register_function(annotation)
+        serv.register_instance(ClassWithAnnotation())
 
         while numrequests > 0:
             serv.handle_request()
@@ -177,10 +187,7 @@
              b'method takes two integers as arguments'
              b'<br>\nand returns a double result.<br>\n '
              b'<br>\nThis server does NOT support system'
-             b'.methodSignature.</tt></dd></dl>\n<dl><dt><a name="-test_method">'
-             b'<strong>test_method</strong></a>(arg)</dt><dd><tt>Test '
-             b'method\'s docs. This method truly does'
-             b' very little.</tt></dd></dl>'), response)
+             b'.methodSignature.</tt></dd></dl>'), response)
 
     def test_autolink_dotted_methods(self):
         """Test that selfdot values are made strong automatically in the
@@ -191,6 +198,18 @@
         self.assertIn(b"""Try self.<strong>add</strong>, too.""",
                       response.read())
 
+    def test_annotations(self):
+        """ Test that annotations works as expected """
+        self.client.request("GET", "/")
+        response = self.client.getresponse()
+        self.assertIn(
+            (b'<dl><dt><a name="-annotation"><strong>annotation</strong></a>'
+             b'(x: int)</dt><dd><tt>Use function annotations.</tt>'
+             b'</dd></dl>\n<dl><dt><a name="-method_annotation"><strong>'
+             b'method_annotation</strong></a>(x: bytes)</dt></dl>'),
+            response.read())
+
+
 def test_main():
     support.run_unittest(DocXMLRPCHTTPGETServer)
 
diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py
--- a/Lib/xmlrpc/server.py
+++ b/Lib/xmlrpc/server.py
@@ -756,20 +756,23 @@
             self.escape(anchor), self.escape(name))
 
         if inspect.ismethod(object):
-            args, varargs, varkw, defaults = inspect.getargspec(object)
+            args = inspect.getfullargspec(object)
             # exclude the argument bound to the instance, it will be
             # confusing to the non-Python user
             argspec = inspect.formatargspec (
-                    args[1:],
-                    varargs,
-                    varkw,
-                    defaults,
+                    args.args[1:],
+                    args.varargs,
+                    args.varkw,
+                    args.defaults,
+                    annotations=args.annotations,
                     formatvalue=self.formatvalue
                 )
         elif inspect.isfunction(object):
-            args, varargs, varkw, defaults = inspect.getargspec(object)
+            args = inspect.getfullargspec(object)
             argspec = inspect.formatargspec(
-                args, varargs, varkw, defaults, formatvalue=self.formatvalue)
+                args.args, args.varargs, args.varkw, args.defaults,
+                annotations=args.annotations,
+                formatvalue=self.formatvalue)
         else:
             argspec = '(...)'
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -64,6 +64,9 @@
 Library
 -------
 
+- Issue #8112: xlmrpc.server's DocXMLRPCServer server no longer raises an error
+  if methods have annotations; it now correctly displays the annotations.
+
 - Issue #17998: Fix an internal error in regular expression engine.
 
 - Issue #17557: Fix os.getgroups() to work with the modified behavior of

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list