Robert Brewer avatar Robert Brewer committed 7faab78

Fix to unrepr for function calls.

Comments (0)

Files changed (2)

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())

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")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.