Commits

Jason R. Coombs committed 717e56c Merge

Merged in amorphic/cherrypy-1302 (pull request #62)

Fix for #1302: Config value declarations fail if keyword arguments are used.

Comments (0)

Files changed (2)

cherrypy/lib/reprconf.py

         return expr[subs]
 
     def build_CallFunc(self, o):
-        children = map(self.build, o.getChildren())
-        callee = children.pop(0)
-        kwargs = children.pop() or {}
-        starargs = children.pop() or ()
-        args = tuple(children) + tuple(starargs)
+        children = o.getChildren()
+        # Build callee from first child
+        callee = self.build(children[0])
+        # Build args and kwargs from remaining children
+        args = []
+        kwargs = {}
+        for child in children[1:]:
+            class_name = child.__class__.__name__
+            # None is ignored
+            if class_name == 'NoneType':
+                continue
+            # Keywords become kwargs
+            if class_name == 'Keyword':
+                kwargs.update(self.build(child))
+            # Everything else becomes args
+            else :
+                args.append(self.build(child))
         return callee(*args, **kwargs)
 
+    def build_Keyword(self, o):
+        key, value_obj = o.getChildren()
+        value = self.build(value_obj)
+        kw_dict = {key: value}
+        return kw_dict 
+
     def build_List(self, o):
         return map(self.build, o.getChildren())
 

cherrypy/test/test_config.py

 filename: os.path.join(sys.prefix, "hello.py")
 thing1: cherrypy.lib.httputil.response_codes[404]
 thing2: __import__('cherrypy.tutorial', globals(), locals(), ['']).thing2
+thing3: unicode('test', errors='ignore')
 complex: 3+2j
 mul: 6*3
 ones: "11"