From e5effe0eb43d57e3a34a9dd07a0c03e3a178b2f2 2010-11-03 06:56:33 From: Thomas Spura <tomspur@fedoraproject.org> Date: 2010-11-03 06:56:33 Subject: [PATCH] pycolor: Wrong filename given -> print error When a user wanted to colorize a file, which doesn't exist, IPython would crash. This commit changes this, so the user gets a usefull message about the wrong filename. This fixes RH bug #628742. Signed-off-by: Thomas Spura <tomspur@fedoraproject.org> --- diff --git a/IPython/utils/PyColorize.py b/IPython/utils/PyColorize.py index 613ae19..ddf3f7a 100644 --- a/IPython/utils/PyColorize.py +++ b/IPython/utils/PyColorize.py @@ -277,7 +277,11 @@ If no filename is given, or if filename is -, read standard input.""" if fname == '-': stream = sys.stdin else: - stream = file(fname) + try: + stream = file(fname) + except IOError,msg: + print >> sys.stderr, msg + sys.exit(1) parser = Parser()