Issue 8112: xmlrpc.server: ServerHTMLDoc.docroutine uses (since 3.0) deprecated function "inspect.getargspec()" (original) (raw)

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:58 admin set github: 52359
2013-08-10 16:34:01 r.david.murray set messages: +
2013-08-10 16:32:09 r.david.murray set messages: -
2013-08-10 16:17:29 r.david.murray set status: open -> closedversions: + Python 3.3messages: + resolution: fixedstage: test needed -> resolved
2013-08-10 16:15:50 python-dev set nosy: + python-devmessages: +
2013-08-09 20:45:37 Claudiu.Popa set files: + xmlrpc.patchversions: + Python 3.4, - Python 3.1nosy: + Claudiu.Popamessages: + keywords: + patch
2013-05-26 18:02:31 brian.curtin set nosy: - brian.curtin
2013-05-26 10:50:40 BreamoreBoy set nosy: + BreamoreBoymessages: +
2010-03-11 18:01:04 r.david.murray set priority: normalnosy: + r.david.murraymessages: + type: crash -> behavior
2010-03-11 16:55:44 tormen set messages: +
2010-03-11 16:52:08 tormen set messages: +
2010-03-11 16:47:07 tormen set messages: +
2010-03-10 18:27:01 brian.curtin set nosy: + brian.curtinmessages: + components: + Library (Lib)stage: test needed
2010-03-10 17:48:04 tormen set title: 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:02 tormen set messages: +
2010-03-10 17:37:50 tormen create