[Python-modules-commits] [ipython4] 05/10: Import ipython_4.1.2.orig.tar.gz
Julien Cristau
jcristau at moszumanska.debian.org
Fri Apr 8 11:12:59 UTC 2016
This is an automated email from the git hooks/post-receive script.
jcristau pushed a commit to branch master
in repository ipython4.
commit d2cc497c43f9f6a338952997f21c3f4b0ee4beb1
Author: Julien Cristau <julien.cristau at logilab.fr>
Date: Fri Apr 8 12:50:30 2016 +0200
Import ipython_4.1.2.orig.tar.gz
---
IPython/core/alias.py | 1 +
IPython/core/application.py | 28 +-
IPython/core/builtin_trap.py | 2 +-
IPython/core/completer.py | 21 +-
IPython/core/completerlib.py | 2 +-
IPython/core/debugger.py | 86 +-
IPython/core/display.py | 38 +-
IPython/core/excolors.py | 14 +-
IPython/core/extensions.py | 5 -
IPython/core/formatters.py | 2 +
IPython/core/history.py | 10 +-
IPython/core/inputtransformer.py | 18 +-
IPython/core/interactiveshell.py | 247 +-
IPython/core/magic.py | 6 +-
IPython/core/magics/basic.py | 29 +-
IPython/core/magics/code.py | 10 +
IPython/core/magics/deprecated.py | 5 +-
IPython/core/magics/display.py | 7 +-
IPython/core/magics/execution.py | 24 +-
IPython/core/magics/extension.py | 4 +-
IPython/core/magics/osm.py | 10 +-
IPython/core/oinspect.py | 44 +-
IPython/core/profileapp.py | 2 +-
IPython/core/profiledir.py | 4 +-
IPython/core/prompts.py | 120 +-
IPython/core/pylabtools.py | 36 +-
IPython/core/release.py | 14 +-
IPython/core/shellapp.py | 34 +-
.../tests/{ => daft_extension}/daft_extension.py | 0
IPython/core/tests/test_completer.py | 20 +-
IPython/core/tests/test_completerlib.py | 12 +-
IPython/core/tests/test_debugger.py | 29 +
IPython/core/tests/test_display.py | 3 +
IPython/core/tests/test_inputsplitter.py | 2 +-
IPython/core/tests/test_inputtransformer.py | 13 +
IPython/core/tests/test_interactiveshell.py | 15 +-
IPython/core/tests/test_magic.py | 30 +-
IPython/core/tests/test_oinspect.py | 41 +
IPython/core/tests/test_profile.py | 2 +-
IPython/core/tests/test_prompts.py | 24 +-
IPython/core/tests/test_pylabtools.py | 48 +-
IPython/core/tests/test_ultratb.py | 144 +
IPython/core/ultratb.py | 488 +-
IPython/extensions/autoreload.py | 2 +-
IPython/external/mathjax.py | 234 +-
IPython/external/qt_for_kernel.py | 51 +-
IPython/external/qt_loaders.py | 18 +-
IPython/lib/deepreload.py | 5 +-
IPython/lib/display.py | 14 +
IPython/lib/kernel.py | 3 +-
IPython/lib/latextools.py | 10 +-
IPython/lib/lexers.py | 1 +
IPython/lib/pretty.py | 27 +-
IPython/lib/tests/test_lexers.py | 15 +-
IPython/lib/tests/test_pretty.py | 82 +-
IPython/nbconvert.py | 2 +-
IPython/sphinxext/ipython_console_highlighting.py | 3 +-
IPython/sphinxext/ipython_directive.py | 19 +-
IPython/terminal/embed.py | 24 +-
IPython/terminal/interactiveshell.py | 213 +-
IPython/terminal/ipapp.py | 48 +-
IPython/testing/decorators.py | 12 +-
IPython/testing/iptest.py | 38 +-
IPython/testing/iptestcontroller.py | 2 +-
IPython/testing/plugin/ipdoctest.py | 4 +-
IPython/utils/PyColorize.py | 31 +-
IPython/utils/{signatures.py => _signatures.py} | 0
IPython/utils/_sysinfo.py | 2 +-
IPython/utils/coloransi.py | 2 +-
IPython/utils/contexts.py | 25 +-
IPython/utils/dir2.py | 2 +-
IPython/utils/frame.py | 2 +-
IPython/utils/io.py | 2 +
IPython/utils/py3compat.py | 7 +-
IPython/utils/signatures.py | 818 +-
IPython/utils/tests/test_pycolorize.py | 54 +-
IPython/utils/tests/test_text.py | 71 +-
IPython/utils/tests/test_tokenutil.py | 19 +
IPython/utils/text.py | 83 +-
IPython/utils/tokenutil.py | 23 +-
PKG-INFO | 7 +-
README.rst | 4 +-
docs/Makefile | 9 +-
docs/requirements.txt | 2 +-
docs/source/_static/favicon.ico | Bin 0 -> 1430 bytes
docs/source/conf.py | 5 +-
docs/source/config/callbacks.rst | 55 +-
docs/source/config/custommagics.rst | 3 +-
docs/source/config/extensions/index.rst | 8 +-
docs/source/coredev/index.rst | 18 +
docs/source/coredev/release_process.rst | 185 +
docs/source/development/figs/allconnections.png | Bin 32144 -> 0 bytes
docs/source/development/figs/allconnections.svg | 4012 -------
docs/source/development/figs/hbfade.png | Bin 38554 -> 0 bytes
docs/source/development/figs/iopubfade.png | Bin 39136 -> 0 bytes
docs/source/development/figs/nbconvert.png | Bin 23877 -> 0 bytes
docs/source/development/figs/nbconvert.svg | 195 -
.../development/figs/notebook_components.png | Bin 30974 -> 0 bytes
.../development/figs/notebook_components.svg | 596 -
docs/source/development/figs/notiffade.png | Bin 37583 -> 0 bytes
docs/source/development/figs/queryfade.png | Bin 38260 -> 0 bytes
docs/source/development/figs/queuefade.png | Bin 40459 -> 0 bytes
docs/source/development/how_ipython_works.rst | 45 +-
docs/source/development/index.rst | 25 +-
docs/source/development/kernels.rst | 143 +-
docs/source/development/parallel_connections.rst | 152 +-
docs/source/development/parallel_messages.rst | 367 +-
docs/source/development/wrapperkernels.rst | 10 +-
docs/source/index.rst | 9 +-
docs/source/install/kernel_install.rst | 60 +-
docs/source/interactive/index.rst | 2 +-
docs/source/interactive/plotting.rst | 2 +-
docs/source/interactive/python-ipython-diff.rst | 249 +
docs/source/interactive/qtconsole.rst | 654 -
docs/source/interactive/reference.rst | 63 +
docs/source/overview.rst | 8 +-
docs/source/whatsnew/development.rst | 4 +-
docs/source/whatsnew/github-stats-4.rst | 67 +
docs/source/whatsnew/version0.11.rst | 2 +-
docs/source/whatsnew/version4.rst | 31 +-
docs/sphinxext/github.py | 6 +-
docs/sphinxext/magics.py | 3 +
.../distributed-checkpoint.ipynb | 144 +
.../Custom Display Logic-checkpoint.ipynb | 737 ++
.../.ipynb_checkpoints/Untitled-checkpoint.ipynb | 6 +
.../Importing Notebooks.ipynb | 320 +-
examples/IPython Kernel/Index.ipynb | 5 +-
examples/IPython Kernel/Rich Output.ipynb | 6 +-
examples/IPython Kernel/Untitled.ipynb | 74 +
.../nbpackage/__init__.py | 0
.../nbpackage/mynotebook.ipynb | 0
.../nbpackage/nbs/__init__.py | 0
.../nbpackage/nbs/other.ipynb | 0
examples/Index.ipynb | 6 +-
.../Interactive Widgets/Beat Frequencies.ipynb | 120 -
.../Custom Widget - Hello World.ipynb | 793 --
.../Interactive Widgets/Date Picker Widget.ipynb | 838 --
.../Interactive Widgets/Exploring Graphs.ipynb | 117 -
.../Interactive Widgets/Export As (nbconvert).html | 11882 -------------------
.../Export As (nbconvert).ipynb | 186 -
examples/Interactive Widgets/Factoring.ipynb | 115 -
.../Interactive Widgets/File Upload Widget.ipynb | 187 -
examples/Interactive Widgets/Image Browser.ipynb | 119 -
.../Interactive Widgets/Image Processing.ipynb | 162 -
examples/Interactive Widgets/Index.ipynb | 108 -
.../Lorenz Differential Equations.ipynb | 290 -
.../Interactive Widgets/Nonblocking Console.ipynb | 239 -
examples/Interactive Widgets/Using Interact.ipynb | 629 -
.../Interactive Widgets/Variable Inspector.ipynb | 240 -
examples/Interactive Widgets/Widget Basics.ipynb | 445 -
examples/Interactive Widgets/Widget Events.ipynb | 383 -
examples/Interactive Widgets/Widget List.ipynb | 621 -
examples/Interactive Widgets/Widget Styling.ipynb | 585 -
.../images/MultilanguageKernels.graffle | 442 -
.../images/MultilanguageKernels.png | Bin 22608 -> 0 bytes
.../images/ParallelKernels.graffle | 876 --
.../Interactive Widgets/images/ParallelKernels.png | Bin 38764 -> 0 bytes
.../images/VizInteractCompute.graffle | 426 -
.../images/VizInteractCompute.png | Bin 30013 -> 0 bytes
.../Interactive Widgets/images/WidgetArch.graffle | 322 -
examples/Interactive Widgets/images/WidgetArch.png | Bin 23058 -> 0 bytes
.../images/WidgetModelView.graffle | 523 -
.../Interactive Widgets/images/WidgetModelView.png | Bin 38681 -> 0 bytes
.../Configuring the Notebook and Server.ipynb | 295 -
.../Notebook/Connecting with the Qt Console.ipynb | 132 -
.../Converting Notebooks With nbconvert.ipynb | 317 -
examples/Notebook/Custom Keyboard Shortcuts.ipynb | 113 -
examples/Notebook/Index.ipynb | 91 -
.../Notebook/JavaScript Notebook Extensions.ipynb | 612 -
examples/Notebook/Notebook Basics.ipynb | 313 -
examples/Notebook/Running Code.ipynb | 289 -
examples/Notebook/Typesetting Equations.ipynb | 271 -
.../Notebook/Using nbconvert as a Library.ipynb | 619 -
.../Notebook/What is the IPython Notebook.ipynb | 183 -
.../Notebook/Working With Markdown Cells.ipynb | 320 -
examples/Notebook/images/command_mode.png | Bin 6021 -> 0 bytes
examples/Notebook/images/dashboard_files_tab.png | Bin 116878 -> 0 bytes
.../Notebook/images/dashboard_files_tab_btns.png | Bin 13356 -> 0 bytes
.../Notebook/images/dashboard_files_tab_new.png | Bin 33908 -> 0 bytes
.../Notebook/images/dashboard_files_tab_run.png | Bin 85527 -> 0 bytes
examples/Notebook/images/dashboard_running_tab.png | Bin 211313 -> 0 bytes
examples/Notebook/images/edit_mode.png | Bin 6030 -> 0 bytes
examples/Notebook/images/menubar_toolbar.png | Bin 30328 -> 0 bytes
examples/Notebook/images/nbconvert_arch.png | Bin 114431 -> 0 bytes
examples/distributed.ipynb | 144 +
setup.py | 17 +-
setupbase.py | 15 +-
187 files changed, 3883 insertions(+), 32457 deletions(-)
diff --git a/IPython/core/alias.py b/IPython/core/alias.py
index d28cca5..b0dd2bf 100644
--- a/IPython/core/alias.py
+++ b/IPython/core/alias.py
@@ -131,6 +131,7 @@ class Alias(object):
self.shell = shell
self.name = name
self.cmd = cmd
+ self.__doc__ = "Alias for `!{}`".format(cmd)
self.nargs = self.validate()
def validate(self):
diff --git a/IPython/core/application.py b/IPython/core/application.py
index 3a23676..86cfdcd 100644
--- a/IPython/core/application.py
+++ b/IPython/core/application.py
@@ -185,7 +185,7 @@ class BaseIPythonApplication(Application):
super(BaseIPythonApplication, self).__init__(**kwargs)
# ensure current working directory exists
try:
- directory = py3compat.getcwd()
+ py3compat.getcwd()
except:
# exit if cwd doesn't exist
self.log.error("Current working directory doesn't exist.")
@@ -194,6 +194,21 @@ class BaseIPythonApplication(Application):
#-------------------------------------------------------------------------
# Various stages of Application creation
#-------------------------------------------------------------------------
+
+ deprecated_subcommands = {}
+
+ def initialize_subcommand(self, subc, argv=None):
+ if subc in self.deprecated_subcommands:
+ import time
+ self.log.warning("Subcommand `ipython {sub}` is deprecated and will be removed "
+ "in future versions.".format(sub=subc))
+ self.log.warning("You likely want to use `jupyter {sub}`... continue "
+ "in 5 sec. Press Ctrl-C to quit now.".format(sub=subc))
+ try:
+ time.sleep(5)
+ except KeyboardInterrupt:
+ sys.exit(1)
+ return super(BaseIPythonApplication, self).initialize_subcommand(subc, argv)
def init_crash_handler(self):
"""Create a crash handler, typically setting sys.excepthook to it."""
@@ -276,7 +291,7 @@ class BaseIPythonApplication(Application):
except ConfigFileNotFound:
# Only warn if the default config file was NOT being used.
if config_file_name in self.config_file_specified:
- msg = self.log.warn
+ msg = self.log.warning
else:
msg = self.log.debug
msg("Config file not found, skipping: %s", config_file_name)
@@ -284,7 +299,7 @@ class BaseIPythonApplication(Application):
# For testing purposes.
if not suppress_errors:
raise
- self.log.warn("Error loading config file: %s" %
+ self.log.warning("Error loading config file: %s" %
self.config_file_name, exc_info=True)
def init_profile_dir(self):
@@ -351,7 +366,7 @@ class BaseIPythonApplication(Application):
cfg = self.config_file_name
if path and os.path.exists(os.path.join(path, cfg)):
- self.log.warn("Staging %r from %s into %r [overwrite=%s]"%(
+ self.log.warning("Staging %r from %s into %r [overwrite=%s]"%(
cfg, src, self.profile_dir.location, self.overwrite)
)
self.profile_dir.copy_config_file(cfg, path=path, overwrite=self.overwrite)
@@ -366,7 +381,7 @@ class BaseIPythonApplication(Application):
cfg = os.path.basename(fullpath)
if self.profile_dir.copy_config_file(cfg, path=path, overwrite=False):
# file was copied
- self.log.warn("Staging bundled %s from %s into %r"%(
+ self.log.warning("Staging bundled %s from %s into %r"%(
cfg, self.profile, self.profile_dir.location)
)
@@ -376,7 +391,7 @@ class BaseIPythonApplication(Application):
s = self.generate_config_file()
fname = os.path.join(self.profile_dir.location, self.config_file_name)
if self.overwrite or not os.path.exists(fname):
- self.log.warn("Generating default config file: %r"%(fname))
+ self.log.warning("Generating default config file: %r"%(fname))
with open(fname, 'w') as f:
f.write(s)
@@ -394,4 +409,3 @@ class BaseIPythonApplication(Application):
self.load_config_file()
# enforce cl-opts override configfile opts:
self.update_config(cl_config)
-
diff --git a/IPython/core/builtin_trap.py b/IPython/core/builtin_trap.py
index 403f7b4..95c9ca4 100644
--- a/IPython/core/builtin_trap.py
+++ b/IPython/core/builtin_trap.py
@@ -57,7 +57,7 @@ class BuiltinTrap(Configurable):
from IPython.lib import deepreload
if self.shell.deep_reload:
from warnings import warn
- warn("Automatically replacing builtin `reload` by `deepreload.reload` is deprecated, please import `reload` explicitly from `IPython.lib.deeprelaod", DeprecationWarning)
+ warn("Automatically replacing builtin `reload` by `deepreload.reload` is deprecated and will be removed in IPython 6.0, please import `reload` explicitly from `IPython.lib.deeprelaod", DeprecationWarning)
self.auto_builtins['reload'] = deepreload._dreload
else:
self.auto_builtins['dreload']= deepreload._dreload
diff --git a/IPython/core/completer.py b/IPython/core/completer.py
index 5032aa5..4c793b4 100644
--- a/IPython/core/completer.py
+++ b/IPython/core/completer.py
@@ -839,22 +839,31 @@ class IPCompleter(Completer):
# for all others, check if they are __call__able
elif hasattr(obj, '__call__'):
call_obj = obj.__call__
-
ret += self._default_arguments_from_docstring(
getattr(call_obj, '__doc__', ''))
+ if PY3:
+ _keeps = (inspect.Parameter.KEYWORD_ONLY,
+ inspect.Parameter.POSITIONAL_OR_KEYWORD)
+ signature = inspect.signature
+ else:
+ import IPython.utils.signatures
+ _keeps = (IPython.utils.signatures.Parameter.KEYWORD_ONLY,
+ IPython.utils.signatures.Parameter.POSITIONAL_OR_KEYWORD)
+ signature = IPython.utils.signatures.signature
+
try:
- args,_,_1,defaults = inspect.getargspec(call_obj)
- if defaults:
- ret+=args[-len(defaults):]
- except TypeError:
+ sig = signature(call_obj)
+ ret.extend(k for k, v in sig.parameters.items() if
+ v.kind in _keeps)
+ except ValueError:
pass
return list(set(ret))
def python_func_kw_matches(self,text):
"""Match named parameters (kwargs) of the last open function"""
-
+
if "." in text: # a parameter cannot be dotted
return []
try: regexp = self.__funcParamsRegex
diff --git a/IPython/core/completerlib.py b/IPython/core/completerlib.py
index f76ea85..57dd2b5 100644
--- a/IPython/core/completerlib.py
+++ b/IPython/core/completerlib.py
@@ -223,7 +223,7 @@ def module_completion(line):
return ['import ']
# 'from xy<tab>' or 'import xy<tab>'
- if nwords < 3 and (words[0] in ['import','from']) :
+ if nwords < 3 and (words[0] in {'%aimport', 'import', 'from'}) :
if nwords == 1:
return get_root_modules()
mod = words[1].split('.')
diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py
index 609cce4..a1ba878 100644
--- a/IPython/core/debugger.py
+++ b/IPython/core/debugger.py
@@ -29,7 +29,6 @@ from __future__ import print_function
import bdb
import functools
import inspect
-import linecache
import sys
from IPython import get_ipython
@@ -54,7 +53,6 @@ if '--pydb' in sys.argv:
if has_pydb:
from pydb import Pdb as OldPdb
- #print "Using pydb for %run -d and post-mortem" #dbg
prompt = 'ipydb> '
else:
from pdb import Pdb as OldPdb
@@ -94,7 +92,7 @@ class Tracer(object):
"""
@skip_doctest
- def __init__(self,colors=None):
+ def __init__(self, colors=None):
"""Create a local debugger instance.
Parameters
@@ -113,7 +111,7 @@ class Tracer(object):
from IPython.core.debugger import Tracer; debug_here = Tracer()
Later in your code::
-
+
debug_here() # -> will open up the debugger at that point.
Once the debugger activates, you can use all of its regular commands to
@@ -202,16 +200,21 @@ class Pdb(OldPdb):
"""Modified Pdb class, does not load readline."""
def __init__(self,color_scheme='NoColor',completekey=None,
- stdin=None, stdout=None):
+ stdin=None, stdout=None, context=5):
# Parent constructor:
+ try:
+ self.context=int(context)
+ if self.context <= 0:
+ raise ValueError("Context must be a positive integer")
+ except (TypeError, ValueError):
+ raise ValueError("Context must be a positive integer")
+
if has_pydb and completekey is None:
OldPdb.__init__(self,stdin=stdin,stdout=io.stdout)
else:
OldPdb.__init__(self,completekey,stdin,stdout)
- self.prompt = prompt # The default prompt is '(Pdb)'
-
# IPython changes...
self.is_pydb = has_pydb
@@ -253,12 +256,15 @@ class Pdb(OldPdb):
C = coloransi.TermColors
cst = self.color_scheme_table
+ cst['NoColor'].colors.prompt = C.NoColor
cst['NoColor'].colors.breakpoint_enabled = C.NoColor
cst['NoColor'].colors.breakpoint_disabled = C.NoColor
+ cst['Linux'].colors.prompt = C.Green
cst['Linux'].colors.breakpoint_enabled = C.LightRed
cst['Linux'].colors.breakpoint_disabled = C.Red
+ cst['LightBG'].colors.prompt = C.Blue
cst['LightBG'].colors.breakpoint_enabled = C.LightRed
cst['LightBG'].colors.breakpoint_disabled = C.Red
@@ -268,6 +274,10 @@ class Pdb(OldPdb):
# debugging.
self.parser = PyColorize.Parser()
+ # Set the prompt
+ Colors = cst.active_colors
+ self.prompt = u'%s%s%s' % (Colors.prompt, prompt, Colors.Normal) # The default prompt is '(Pdb)'
+
def set_colors(self, scheme):
"""Shorthand access to the color table scheme selector method."""
self.color_scheme_table.set_active_scheme(scheme)
@@ -277,11 +287,14 @@ class Pdb(OldPdb):
while True:
try:
OldPdb.interaction(self, frame, traceback)
+ break
except KeyboardInterrupt:
self.shell.write('\n' + self.shell.get_exception_only())
break
- else:
- break
+ finally:
+ # Pdb sets readline delimiters, so set them back to our own
+ if self.shell.readline is not None:
+ self.shell.readline.set_completer_delims(self.shell.readline_delims)
def new_do_up(self, arg):
OldPdb.do_up(self, arg)
@@ -303,10 +316,6 @@ class Pdb(OldPdb):
if hasattr(self, 'old_all_completions'):
self.shell.Completer.all_completions=self.old_all_completions
- # Pdb sets readline delimiters, so set them back to our own
- if self.shell.readline is not None:
- self.shell.readline.set_completer_delims(self.shell.readline_delims)
-
return OldPdb.do_quit(self, arg)
do_q = do_quit = decorate_fn_with_doc(new_do_quit, OldPdb.do_quit)
@@ -320,16 +329,31 @@ class Pdb(OldPdb):
def postloop(self):
self.shell.set_completer_frame(None)
- def print_stack_trace(self):
+ def print_stack_trace(self, context=None):
+ if context is None:
+ context = self.context
+ try:
+ context=int(context)
+ if context <= 0:
+ raise ValueError("Context must be a positive integer")
+ except (TypeError, ValueError):
+ raise ValueError("Context must be a positive integer")
try:
for frame_lineno in self.stack:
- self.print_stack_entry(frame_lineno, context = 5)
+ self.print_stack_entry(frame_lineno, context=context)
except KeyboardInterrupt:
pass
def print_stack_entry(self,frame_lineno,prompt_prefix='\n-> ',
- context = 3):
- #frame, lineno = frame_lineno
+ context=None):
+ if context is None:
+ context = self.context
+ try:
+ context=int(context)
+ if context <= 0:
+ raise ValueError("Context must be a positive integer")
+ except (TypeError, ValueError):
+ raise ValueError("Context must be a positive integer")
print(self.format_stack_entry(frame_lineno, '', context), file=io.stdout)
# vds: >>
@@ -338,7 +362,15 @@ class Pdb(OldPdb):
self.shell.hooks.synchronize_with_editor(filename, lineno, 0)
# vds: <<
- def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3):
+ def format_stack_entry(self, frame_lineno, lprefix=': ', context=None):
+ if context is None:
+ context = self.context
+ try:
+ context=int(context)
+ if context <= 0:
+ print("Context must be a positive integer")
+ except (TypeError, ValueError):
+ print("Context must be a positive integer")
try:
import reprlib # Py 3
except ImportError:
@@ -526,7 +558,6 @@ class Pdb(OldPdb):
def do_longlist(self, arg):
self.lastcmd = 'longlist'
filename = self.curframe.f_code.co_filename
- breaklist = self.get_file_breaks(filename)
try:
lines, lineno = self.getsourcelines(self.curframe)
except OSError as err:
@@ -582,3 +613,20 @@ class Pdb(OldPdb):
namespaces = [('Locals', self.curframe.f_locals),
('Globals', self.curframe.f_globals)]
self.shell.find_line_magic('psource')(arg, namespaces=namespaces)
+
+ if sys.version_info > (3, ):
+ def do_where(self, arg):
+ """w(here)
+ Print a stack trace, with the most recent frame at the bottom.
+ An arrow indicates the "current frame", which determines the
+ context of most commands. 'bt' is an alias for this command.
+
+ Take a number as argument as an (optional) number of context line to
+ print"""
+ if arg:
+ context = int(arg)
+ self.print_stack_trace(context)
+ else:
+ self.print_stack_trace()
+
+ do_w = do_where
diff --git a/IPython/core/display.py b/IPython/core/display.py
index 2934bee..bf9590a 100644
--- a/IPython/core/display.py
+++ b/IPython/core/display.py
@@ -12,7 +12,6 @@ import os
import struct
import warnings
-from IPython.core.formatters import _safe_get_formatter_method
from IPython.utils.py3compat import (string_types, cast_bytes_py2, cast_unicode,
unicode_type)
from IPython.testing.skipdoctest import skip_doctest
@@ -185,6 +184,9 @@ def display_pretty(*objs, **kwargs):
def display_html(*objs, **kwargs):
"""Display the HTML representation of an object.
+
+ Note: If raw=False and the object does not have a HTML
+ representation, no HTML will be shown.
Parameters
----------
@@ -637,7 +639,7 @@ class Image(DisplayObject):
_FMT_PNG = u'png'
_ACCEPTABLE_EMBEDDINGS = [_FMT_JPEG, _FMT_PNG]
- def __init__(self, data=None, url=None, filename=None, format=u'png',
+ def __init__(self, data=None, url=None, filename=None, format=None,
embed=None, width=None, height=None, retina=False,
unconfined=False, metadata=None):
"""Create a PNG/JPEG image object given raw data.
@@ -714,17 +716,27 @@ class Image(DisplayObject):
else:
ext = None
- if ext is not None:
- format = ext.lower()
- if ext == u'jpg' or ext == u'jpeg':
- format = self._FMT_JPEG
- if ext == u'png':
- format = self._FMT_PNG
- elif isinstance(data, bytes) and format == 'png':
- # infer image type from image data header,
- # only if format might not have been specified.
- if data[:2] == _JPEG:
- format = 'jpeg'
+ if format is None:
+ if ext is not None:
+ if ext == u'jpg' or ext == u'jpeg':
+ format = self._FMT_JPEG
+ if ext == u'png':
+ format = self._FMT_PNG
+ else:
+ format = ext.lower()
+ elif isinstance(data, bytes):
+ # infer image type from image data header,
+ # only if format has not been specified.
+ if data[:2] == _JPEG:
+ format = self._FMT_JPEG
+
+ # failed to detect format, default png
+ if format is None:
+ format = 'png'
+
+ if format.lower() == 'jpg':
+ # jpg->jpeg
+ format = self._FMT_JPEG
self.format = unicode_type(format).lower()
self.embed = embed if embed is not None else (url is None)
diff --git a/IPython/core/excolors.py b/IPython/core/excolors.py
index 27a1d6a..9d57258 100644
--- a/IPython/core/excolors.py
+++ b/IPython/core/excolors.py
@@ -3,6 +3,8 @@
Color schemes for exception handling code in IPython.
"""
+import warnings
+
#*****************************************************************************
# Copyright (C) 2005-2006 Fernando Perez <fperez at colorado.edu>
#
@@ -127,9 +129,19 @@ def exception_colors():
return ex_colors
+class Deprec(object):
+
+ def __init__(self, wrapped_obj):
+ self.wrapped=wrapped_obj
+
+ def __getattr__(self, name):
+ val = getattr(self.wrapped, name)
+ warnings.warn("Using ExceptionColors global is deprecated and will be removed in IPython 6.0", DeprecationWarning)
+ # using getattr after warnings break ipydoctest in weird way for 3.5
+ return val
# For backwards compatibility, keep around a single global object. Note that
# this should NOT be used, the factory function should be used instead, since
# these objects are stateful and it's very easy to get strange bugs if any code
# modifies the module-level object's state.
-ExceptionColors = exception_colors()
+ExceptionColors = Deprec(exception_colors())
diff --git a/IPython/core/extensions.py b/IPython/core/extensions.py
index f31dd83..cd1dd59 100644
--- a/IPython/core/extensions.py
+++ b/IPython/core/extensions.py
@@ -59,11 +59,6 @@ class ExtensionManager(Configurable):
)
self.loaded = set()
- def __del__(self):
- self.shell.on_trait_change(
- self._on_ipython_dir_changed, 'ipython_dir', remove=True
- )
-
@property
def ipython_extension_dir(self):
return os.path.join(self.shell.ipython_dir, u'extensions')
diff --git a/IPython/core/formatters.py b/IPython/core/formatters.py
index 3a7d598..aa05679 100644
--- a/IPython/core/formatters.py
+++ b/IPython/core/formatters.py
@@ -62,6 +62,8 @@ class DisplayFormatter(Configurable):
def _plain_text_only_changed(self, name, old, new):
warnings.warn("""DisplayFormatter.plain_text_only is deprecated.
+ It will be removed in IPython 5.0
+
Use DisplayFormatter.active_types = ['text/plain']
for the same effect.
""", DeprecationWarning)
diff --git a/IPython/core/history.py b/IPython/core/history.py
index adae60d..f638703 100644
--- a/IPython/core/history.py
+++ b/IPython/core/history.py
@@ -513,12 +513,18 @@ class HistoryManager(HistoryAccessor):
self.save_flag = threading.Event()
self.db_input_cache_lock = threading.Lock()
self.db_output_cache_lock = threading.Lock()
+
+ try:
+ self.new_session()
+ except OperationalError:
+ self.log.error("Failed to create history session in %s. History will not be saved.",
+ self.hist_file, exc_info=True)
+ self.hist_file = ':memory:'
+
if self.enabled and self.hist_file != ':memory:':
self.save_thread = HistorySavingThread(self)
self.save_thread.start()
- self.new_session()
-
def _get_hist_file_name(self, profile=None):
"""Get default history file name based on the Shell's profile.
diff --git a/IPython/core/inputtransformer.py b/IPython/core/inputtransformer.py
index daf40b0..cd8519b 100644
--- a/IPython/core/inputtransformer.py
+++ b/IPython/core/inputtransformer.py
@@ -400,7 +400,7 @@ def cellmagic(end_on_blank_line=False):
line = tpl % (magic_name, first, u'\n'.join(body))
-def _strip_prompts(prompt_re, initial_re=None):
+def _strip_prompts(prompt_re, initial_re=None, turnoff_re=None):
"""Remove matching input prompts from a block of input.
Parameters
@@ -428,6 +428,14 @@ def _strip_prompts(prompt_re, initial_re=None):
if line is None:
continue
out, n1 = initial_re.subn('', line, count=1)
+ if turnoff_re and not n1:
+ if turnoff_re.match(line):
+ # We're in e.g. a cell magic; disable this transformer for
+ # the rest of the cell.
+ while line is not None:
+ line = (yield line)
+ continue
+
line = (yield out)
if line is None:
@@ -455,14 +463,18 @@ def classic_prompt():
# FIXME: non-capturing version (?:...) usable?
prompt_re = re.compile(r'^(>>>|\.\.\.)( |$)')
initial_re = re.compile(r'^>>>( |$)')
- return _strip_prompts(prompt_re, initial_re)
+ # Any %magic/!system is IPython syntax, so we needn't look for >>> prompts
+ turnoff_re = re.compile(r'^[%!]')
+ return _strip_prompts(prompt_re, initial_re, turnoff_re)
@CoroutineInputTransformer.wrap
def ipy_prompt():
"""Strip IPython's In [1]:/...: prompts."""
# FIXME: non-capturing version (?:...) usable?
prompt_re = re.compile(r'^(In \[\d+\]: |\s*\.{3,}: ?)')
- return _strip_prompts(prompt_re)
+ # Disable prompt stripping inside cell magics
+ turnoff_re = re.compile(r'^%%')
+ return _strip_prompts(prompt_re, turnoff_re=turnoff_re)
@CoroutineInputTransformer.wrap
diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
index 61079ac..9486475 100644
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -62,6 +62,7 @@ from IPython.utils import PyColorize
from IPython.utils import io
from IPython.utils import py3compat
from IPython.utils import openpy
+from IPython.utils.contexts import NoOpContext
from IPython.utils.decorators import undoc
from IPython.utils.io import ask_yes_no
from IPython.utils.ipstruct import Struct
@@ -109,11 +110,6 @@ def softspace(file, newvalue):
@undoc
def no_op(*a, **kw): pass
- at undoc
-class NoOpContext(object):
- def __enter__(self): pass
- def __exit__(self, type, value, traceback): pass
-no_op_context = NoOpContext()
class SpaceInInput(Exception): pass
@@ -142,52 +138,6 @@ class SeparateUnicode(Unicode):
return super(SeparateUnicode, self).validate(obj, value)
-class ReadlineNoRecord(object):
- """Context manager to execute some code, then reload readline history
- so that interactive input to the code doesn't appear when pressing up."""
- def __init__(self, shell):
- self.shell = shell
- self._nested_level = 0
-
- def __enter__(self):
- if self._nested_level == 0:
- try:
- self.orig_length = self.current_length()
- self.readline_tail = self.get_readline_tail()
- except (AttributeError, IndexError): # Can fail with pyreadline
- self.orig_length, self.readline_tail = 999999, []
- self._nested_level += 1
-
- def __exit__(self, type, value, traceback):
- self._nested_level -= 1
- if self._nested_level == 0:
- # Try clipping the end if it's got longer
- try:
- e = self.current_length() - self.orig_length
- if e > 0:
- for _ in range(e):
- self.shell.readline.remove_history_item(self.orig_length)
-
- # If it still doesn't match, just reload readline history.
- if self.current_length() != self.orig_length \
- or self.get_readline_tail() != self.readline_tail:
- self.shell.refill_readline_hist()
- except (AttributeError, IndexError):
- pass
- # Returning False will cause exceptions to propagate
- return False
-
- def current_length(self):
- return self.shell.readline.get_current_history_length()
-
- def get_readline_tail(self, n=10):
- """Get the last n items in readline history."""
- end = self.shell.readline.get_current_history_length() + 1
- start = max(end-n, 1)
- ghi = self.shell.readline.get_history_item
- return [ghi(x) for x in range(start, end)]
-
-
@undoc
class DummyMod(object):
"""A dummy module used for IPython's interactive module when
@@ -294,6 +244,8 @@ class InteractiveShell(SingletonConfigurable):
"""
**Deprecated**
+ Will be removed in IPython 6.0
+
Enable deep (recursive) reloading by default. IPython can use the
deep_reload module which reloads changes in modules recursively (it
replaces the reload() function, so you don't need to change anything to
@@ -365,13 +317,13 @@ class InteractiveShell(SingletonConfigurable):
# deprecated prompt traits:
prompt_in1 = Unicode('In [\\#]: ', config=True,
- help="Deprecated, use PromptManager.in_template")
+ help="Deprecated, will be removed in IPython 5.0, use PromptManager.in_template")
prompt_in2 = Unicode(' .\\D.: ', config=True,
- help="Deprecated, use PromptManager.in2_template")
+ help="Deprecated, will be removed in IPython 5.0, use PromptManager.in2_template")
prompt_out = Unicode('Out[\\#]: ', config=True,
- help="Deprecated, use PromptManager.out_template")
+ help="Deprecated, will be removed in IPython 5.0, use PromptManager.out_template")
prompts_pad_left = CBool(True, config=True,
- help="Deprecated, use PromptManager.justify")
+ help="Deprecated, will be removed in IPython 5.0, use PromptManager.justify")
def _prompt_trait_changed(self, name, old, new):
table = {
@@ -804,11 +756,10 @@ class InteractiveShell(SingletonConfigurable):
This has to be called after self.user_module is created.
"""
- self._orig_sys_module_state = {}
- self._orig_sys_module_state['stdin'] = sys.stdin
- self._orig_sys_module_state['stdout'] = sys.stdout
- self._orig_sys_module_state['stderr'] = sys.stderr
- self._orig_sys_module_state['excepthook'] = sys.excepthook
+ self._orig_sys_module_state = {'stdin': sys.stdin,
+ 'stdout': sys.stdout,
+ 'stderr': sys.stderr,
+ 'excepthook': sys.excepthook}
self._orig_sys_modules_main_name = self.user_module.__name__
self._orig_sys_modules_main_mod = sys.modules.get(self.user_module.__name__)
@@ -1103,7 +1054,7 @@ class InteractiveShell(SingletonConfigurable):
# Now that FakeModule produces a real module, we've run into a nasty
# problem: after script execution (via %run), the module where the user
# code ran is deleted. Now that this object is a true module (needed
- # so docetst and other tools work correctly), the Python module
+ # so doctest and other tools work correctly), the Python module
# teardown mechanism runs over it, and sets to None every variable
# present in that module. Top-level references to objects from the
# script survive, because the user_ns is updated with them. However,
@@ -1217,7 +1168,7 @@ class InteractiveShell(SingletonConfigurable):
# user_ns, and we sync that contents into user_ns_hidden so that these
# initial variables aren't shown by %who. After the sync, we add the
# rest of what we *do* want the user to see with %who even on a new
- # session (probably nothing, so theye really only see their own stuff)
+ # session (probably nothing, so they really only see their own stuff)
# The user dict must *always* have a __builtin__ reference to the
# Python standard __builtin__ namespace, which must be imported.
@@ -1460,7 +1411,6 @@ class InteractiveShell(SingletonConfigurable):
not py3compat.isidentifier(oname, dotted=True):
return dict(found=False)
- alias_ns = None
if namespaces is None:
# Namespaces to search in:
# Put them in a list. The order is important so that we
@@ -1471,7 +1421,7 @@ class InteractiveShell(SingletonConfigurable):
]
# initialize results to 'null'
- found = False; obj = None; ospace = None; ds = None;
+ found = False; obj = None; ospace = None;
ismagic = False; isalias = False; parent = None
# We need to special-case 'print', which as of python2.6 registers as a
@@ -1935,120 +1885,17 @@ class InteractiveShell(SingletonConfigurable):
#-------------------------------------------------------------------------
def init_readline(self):
- """Command history completion/saving/reloading."""
-
- if self.readline_use:
- import IPython.utils.rlineimpl as readline
-
- self.rl_next_input = None
- self.rl_do_indent = False
-
- if not self.readline_use or not readline.have_readline:
- self.has_readline = False
- self.readline = None
- # Set a number of methods that depend on readline to be no-op
- self.readline_no_record = no_op_context
- self.set_readline_completer = no_op
- self.set_custom_completer = no_op
- if self.readline_use:
- warn('Readline services not available or not loaded.')
- else:
- self.has_readline = True
- self.readline = readline
- sys.modules['readline'] = readline
-
- # Platform-specific configuration
- if os.name == 'nt':
- # FIXME - check with Frederick to see if we can harmonize
- # naming conventions with pyreadline to avoid this
- # platform-dependent check
- self.readline_startup_hook = readline.set_pre_input_hook
- else:
- self.readline_startup_hook = readline.set_startup_hook
-
- # Readline config order:
- # - IPython config (default value)
- # - custom inputrc
- # - IPython config (user customized)
-
- # load IPython config before inputrc if default
- # skip if libedit because parse_and_bind syntax is different
- if not self._custom_readline_config and not readline.uses_libedit:
- for rlcommand in self.readline_parse_and_bind:
- readline.parse_and_bind(rlcommand)
-
- # Load user's initrc file (readline config)
- # Or if libedit is used, load editrc.
- inputrc_name = os.environ.get('INPUTRC')
- if inputrc_name is None:
- inputrc_name = '.inputrc'
- if readline.uses_libedit:
- inputrc_name = '.editrc'
- inputrc_name = os.path.join(self.home_dir, inputrc_name)
- if os.path.isfile(inputrc_name):
- try:
- readline.read_init_file(inputrc_name)
- except:
- warn('Problems reading readline initialization file <%s>'
- % inputrc_name)
-
- # load IPython config after inputrc if user has customized
- if self._custom_readline_config:
- for rlcommand in self.readline_parse_and_bind:
- readline.parse_and_bind(rlcommand)
-
- # Remove some chars from the delimiters list. If we encounter
- # unicode chars, discard them.
- delims = readline.get_completer_delims()
- if not py3compat.PY3:
- delims = delims.encode("ascii", "ignore")
- for d in self.readline_remove_delims:
- delims = delims.replace(d, "")
- delims = delims.replace(ESC_MAGIC, '')
- readline.set_completer_delims(delims)
- # Store these so we can restore them if something like rpy2 modifies
- # them.
- self.readline_delims = delims
... 39104 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/ipython4.git
More information about the Python-modules-commits
mailing list