]> granicus.if.org Git - python/commitdiff
bpo-33911: Fixed deprecation warning in xmlrpc.server (GH-7847)
authorNicolas Noé <nicolas@niconoe.org>
Mon, 16 Jul 2018 08:46:04 +0000 (10:46 +0200)
committerVictor Stinner <vstinner@redhat.com>
Mon, 16 Jul 2018 08:46:04 +0000 (10:46 +0200)
Replace deprecated inspect.getfullargspec() with inspect.signature().

Lib/xmlrpc/server.py

index 88d0eec786b018a10afa5ed0665a892cfd5713ae..f1c467eb1b2b87c2e76a46b745985831d67c7acb 100644 (file)
@@ -107,13 +107,13 @@ server.handle_request()
 from xmlrpc.client import Fault, dumps, loads, gzip_encode, gzip_decode
 from http.server import BaseHTTPRequestHandler
 from functools import partial
+from inspect import signature
 import http.server
 import socketserver
 import sys
 import os
 import re
 import pydoc
-import inspect
 import traceback
 try:
     import fcntl
@@ -771,24 +771,8 @@ class ServerHTMLDoc(pydoc.HTMLDoc):
         title = '<a name="%s"><strong>%s</strong></a>' % (
             self.escape(anchor), self.escape(name))
 
-        if inspect.ismethod(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.args[1:],
-                    args.varargs,
-                    args.varkw,
-                    args.defaults,
-                    annotations=args.annotations,
-                    formatvalue=self.formatvalue
-                )
-        elif inspect.isfunction(object):
-            args = inspect.getfullargspec(object)
-            argspec = inspect.formatargspec(
-                args.args, args.varargs, args.varkw, args.defaults,
-                annotations=args.annotations,
-                formatvalue=self.formatvalue)
+        if callable(object):
+            argspec = str(signature(object))
         else:
             argspec = '(...)'