Issue 33911: [EASY] test_docxmlrpc fails when run with -Werror (original) (raw)
Ok, but notice the two warnings:
vstinner@apu$ ./python -m test test_docxmlrpc
Run tests sequentially
0:00:00 load avg: 1.19 [1/1] test_docxmlrpc
/home/vstinner/prog/python/master/Lib/xmlrpc/server.py:791: DeprecationWarning: formatargspec
is deprecated since Python 3.5. Use signature
and the Signature
object directly
formatvalue=self.formatvalue)
/home/vstinner/prog/python/master/Lib/xmlrpc/server.py:784: DeprecationWarning: formatargspec
is deprecated since Python 3.5. Use signature
and the Signature
object directly
formatvalue=self.formatvalue
== Tests result: SUCCESS ==
1 test OK.
Total duration: 2 sec 698 ms Tests result: SUCCESS
Fail:
vstinner@apu$ ./python -Werror -m test -v test_docxmlrpc
test_annotations (test.test_docxmlrpc.DocXMLRPCHTTPGETServer)
Test that annotations works as expected ... ----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 45060)
Traceback (most recent call last):
File "/home/vstinner/prog/python/master/Lib/socketserver.py", line 313, in _handle_request_noblock
self.process_request(request, client_address)
File "/home/vstinner/prog/python/master/Lib/socketserver.py", line 344, in process_request
self.finish_request(request, client_address)
File "/home/vstinner/prog/python/master/Lib/socketserver.py", line 357, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/home/vstinner/prog/python/master/Lib/socketserver.py", line 717, in init
self.handle()
File "/home/vstinner/prog/python/master/Lib/http/server.py", line 426, in handle
self.handle_one_request()
File "/home/vstinner/prog/python/master/Lib/http/server.py", line 414, in handle_one_request
method()
File "/home/vstinner/prog/python/master/Lib/xmlrpc/server.py", line 936, in do_GET
response = self.server.generate_html_documentation().encode('utf-8')
File "/home/vstinner/prog/python/master/Lib/xmlrpc/server.py", line 910, in generate_html_documentation
methods
File "/home/vstinner/prog/python/master/Lib/xmlrpc/server.py", line 828, in docserver
contents.append(self.docroutine(value, key, funcs=fdict))
File "/home/vstinner/prog/python/master/Lib/xmlrpc/server.py", line 791, in docroutine
formatvalue=self.formatvalue)
File "/home/vstinner/prog/python/master/Lib/inspect.py", line 1225, in formatargspec
stacklevel=2)
DeprecationWarning: formatargspec
is deprecated since Python 3.5. Use signature
and the Signature
object directly
ERROR (...) == Tests result: FAILURE ==
1 test failed: test_docxmlrpc
Total duration: 3 sec 234 ms Tests result: FAILURE
It seems like the fix is explained in the error message:
Lib/xmlrpc/server.py, line 791, in docroutine():
DeprecationWarning: formatargspec
is deprecated since Python 3.5. Use signature
and the Signature
object directly
Slightly off topic but while trying to look at the code I can see a space between function name and parenthesis as below. It's not an invalid syntax but it's mentioned as a pet peeve in PEP 8 to not to have space between function name and parenthesis. I did a simple grep and I could some places where even function definitions have spaces as below. It's a trivial thing but just wanted to post it here and might seem like an invalid syntax for someone new fixing it.
Lib/xmlrpc/server.py
argspec = inspect.formatargspec (
simple grep and manual scanning with rg '\w+ \(' | grep -v -E 'if|while|for|except|return' | grep '.py' | less
Tools/gdb/libpython.py: def init (self, gdbval): Tools/gdb/libpython.py: def to_string (self): Tools/gdb/libpython.py:def register (obj): Tools/gdb/libpython.py:register (gdb.current_objfile ()) Tools/gdb/libpython.py: gdb.Command.init (self, Tools/gdb/libpython.py: gdb.Command.init (self, Tools/gdb/libpython.py: gdb.Command.init (self, Tools/gdb/libpython.py: gdb.Command.init (self, Tools/gdb/libpython.py: gdb.Command.init (self,
Relevant PEP 8 section : https://www.python.org/dev/peps/pep-0008/#pet-peeves
Immediately before the open parenthesis that starts the argument list of a function call: Yes: spam(1) No: spam (1)
Also I think it will be good if a deprecation is made then it has to run the test suite with -Werror
so that the deprecations are fixed which is slightly subjective though where deprecations are reverted back in a future version for reasons like easy 2to3 porting.
Thanks much for these easy issues and I hope someone takes it up.
Python 3.7 is affected as well:
vstinner@apu$ ./python -Werror -m test test_docxmlrpc
Exception happened during processing of request from ('127.0.0.1', 46636)
Traceback (most recent call last):
(...)
File "/home/vstinner/prog/python/3.7/Lib/xmlrpc/server.py", line 828, in docserver
contents.append(self.docroutine(value, key, funcs=fdict))
File "/home/vstinner/prog/python/3.7/Lib/xmlrpc/server.py", line 791, in docroutine
formatvalue=self.formatvalue)
File "/home/vstinner/prog/python/3.7/Lib/inspect.py", line 1225, in formatargspec
stacklevel=2)
DeprecationWarning: formatargspec
is deprecated since Python 3.5. Use signature
and the Signature
object directly
Warning -- threading._dangling was modified by test_docxmlrpc Before: <_weakrefset.WeakSet object at 0x7fc84da8f810> After: <_weakrefset.WeakSet object at 0x7fc84da8f538> test test_docxmlrpc failed -- multiple errors occurred; run in verbose mode for details test_docxmlrpc failed
I generated PR 8294 backport to fix Python 3.7 as well. Since the HTML output is unchanged, IMHO it's safe to backport the change.
In the documentation, inspect.formatargspec() is also deprecated in Python 3.6, but the code doesn't emit a DeprecationWarning. I don't think that it's worth it to backport the change to Python 3.6.