diff --git a/pdoc/cli.py b/pdoc/cli.py index 149d1117..a6819da1 100755 --- a/pdoc/cli.py +++ b/pdoc/cli.py @@ -2,6 +2,7 @@ """pdoc's CLI interface and helper functions.""" import argparse +import ast import importlib import inspect import os @@ -370,12 +371,19 @@ def main(_args=None): _warn_deprecated('--overwrite', '--force') args.force = args.overwrite - try: - template_config = {opt.split('=', 1)[0]: eval(opt.split('=', 1)[1], {}) - for opt in args.config} - except Exception as e: - raise RuntimeError('Error evaluating config values {}: {}\n' - 'Make sure string values are quoted?'.format(args.config, e)) + template_config = {} + for config_str in args.config: + try: + key, value = config_str.split('=', 1) + value = ast.literal_eval(value) + template_config[key] = value + except Exception: + raise ValueError( + 'Error evaluating --config statement "{}". ' + 'Make sure string values are quoted?' + .format(config_str) + ) + if args.html_no_source: _warn_deprecated('--html-no-source', '-c show_source_code=False', True) template_config['show_source_code'] = False