diff --git a/IPython/core/ipapi.py b/IPython/core/ipapi.py index dc1f1f5..8ee88a2 100644 --- a/IPython/core/ipapi.py +++ b/IPython/core/ipapi.py @@ -18,16 +18,19 @@ has been made into a component, this module will be sent to deathrow. # Imports #----------------------------------------------------------------------------- -from IPython.core.error import TryNext, UsageError +from IPython.core.error import TryNext, UsageError, IPythonCoreError #----------------------------------------------------------------------------- # Classes and functions #----------------------------------------------------------------------------- + def get(): """Get the most recently created InteractiveShell instance.""" from IPython.core.iplib import InteractiveShell insts = InteractiveShell.get_instances() + if len(insts)==0: + return None most_recent = insts[0] for inst in insts[1:]: if inst.created > most_recent.created: