This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: xmlrpc.server: ServerHTMLDoc.docroutine uses (since 3.0) deprecated function "inspect.getargspec()"
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, Claudiu.Popa, python-dev, r.david.murray, tormen
Priority: normal Keywords: patch

Created on 2010-03-10 17:37 by tormen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
xmlrpc.patch Claudiu.Popa, 2013-08-09 20:45 review
Messages (11)
msg100800 - (view) Author: (tormen) Date: 2010-03-10 17:37
This throws an exception and crashes your DocXMLRPCServer when using registered python functions that use function annotations.

Seems inconsistent to me.
Or is there a reason for this?
msg100801 - (view) Author: (tormen) Date: 2010-03-10 17:39
"This" refers to the summary of the bug.
msg100802 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-03-10 18:27
Can you provide a test case which reproduces your issue?
msg100875 - (view) Author: (tormen) Date: 2010-03-11 16:47
Okey ...

Consider you have a function:
def fn( str:str ): pass

That you register to your DocXMLRPCServer:
register_function of SimpleXMLRPCDispatcher stores the function object  in the dictionary self.funcs under the name of the function (as key).

Then you start your server and access (with a browser) the ip and port of the machine running your xmlrpc server which calls
> DocXMLRPCRequestHandler.do_GET which
> generate_html_documenation() which copies the funcs dictionary into methods and hands it to
> ServerHTMLDoc.docserver which calls for each function name + function object:
> ServerHTMLDoc.docroutine which calls (for inspect.ismethod and inspect.isfunction):

inspect.getargspec on the function object

which will fail if you register an annotated function (like the above "fn") in the first place:
=========================================
  File "/usr/lib/python3.1/inspect.py", line 789, in getargspec
    raise ValueError("Function has keyword-only arguments or annotations"
ValueError: Function has keyword-only arguments or annotations, use getfullargspec() API which can support them
=========================================

Which most probably leads to the conclusion that you should just use the getfullargspec instead of getargspec just to avoid that the XMLRPC server crashes if someone registers a annotated function.
msg100876 - (view) Author: (tormen) Date: 2010-03-11 16:52
If you want an example:

pydoc3.1 xmlrpc.server

2nd usage pattern

change "SimpleXMLRPCServer" to "DocXMLRPCServer"
change function signature from "pow(self, x, y)" to "pow(self, x:int, y:int)"

and your good to go and have your doc xmlrpc server crashed the moment you send a get request to him (e.g. by accessing "http://ip:port" in the browser of your choice).
msg100878 - (view) Author: (tormen) Date: 2010-03-11 16:55
If you want I can send you a patch.
msg100879 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-03-11 18:01
A patch with tests would be an excellent thing to have.
msg190073 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2013-05-26 10:50
Tormen could you provide a patch for this?
msg194773 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2013-08-09 20:45
Here's a patch with tests attached.
msg194815 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-10 16:15
New changeset bc49e82ee013 by R David Murray in branch '3.3':
#8112: Update the documenting xmlrpc server to use getfullargspec.
http://hg.python.org/cpython/rev/bc49e82ee013

New changeset 69e515209fa9 by R David Murray in branch 'default':
Merge #8112: Update the documenting xmlrpc server to use getfullargspec.
http://hg.python.org/cpython/rev/69e515209fa9
msg194817 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-08-10 16:34
Thanks, Popa.
History
Date User Action Args
2022-04-11 14:56:58adminsetgithub: 52359
2013-08-10 16:34:01r.david.murraysetmessages: + msg194817
2013-08-10 16:32:09r.david.murraysetmessages: - msg194816
2013-08-10 16:17:29r.david.murraysetstatus: open -> closed
versions: + Python 3.3
messages: + msg194816

resolution: fixed
stage: test needed -> resolved
2013-08-10 16:15:50python-devsetnosy: + python-dev
messages: + msg194815
2013-08-09 20:45:37Claudiu.Popasetfiles: + xmlrpc.patch
versions: + Python 3.4, - Python 3.1
nosy: + Claudiu.Popa

messages: + msg194773

keywords: + patch
2013-05-26 18:02:31brian.curtinsetnosy: - brian.curtin
2013-05-26 10:50:40BreamoreBoysetnosy: + BreamoreBoy
messages: + msg190073
2010-03-11 18:01:04r.david.murraysetpriority: normal

nosy: + r.david.murray
messages: + msg100879

type: crash -> behavior
2010-03-11 16:55:44tormensetmessages: + msg100878
2010-03-11 16:52:08tormensetmessages: + msg100876
2010-03-11 16:47:07tormensetmessages: + msg100875
2010-03-10 18:27:01brian.curtinsetnosy: + brian.curtin
messages: + msg100802

components: + Library (Lib)
stage: test needed
2010-03-10 17:48:04tormensettitle: xmlrpc.server: ServerHTMLDoc.docroutine uses (since 3.0) depricated function "inspect.getargspec()" -> xmlrpc.server: ServerHTMLDoc.docroutine uses (since 3.0) deprecated function "inspect.getargspec()"
2010-03-10 17:39:02tormensetmessages: + msg100801
2010-03-10 17:37:50tormencreate