ipython/ipython — Issue #1102: magic in IPythonDemo fails when not located at top of demo file
Author: agardelein
Created: 2011-12-04 22:20:59+00:00
State: open

Recently switched from 0.10 to 0.11 and found this which is apparently a regression (neglecting messages related to history logging)

bomberx% cat aa.py
lsmagic

bomberx% cat aa2.py
print 2222
lsmagic

bomberx% ipython --automagic
Python 2.7.2+ (default, Nov 30 2011, 19:22:03)
Type "copyright", "credits" or "license" for more information.

IPython 0.11 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]: from IPython.lib.demo import IPythonDemo

In [2]: mydemo1=IPythonDemo('aa.py')

In [3]: mydemo1()
********************** block # 0 (0 remaining) **********************
lsmagic

****************** Press to quit, to execute... ******************
Available magic functions:
%alias %autocall %autoindent %automagic %bookmark %cd %colors %cpaste %debug %dhist %dirs %doctest_mode %ed %edit %env %gui %hist %history %install_default_config %install_profiles %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %lsmagic %macro %magic %page %paste %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %popd %pprint %precision %profile %prun %psearch %psource %pushd %pwd %pycat %pylab %quickref %recall %rehashx %reload_ext %rep %rerun %reset %reset_selective %run %save %sc %sx %tb %time %timeit %unalias %unload_ext %who %who_ls %whos %xdel %xmode

Automagic is ON, % prefix NOT needed for magic functions.

******************************** END OF DEMO ********************************
************** Use .reset() if you want to rerun it. **************

In [5]: ERROR! Session/line number was not unique in database. History logging moved to new session 34

In [5]: mydemo2=IPythonDemo('aa2.py')

In [6]: mydemo2()
********************** block # 0 (0 remaining) **********************
print 2222
lsmagic

****************** Press to quit, to execute... ******************
2222
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
/home/arnaud/src/scope/ in ()
1 print 2222
----> 2 lsmagic

NameError: name 'lsmagic' is not defined

******************************** END OF DEMO ********************************
************** Use .reset() if you want to rerun it. **************

In [8]: