Fix traceback in sys.doc, sys.list_functions

This fixes #5779. In addition, it adds support for an arbitrary number
of positional arguments.