diff options
author | Michael Kefeder <oss@multiwave.ch> | 2016-01-28 20:33:04 +0100 |
---|---|---|
committer | Michael Kefeder <oss@multiwave.ch> | 2016-01-28 20:33:04 +0100 |
commit | 037a1668552ef1ac058b65cfc220bcbd71c1641f (patch) | |
tree | a1aff46c9dd795f185e172e9ca0db54f9f788c79 | |
parent | 2bd27c084c64ab00d34d79c3c15e2d44e9ac3760 (diff) | |
download | cherrypy-037a1668552ef1ac058b65cfc220bcbd71c1641f.tar.gz |
workaround for issue #1382, python 3.5 _ast.Call signature rudimentarily implemented
-rw-r--r-- | cherrypy/lib/reprconf.py | 30 |
1 files changed, 29 insertions, 1 deletions
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: |