From 05d203a878cace00013c62bec8337c0c4d5eaca4 2008-05-27 12:20:02 From: vivainio2 Date: 2008-05-27 12:20:02 Subject: [PATCH] %cpaste: strip whitespace before >>> in regex to allow pasting doctests --- diff --git a/IPython/Magic.py b/IPython/Magic.py index 19ac301..b7d34f8 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -3167,7 +3167,7 @@ Defaulting color scheme to 'NoColor'""" sentinel = opts.get('s','--') strip_from_start = [re.compile(e) for e in - ['^(.?>)+','^In \[\d+\]:','^\++']] + [r'^\s*(\s?>)+',r'^\s*In \[\d+\]:',r'^\++']] from IPython import iplib lines = [] print "Pasting code; enter '%s' alone on the line to stop." % sentinel diff --git a/doc/ChangeLog b/doc/ChangeLog index ffc7e55..d4e8a63 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -3,7 +3,8 @@ * iplib.py, ipmaker.py: survive lack of doctest and site._Helper for minimal environments (e.g. Maemo sdk python) - * Branch for 0.8.3 + * Magic.py: cpaste strips whitespace before >>> (allow pasting + doctests) 2008-05-14 Ville Vainio diff --git a/test/test_cpaste.ipy b/test/test_cpaste.ipy index 90811f7..259e930 100644 --- a/test/test_cpaste.ipy +++ b/test/test_cpaste.ipy @@ -3,7 +3,8 @@ tests = {'pass': ["> > > run()", ">>> > run()", "+++ run()", - "++ run()"], + "++ run()", + " >>> run()"], 'fail': ["+ + run()", " ++ run()"]}