Commits

Robert Brewer committed 7faab78

Fix to unrepr for function calls.

  • Participants
  • Parent commits 327a695

Comments (0)

Files changed (2)

File cherrypy/lib/__init__.py

         return m(o)
     
     def build_CallFunc(self, o):
-        callee, args, starargs, kwargs = map(self.build, o.getChildren())
-        return callee(args, *(starargs or ()), **(kwargs or {}))
+        children = map(self.build, o.getChildren())
+        callee = children.pop(0)
+        kwargs = children.pop() or {}
+        starargs = children.pop() or ()
+        args = tuple(children) + tuple(starargs)
+        return callee(*args, **kwargs)
     
     def build_List(self, o):
         return map(self.build, o.getChildren())

File cherrypy/test/test_config.py

 from cherrypy.test import test
 test.prefer_parent_path()
 
+import os
 import StringIO
 import cherrypy
 
     ioconf = StringIO.StringIO("""
 [/]
 neg: -1234
+filename: os.path.join(os.getcwd(), "hello.py")
 """)
     
     root = Root()
             ('/',        'nex', 'None'),
             ('/',        'foo', 'this'),
             ('/',        'bar', 'that'),
-            ('/repr',    'neg', '-1234'),
             ('/xyz',     'foo', 'this'),
             ('/foo/',    'foo', 'this2'),
             ('/foo/',    'bar', 'that'),
             self.getPage("/foo/bar?key=" + key)
             self.assertBody(`expected`)
     
+    def testUnrepr(self):
+        self.getPage("/repr?key=neg")
+        self.assertBody("-1234")
+        
+        self.getPage("/repr?key=filename")
+        self.assertBody(repr(os.path.join(os.getcwd(), "hello.py")))
+    
     def testCustomNamespaces(self):
         self.getPage("/raw/incr?num=12")
         self.assertBody("13")