Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2bb2f6ac
Commit
2bb2f6ac
authored
Aug 10, 2013
by
R David Murray
Browse files
Options
Browse Files
Download
Plain Diff
Merge #8112: Update the documenting xmlrpc server to use getfullargspec.
parents
8281e7c2
f22b62e2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
11 deletions
+36
-11
Lib/test/test_docxmlrpc.py
Lib/test/test_docxmlrpc.py
+23
-4
Lib/xmlrpc/server.py
Lib/xmlrpc/server.py
+10
-7
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_docxmlrpc.py
View file @
2bb2f6ac
...
...
@@ -54,8 +54,18 @@ def server(evt, numrequests):
"""
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 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
b'method takes two integers as arguments'
b'<br>
\
n
and returns a double result.<br>
\
n
'
b'<br>
\
n
This 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 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
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
)
...
...
Lib/xmlrpc/server.py
View file @
2bb2f6ac
...
...
@@ -756,20 +756,23 @@ class ServerHTMLDoc(pydoc.HTMLDoc):
self.escape(anchor), self.escape(name))
if inspect.ismethod(object):
args
, varargs, varkw, defaults = inspect.get
argspec(object)
args
= inspect.getfull
argspec(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.get
argspec(object)
args
= inspect.getfull
argspec(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 = '(...)'
...
...
Misc/NEWS
View file @
2bb2f6ac
...
...
@@ -24,6 +24,9 @@ Core and Builtins
Library
-------
- Issue #8112: xlmrpc.server'
s
DocXMLRPCServer
server
no
longer
raises
an
error
if
methods
have
annotations
;
it
now
correctly
displays
the
annotations
.
-
Issue
#
18600
:
Added
policy
argument
to
email
.
message
.
Message
.
as_string
,
and
as_bytes
and
__bytes__
methods
to
Message
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment