From 037a1668552ef1ac058b65cfc220bcbd71c1641f Mon Sep 17 00:00:00 2001 From: Michael Kefeder Date: Thu, 28 Jan 2016 20:33:04 +0100 Subject: workaround for issue #1382, python 3.5 _ast.Call signature rudimentarily implemented --- cherrypy/lib/reprconf.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/cherrypy/lib/reprconf.py b/cherrypy/lib/reprconf.py index 6e70b5ec..cd6e9342 100644 --- a/cherrypy/lib/reprconf.py +++ b/cherrypy/lib/reprconf.py @@ -287,7 +287,7 @@ class _Builder2: key, value_obj = o.getChildren() value = self.build(value_obj) kw_dict = {key: value} - return kw_dict + return kw_dict def build_List(self, o): return map(self.build, o.getChildren()) @@ -377,7 +377,35 @@ class _Builder3: def build_Index(self, o): return self.build(o.value) + def build_Call35(self, o): + """workaround for python 3.5 _ast.Call signature, docs found here + https://greentreesnakes.readthedocs.org/en/latest/nodes.html""" + callee = self.build(o.func) + + args = () + kwargs = dict() + if o.args is not None: + import _ast + args = [] + for a in o.args: + if _ast.Starred is not type(a): + args.append(self.build(a)) + else: + args.append(self.build(a.value)) + args = tuple(args) + + for a in o.keywords: + if a.arg: + kwargs[a.arg] = self.build(a.value) + else: + kwargs[a.value.id] = self.build(a.value) + + return callee(*(args), **kwargs) + def build_Call(self, o): + if sys.version_info >= (3, 5): + return self.build_Call35(o) + callee = self.build(o.func) if o.args is None: -- cgit v1.2.1