##// END OF EJS Templates
Document how to change the default predicates for the debugger....
Matthias Bussonnier -
Show More
@@ -1,924 +1,946 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 Pdb debugger class.
3 Pdb debugger class.
4
4
5 Modified from the standard pdb.Pdb class to avoid including readline, so that
5 Modified from the standard pdb.Pdb class to avoid including readline, so that
6 the command line completion of other programs which include this isn't
6 the command line completion of other programs which include this isn't
7 damaged.
7 damaged.
8
8
9 In the future, this class will be expanded with improvements over the standard
9 In the future, this class will be expanded with improvements over the standard
10 pdb.
10 pdb.
11
11
12 The code in this file is mainly lifted out of cmd.py in Python 2.2, with minor
12 The code in this file is mainly lifted out of cmd.py in Python 2.2, with minor
13 changes. Licensing should therefore be under the standard Python terms. For
13 changes. Licensing should therefore be under the standard Python terms. For
14 details on the PSF (Python Software Foundation) standard license, see:
14 details on the PSF (Python Software Foundation) standard license, see:
15
15
16 https://docs.python.org/2/license.html
16 https://docs.python.org/2/license.html
17 """
17 """
18
18
19 #*****************************************************************************
19 #*****************************************************************************
20 #
20 #
21 # This file is licensed under the PSF license.
21 # This file is licensed under the PSF license.
22 #
22 #
23 # Copyright (C) 2001 Python Software Foundation, www.python.org
23 # Copyright (C) 2001 Python Software Foundation, www.python.org
24 # Copyright (C) 2005-2006 Fernando Perez. <fperez@colorado.edu>
24 # Copyright (C) 2005-2006 Fernando Perez. <fperez@colorado.edu>
25 #
25 #
26 #
26 #
27 #*****************************************************************************
27 #*****************************************************************************
28
28
29 import bdb
29 import bdb
30 import functools
30 import functools
31 import inspect
31 import inspect
32 import linecache
32 import linecache
33 import sys
33 import sys
34 import warnings
34 import warnings
35 import re
35 import re
36 import os
36 import os
37
37
38 from IPython import get_ipython
38 from IPython import get_ipython
39 from IPython.utils import PyColorize
39 from IPython.utils import PyColorize
40 from IPython.utils import coloransi, py3compat
40 from IPython.utils import coloransi, py3compat
41 from IPython.core.excolors import exception_colors
41 from IPython.core.excolors import exception_colors
42 from IPython.testing.skipdoctest import skip_doctest
42 from IPython.testing.skipdoctest import skip_doctest
43
43
44
44
45 prompt = 'ipdb> '
45 prompt = 'ipdb> '
46
46
47 # We have to check this directly from sys.argv, config struct not yet available
47 # We have to check this directly from sys.argv, config struct not yet available
48 from pdb import Pdb as OldPdb
48 from pdb import Pdb as OldPdb
49
49
50 # Allow the set_trace code to operate outside of an ipython instance, even if
50 # Allow the set_trace code to operate outside of an ipython instance, even if
51 # it does so with some limitations. The rest of this support is implemented in
51 # it does so with some limitations. The rest of this support is implemented in
52 # the Tracer constructor.
52 # the Tracer constructor.
53
53
54
54
55 def make_arrow(pad):
55 def make_arrow(pad):
56 """generate the leading arrow in front of traceback or debugger"""
56 """generate the leading arrow in front of traceback or debugger"""
57 if pad >= 2:
57 if pad >= 2:
58 return '-'*(pad-2) + '> '
58 return '-'*(pad-2) + '> '
59 elif pad == 1:
59 elif pad == 1:
60 return '>'
60 return '>'
61 return ''
61 return ''
62
62
63
63
64 def BdbQuit_excepthook(et, ev, tb, excepthook=None):
64 def BdbQuit_excepthook(et, ev, tb, excepthook=None):
65 """Exception hook which handles `BdbQuit` exceptions.
65 """Exception hook which handles `BdbQuit` exceptions.
66
66
67 All other exceptions are processed using the `excepthook`
67 All other exceptions are processed using the `excepthook`
68 parameter.
68 parameter.
69 """
69 """
70 warnings.warn("`BdbQuit_excepthook` is deprecated since version 5.1",
70 warnings.warn("`BdbQuit_excepthook` is deprecated since version 5.1",
71 DeprecationWarning, stacklevel=2)
71 DeprecationWarning, stacklevel=2)
72 if et == bdb.BdbQuit:
72 if et == bdb.BdbQuit:
73 print('Exiting Debugger.')
73 print('Exiting Debugger.')
74 elif excepthook is not None:
74 elif excepthook is not None:
75 excepthook(et, ev, tb)
75 excepthook(et, ev, tb)
76 else:
76 else:
77 # Backwards compatibility. Raise deprecation warning?
77 # Backwards compatibility. Raise deprecation warning?
78 BdbQuit_excepthook.excepthook_ori(et, ev, tb)
78 BdbQuit_excepthook.excepthook_ori(et, ev, tb)
79
79
80
80
81 def BdbQuit_IPython_excepthook(self, et, ev, tb, tb_offset=None):
81 def BdbQuit_IPython_excepthook(self, et, ev, tb, tb_offset=None):
82 warnings.warn(
82 warnings.warn(
83 "`BdbQuit_IPython_excepthook` is deprecated since version 5.1",
83 "`BdbQuit_IPython_excepthook` is deprecated since version 5.1",
84 DeprecationWarning, stacklevel=2)
84 DeprecationWarning, stacklevel=2)
85 print('Exiting Debugger.')
85 print('Exiting Debugger.')
86
86
87
87
88 class Tracer(object):
88 class Tracer(object):
89 """
89 """
90 DEPRECATED
90 DEPRECATED
91
91
92 Class for local debugging, similar to pdb.set_trace.
92 Class for local debugging, similar to pdb.set_trace.
93
93
94 Instances of this class, when called, behave like pdb.set_trace, but
94 Instances of this class, when called, behave like pdb.set_trace, but
95 providing IPython's enhanced capabilities.
95 providing IPython's enhanced capabilities.
96
96
97 This is implemented as a class which must be initialized in your own code
97 This is implemented as a class which must be initialized in your own code
98 and not as a standalone function because we need to detect at runtime
98 and not as a standalone function because we need to detect at runtime
99 whether IPython is already active or not. That detection is done in the
99 whether IPython is already active or not. That detection is done in the
100 constructor, ensuring that this code plays nicely with a running IPython,
100 constructor, ensuring that this code plays nicely with a running IPython,
101 while functioning acceptably (though with limitations) if outside of it.
101 while functioning acceptably (though with limitations) if outside of it.
102 """
102 """
103
103
104 @skip_doctest
104 @skip_doctest
105 def __init__(self, colors=None):
105 def __init__(self, colors=None):
106 """
106 """
107 DEPRECATED
107 DEPRECATED
108
108
109 Create a local debugger instance.
109 Create a local debugger instance.
110
110
111 Parameters
111 Parameters
112 ----------
112 ----------
113 colors : str, optional
113 colors : str, optional
114 The name of the color scheme to use, it must be one of IPython's
114 The name of the color scheme to use, it must be one of IPython's
115 valid color schemes. If not given, the function will default to
115 valid color schemes. If not given, the function will default to
116 the current IPython scheme when running inside IPython, and to
116 the current IPython scheme when running inside IPython, and to
117 'NoColor' otherwise.
117 'NoColor' otherwise.
118
118
119 Examples
119 Examples
120 --------
120 --------
121 ::
121 ::
122
122
123 from IPython.core.debugger import Tracer; debug_here = Tracer()
123 from IPython.core.debugger import Tracer; debug_here = Tracer()
124
124
125 Later in your code::
125 Later in your code::
126
126
127 debug_here() # -> will open up the debugger at that point.
127 debug_here() # -> will open up the debugger at that point.
128
128
129 Once the debugger activates, you can use all of its regular commands to
129 Once the debugger activates, you can use all of its regular commands to
130 step through code, set breakpoints, etc. See the pdb documentation
130 step through code, set breakpoints, etc. See the pdb documentation
131 from the Python standard library for usage details.
131 from the Python standard library for usage details.
132 """
132 """
133 warnings.warn("`Tracer` is deprecated since version 5.1, directly use "
133 warnings.warn("`Tracer` is deprecated since version 5.1, directly use "
134 "`IPython.core.debugger.Pdb.set_trace()`",
134 "`IPython.core.debugger.Pdb.set_trace()`",
135 DeprecationWarning, stacklevel=2)
135 DeprecationWarning, stacklevel=2)
136
136
137 ip = get_ipython()
137 ip = get_ipython()
138 if ip is None:
138 if ip is None:
139 # Outside of ipython, we set our own exception hook manually
139 # Outside of ipython, we set our own exception hook manually
140 sys.excepthook = functools.partial(BdbQuit_excepthook,
140 sys.excepthook = functools.partial(BdbQuit_excepthook,
141 excepthook=sys.excepthook)
141 excepthook=sys.excepthook)
142 def_colors = 'NoColor'
142 def_colors = 'NoColor'
143 else:
143 else:
144 # In ipython, we use its custom exception handler mechanism
144 # In ipython, we use its custom exception handler mechanism
145 def_colors = ip.colors
145 def_colors = ip.colors
146 ip.set_custom_exc((bdb.BdbQuit,), BdbQuit_IPython_excepthook)
146 ip.set_custom_exc((bdb.BdbQuit,), BdbQuit_IPython_excepthook)
147
147
148 if colors is None:
148 if colors is None:
149 colors = def_colors
149 colors = def_colors
150
150
151 # The stdlib debugger internally uses a modified repr from the `repr`
151 # The stdlib debugger internally uses a modified repr from the `repr`
152 # module, that limits the length of printed strings to a hardcoded
152 # module, that limits the length of printed strings to a hardcoded
153 # limit of 30 characters. That much trimming is too aggressive, let's
153 # limit of 30 characters. That much trimming is too aggressive, let's
154 # at least raise that limit to 80 chars, which should be enough for
154 # at least raise that limit to 80 chars, which should be enough for
155 # most interactive uses.
155 # most interactive uses.
156 try:
156 try:
157 from reprlib import aRepr
157 from reprlib import aRepr
158 aRepr.maxstring = 80
158 aRepr.maxstring = 80
159 except:
159 except:
160 # This is only a user-facing convenience, so any error we encounter
160 # This is only a user-facing convenience, so any error we encounter
161 # here can be warned about but can be otherwise ignored. These
161 # here can be warned about but can be otherwise ignored. These
162 # printouts will tell us about problems if this API changes
162 # printouts will tell us about problems if this API changes
163 import traceback
163 import traceback
164 traceback.print_exc()
164 traceback.print_exc()
165
165
166 self.debugger = Pdb(colors)
166 self.debugger = Pdb(colors)
167
167
168 def __call__(self):
168 def __call__(self):
169 """Starts an interactive debugger at the point where called.
169 """Starts an interactive debugger at the point where called.
170
170
171 This is similar to the pdb.set_trace() function from the std lib, but
171 This is similar to the pdb.set_trace() function from the std lib, but
172 using IPython's enhanced debugger."""
172 using IPython's enhanced debugger."""
173
173
174 self.debugger.set_trace(sys._getframe().f_back)
174 self.debugger.set_trace(sys._getframe().f_back)
175
175
176
176
177 RGX_EXTRA_INDENT = re.compile(r'(?<=\n)\s+')
177 RGX_EXTRA_INDENT = re.compile(r'(?<=\n)\s+')
178
178
179
179
180 def strip_indentation(multiline_string):
180 def strip_indentation(multiline_string):
181 return RGX_EXTRA_INDENT.sub('', multiline_string)
181 return RGX_EXTRA_INDENT.sub('', multiline_string)
182
182
183
183
184 def decorate_fn_with_doc(new_fn, old_fn, additional_text=""):
184 def decorate_fn_with_doc(new_fn, old_fn, additional_text=""):
185 """Make new_fn have old_fn's doc string. This is particularly useful
185 """Make new_fn have old_fn's doc string. This is particularly useful
186 for the ``do_...`` commands that hook into the help system.
186 for the ``do_...`` commands that hook into the help system.
187 Adapted from from a comp.lang.python posting
187 Adapted from from a comp.lang.python posting
188 by Duncan Booth."""
188 by Duncan Booth."""
189 def wrapper(*args, **kw):
189 def wrapper(*args, **kw):
190 return new_fn(*args, **kw)
190 return new_fn(*args, **kw)
191 if old_fn.__doc__:
191 if old_fn.__doc__:
192 wrapper.__doc__ = strip_indentation(old_fn.__doc__) + additional_text
192 wrapper.__doc__ = strip_indentation(old_fn.__doc__) + additional_text
193 return wrapper
193 return wrapper
194
194
195
195
196 class Pdb(OldPdb):
196 class Pdb(OldPdb):
197 """Modified Pdb class, does not load readline.
197 """Modified Pdb class, does not load readline.
198
198
199 for a standalone version that uses prompt_toolkit, see
199 for a standalone version that uses prompt_toolkit, see
200 `IPython.terminal.debugger.TerminalPdb` and
200 `IPython.terminal.debugger.TerminalPdb` and
201 `IPython.terminal.debugger.set_trace()`
201 `IPython.terminal.debugger.set_trace()`
202
203
204 This debugger can hide and skip frames that are tagged according to some predicates.
205 See the `skip_predicates` commands.
206
202 """
207 """
203
208
209 default_predicates = {"tbhide": True, "readonly": False, "ipython_internal": True}
210
204 def __init__(self, color_scheme=None, completekey=None,
211 def __init__(self, color_scheme=None, completekey=None,
205 stdin=None, stdout=None, context=5, **kwargs):
212 stdin=None, stdout=None, context=5, **kwargs):
206 """Create a new IPython debugger.
213 """Create a new IPython debugger.
207
214
208 :param color_scheme: Deprecated, do not use.
215 Parameters
209 :param completekey: Passed to pdb.Pdb.
216 ----------
210 :param stdin: Passed to pdb.Pdb.
217 color_scheme : default None
211 :param stdout: Passed to pdb.Pdb.
218 Deprecated, do not use.
212 :param context: Number of lines of source code context to show when
219 completekey : default None
220 Passed to pdb.Pdb.
221 stdin : default None
222 Passed to pdb.Pdb.
223 stdout : default None
224 Passed to pdb.Pdb.
225 context : int
226 Number of lines of source code context to show when
213 displaying stacktrace information.
227 displaying stacktrace information.
214 :param kwargs: Passed to pdb.Pdb.
228 **kwargs
215 The possibilities are python version dependent, see the python
229 Passed to pdb.Pdb.
216 docs for more info.
230
231 Notes
232 -----
233 The possibilities are python version dependent, see the python
234 docs for more info.
217 """
235 """
218
236
219 # Parent constructor:
237 # Parent constructor:
220 try:
238 try:
221 self.context = int(context)
239 self.context = int(context)
222 if self.context <= 0:
240 if self.context <= 0:
223 raise ValueError("Context must be a positive integer")
241 raise ValueError("Context must be a positive integer")
224 except (TypeError, ValueError) as e:
242 except (TypeError, ValueError) as e:
225 raise ValueError("Context must be a positive integer") from e
243 raise ValueError("Context must be a positive integer") from e
226
244
227 # `kwargs` ensures full compatibility with stdlib's `pdb.Pdb`.
245 # `kwargs` ensures full compatibility with stdlib's `pdb.Pdb`.
228 OldPdb.__init__(self, completekey, stdin, stdout, **kwargs)
246 OldPdb.__init__(self, completekey, stdin, stdout, **kwargs)
229
247
230 # IPython changes...
248 # IPython changes...
231 self.shell = get_ipython()
249 self.shell = get_ipython()
232
250
233 if self.shell is None:
251 if self.shell is None:
234 save_main = sys.modules['__main__']
252 save_main = sys.modules['__main__']
235 # No IPython instance running, we must create one
253 # No IPython instance running, we must create one
236 from IPython.terminal.interactiveshell import \
254 from IPython.terminal.interactiveshell import \
237 TerminalInteractiveShell
255 TerminalInteractiveShell
238 self.shell = TerminalInteractiveShell.instance()
256 self.shell = TerminalInteractiveShell.instance()
239 # needed by any code which calls __import__("__main__") after
257 # needed by any code which calls __import__("__main__") after
240 # the debugger was entered. See also #9941.
258 # the debugger was entered. See also #9941.
241 sys.modules["__main__"] = save_main
259 sys.modules["__main__"] = save_main
242
260
243 if color_scheme is not None:
261 if color_scheme is not None:
244 warnings.warn(
262 warnings.warn(
245 "The `color_scheme` argument is deprecated since version 5.1",
263 "The `color_scheme` argument is deprecated since version 5.1",
246 DeprecationWarning, stacklevel=2)
264 DeprecationWarning, stacklevel=2)
247 else:
265 else:
248 color_scheme = self.shell.colors
266 color_scheme = self.shell.colors
249
267
250 self.aliases = {}
268 self.aliases = {}
251
269
252 # Create color table: we copy the default one from the traceback
270 # Create color table: we copy the default one from the traceback
253 # module and add a few attributes needed for debugging
271 # module and add a few attributes needed for debugging
254 self.color_scheme_table = exception_colors()
272 self.color_scheme_table = exception_colors()
255
273
256 # shorthands
274 # shorthands
257 C = coloransi.TermColors
275 C = coloransi.TermColors
258 cst = self.color_scheme_table
276 cst = self.color_scheme_table
259
277
260 cst['NoColor'].colors.prompt = C.NoColor
278 cst['NoColor'].colors.prompt = C.NoColor
261 cst['NoColor'].colors.breakpoint_enabled = C.NoColor
279 cst['NoColor'].colors.breakpoint_enabled = C.NoColor
262 cst['NoColor'].colors.breakpoint_disabled = C.NoColor
280 cst['NoColor'].colors.breakpoint_disabled = C.NoColor
263
281
264 cst['Linux'].colors.prompt = C.Green
282 cst['Linux'].colors.prompt = C.Green
265 cst['Linux'].colors.breakpoint_enabled = C.LightRed
283 cst['Linux'].colors.breakpoint_enabled = C.LightRed
266 cst['Linux'].colors.breakpoint_disabled = C.Red
284 cst['Linux'].colors.breakpoint_disabled = C.Red
267
285
268 cst['LightBG'].colors.prompt = C.Blue
286 cst['LightBG'].colors.prompt = C.Blue
269 cst['LightBG'].colors.breakpoint_enabled = C.LightRed
287 cst['LightBG'].colors.breakpoint_enabled = C.LightRed
270 cst['LightBG'].colors.breakpoint_disabled = C.Red
288 cst['LightBG'].colors.breakpoint_disabled = C.Red
271
289
272 cst['Neutral'].colors.prompt = C.Blue
290 cst['Neutral'].colors.prompt = C.Blue
273 cst['Neutral'].colors.breakpoint_enabled = C.LightRed
291 cst['Neutral'].colors.breakpoint_enabled = C.LightRed
274 cst['Neutral'].colors.breakpoint_disabled = C.Red
292 cst['Neutral'].colors.breakpoint_disabled = C.Red
275
293
276 # Add a python parser so we can syntax highlight source while
294 # Add a python parser so we can syntax highlight source while
277 # debugging.
295 # debugging.
278 self.parser = PyColorize.Parser(style=color_scheme)
296 self.parser = PyColorize.Parser(style=color_scheme)
279 self.set_colors(color_scheme)
297 self.set_colors(color_scheme)
280
298
281 # Set the prompt - the default prompt is '(Pdb)'
299 # Set the prompt - the default prompt is '(Pdb)'
282 self.prompt = prompt
300 self.prompt = prompt
283 self.skip_hidden = True
301 self.skip_hidden = True
284
302
285 # list of predicates we use to skip frames
303 # list of predicates we use to skip frames
286 self._predicates = {"tbhide": True, "readonly": False, "ipython_internal": True}
304 self._predicates = self.default_predicates
287
305
288 def set_colors(self, scheme):
306 def set_colors(self, scheme):
289 """Shorthand access to the color table scheme selector method."""
307 """Shorthand access to the color table scheme selector method."""
290 self.color_scheme_table.set_active_scheme(scheme)
308 self.color_scheme_table.set_active_scheme(scheme)
291 self.parser.style = scheme
309 self.parser.style = scheme
292
310
293 def set_trace(self, frame=None):
311 def set_trace(self, frame=None):
294 if frame is None:
312 if frame is None:
295 frame = sys._getframe().f_back
313 frame = sys._getframe().f_back
296 self.initial_frame = frame
314 self.initial_frame = frame
297 return super().set_trace(frame)
315 return super().set_trace(frame)
298
316
299 def _hidden_predicate(self, frame):
317 def _hidden_predicate(self, frame):
300 """
318 """
301 Given a frame return whether it it should be hidden or not by IPython.
319 Given a frame return whether it it should be hidden or not by IPython.
302 """
320 """
303
321
304 if self._predicates["readonly"]:
322 if self._predicates["readonly"]:
305 fname = frame.f_code.co_filename
323 fname = frame.f_code.co_filename
306 # we need to check for file existence and interactively define
324 # we need to check for file existence and interactively define
307 # function would otherwise appear as RO.
325 # function would otherwise appear as RO.
308 if os.path.isfile(fname) and not os.access(fname, os.W_OK):
326 if os.path.isfile(fname) and not os.access(fname, os.W_OK):
309 return True
327 return True
310
328
311 if self._predicates["tbhide"]:
329 if self._predicates["tbhide"]:
312 if frame in (self.curframe, getattr(self, "initial_frame", None)):
330 if frame in (self.curframe, getattr(self, "initial_frame", None)):
313 return False
331 return False
314 else:
332 else:
315 return frame.f_locals.get("__tracebackhide__", False)
333 return frame.f_locals.get("__tracebackhide__", False)
316
334
317 return False
335 return False
318
336
319 def hidden_frames(self, stack):
337 def hidden_frames(self, stack):
320 """
338 """
321 Given an index in the stack return whether it should be skipped.
339 Given an index in the stack return whether it should be skipped.
322
340
323 This is used in up/down and where to skip frames.
341 This is used in up/down and where to skip frames.
324 """
342 """
325 # The f_locals dictionary is updated from the actual frame
343 # The f_locals dictionary is updated from the actual frame
326 # locals whenever the .f_locals accessor is called, so we
344 # locals whenever the .f_locals accessor is called, so we
327 # avoid calling it here to preserve self.curframe_locals.
345 # avoid calling it here to preserve self.curframe_locals.
328 # Futhermore, there is no good reason to hide the current frame.
346 # Futhermore, there is no good reason to hide the current frame.
329 ip_hide = [self._hidden_predicate(s[0]) for s in stack]
347 ip_hide = [self._hidden_predicate(s[0]) for s in stack]
330 ip_start = [i for i, s in enumerate(ip_hide) if s == "__ipython_bottom__"]
348 ip_start = [i for i, s in enumerate(ip_hide) if s == "__ipython_bottom__"]
331 if ip_start and self._predicates["ipython_internal"]:
349 if ip_start and self._predicates["ipython_internal"]:
332 ip_hide = [h if i > ip_start[0] else True for (i, h) in enumerate(ip_hide)]
350 ip_hide = [h if i > ip_start[0] else True for (i, h) in enumerate(ip_hide)]
333 return ip_hide
351 return ip_hide
334
352
335 def interaction(self, frame, traceback):
353 def interaction(self, frame, traceback):
336 try:
354 try:
337 OldPdb.interaction(self, frame, traceback)
355 OldPdb.interaction(self, frame, traceback)
338 except KeyboardInterrupt:
356 except KeyboardInterrupt:
339 self.stdout.write("\n" + self.shell.get_exception_only())
357 self.stdout.write("\n" + self.shell.get_exception_only())
340
358
341 def precmd(self, line):
359 def precmd(self, line):
342 """Perform useful escapes on the command before it is executed."""
360 """Perform useful escapes on the command before it is executed."""
343
361
344 if line.endswith("??"):
362 if line.endswith("??"):
345 line = "pinfo2 " + line[:-2]
363 line = "pinfo2 " + line[:-2]
346 elif line.endswith("?"):
364 elif line.endswith("?"):
347 line = "pinfo " + line[:-1]
365 line = "pinfo " + line[:-1]
348
366
349 line = super().precmd(line)
367 line = super().precmd(line)
350
368
351 return line
369 return line
352
370
353 def new_do_frame(self, arg):
371 def new_do_frame(self, arg):
354 OldPdb.do_frame(self, arg)
372 OldPdb.do_frame(self, arg)
355
373
356 def new_do_quit(self, arg):
374 def new_do_quit(self, arg):
357
375
358 if hasattr(self, 'old_all_completions'):
376 if hasattr(self, 'old_all_completions'):
359 self.shell.Completer.all_completions = self.old_all_completions
377 self.shell.Completer.all_completions = self.old_all_completions
360
378
361 return OldPdb.do_quit(self, arg)
379 return OldPdb.do_quit(self, arg)
362
380
363 do_q = do_quit = decorate_fn_with_doc(new_do_quit, OldPdb.do_quit)
381 do_q = do_quit = decorate_fn_with_doc(new_do_quit, OldPdb.do_quit)
364
382
365 def new_do_restart(self, arg):
383 def new_do_restart(self, arg):
366 """Restart command. In the context of ipython this is exactly the same
384 """Restart command. In the context of ipython this is exactly the same
367 thing as 'quit'."""
385 thing as 'quit'."""
368 self.msg("Restart doesn't make sense here. Using 'quit' instead.")
386 self.msg("Restart doesn't make sense here. Using 'quit' instead.")
369 return self.do_quit(arg)
387 return self.do_quit(arg)
370
388
371 def print_stack_trace(self, context=None):
389 def print_stack_trace(self, context=None):
372 Colors = self.color_scheme_table.active_colors
390 Colors = self.color_scheme_table.active_colors
373 ColorsNormal = Colors.Normal
391 ColorsNormal = Colors.Normal
374 if context is None:
392 if context is None:
375 context = self.context
393 context = self.context
376 try:
394 try:
377 context = int(context)
395 context = int(context)
378 if context <= 0:
396 if context <= 0:
379 raise ValueError("Context must be a positive integer")
397 raise ValueError("Context must be a positive integer")
380 except (TypeError, ValueError) as e:
398 except (TypeError, ValueError) as e:
381 raise ValueError("Context must be a positive integer") from e
399 raise ValueError("Context must be a positive integer") from e
382 try:
400 try:
383 skipped = 0
401 skipped = 0
384 for hidden, frame_lineno in zip(self.hidden_frames(self.stack), self.stack):
402 for hidden, frame_lineno in zip(self.hidden_frames(self.stack), self.stack):
385 if hidden and self.skip_hidden:
403 if hidden and self.skip_hidden:
386 skipped += 1
404 skipped += 1
387 continue
405 continue
388 if skipped:
406 if skipped:
389 print(
407 print(
390 f"{Colors.excName} [... skipping {skipped} hidden frame(s)]{ColorsNormal}\n"
408 f"{Colors.excName} [... skipping {skipped} hidden frame(s)]{ColorsNormal}\n"
391 )
409 )
392 skipped = 0
410 skipped = 0
393 self.print_stack_entry(frame_lineno, context=context)
411 self.print_stack_entry(frame_lineno, context=context)
394 if skipped:
412 if skipped:
395 print(
413 print(
396 f"{Colors.excName} [... skipping {skipped} hidden frame(s)]{ColorsNormal}\n"
414 f"{Colors.excName} [... skipping {skipped} hidden frame(s)]{ColorsNormal}\n"
397 )
415 )
398 except KeyboardInterrupt:
416 except KeyboardInterrupt:
399 pass
417 pass
400
418
401 def print_stack_entry(self, frame_lineno, prompt_prefix='\n-> ',
419 def print_stack_entry(self, frame_lineno, prompt_prefix='\n-> ',
402 context=None):
420 context=None):
403 if context is None:
421 if context is None:
404 context = self.context
422 context = self.context
405 try:
423 try:
406 context = int(context)
424 context = int(context)
407 if context <= 0:
425 if context <= 0:
408 raise ValueError("Context must be a positive integer")
426 raise ValueError("Context must be a positive integer")
409 except (TypeError, ValueError) as e:
427 except (TypeError, ValueError) as e:
410 raise ValueError("Context must be a positive integer") from e
428 raise ValueError("Context must be a positive integer") from e
411 print(self.format_stack_entry(frame_lineno, '', context), file=self.stdout)
429 print(self.format_stack_entry(frame_lineno, '', context), file=self.stdout)
412
430
413 # vds: >>
431 # vds: >>
414 frame, lineno = frame_lineno
432 frame, lineno = frame_lineno
415 filename = frame.f_code.co_filename
433 filename = frame.f_code.co_filename
416 self.shell.hooks.synchronize_with_editor(filename, lineno, 0)
434 self.shell.hooks.synchronize_with_editor(filename, lineno, 0)
417 # vds: <<
435 # vds: <<
418
436
419 def format_stack_entry(self, frame_lineno, lprefix=': ', context=None):
437 def format_stack_entry(self, frame_lineno, lprefix=': ', context=None):
420 if context is None:
438 if context is None:
421 context = self.context
439 context = self.context
422 try:
440 try:
423 context = int(context)
441 context = int(context)
424 if context <= 0:
442 if context <= 0:
425 print("Context must be a positive integer", file=self.stdout)
443 print("Context must be a positive integer", file=self.stdout)
426 except (TypeError, ValueError):
444 except (TypeError, ValueError):
427 print("Context must be a positive integer", file=self.stdout)
445 print("Context must be a positive integer", file=self.stdout)
428
446
429 import reprlib
447 import reprlib
430
448
431 ret = []
449 ret = []
432
450
433 Colors = self.color_scheme_table.active_colors
451 Colors = self.color_scheme_table.active_colors
434 ColorsNormal = Colors.Normal
452 ColorsNormal = Colors.Normal
435 tpl_link = "%s%%s%s" % (Colors.filenameEm, ColorsNormal)
453 tpl_link = "%s%%s%s" % (Colors.filenameEm, ColorsNormal)
436 tpl_call = "%s%%s%s%%s%s" % (Colors.vName, Colors.valEm, ColorsNormal)
454 tpl_call = "%s%%s%s%%s%s" % (Colors.vName, Colors.valEm, ColorsNormal)
437 tpl_line = "%%s%s%%s %s%%s" % (Colors.lineno, ColorsNormal)
455 tpl_line = "%%s%s%%s %s%%s" % (Colors.lineno, ColorsNormal)
438 tpl_line_em = "%%s%s%%s %s%%s%s" % (Colors.linenoEm, Colors.line, ColorsNormal)
456 tpl_line_em = "%%s%s%%s %s%%s%s" % (Colors.linenoEm, Colors.line, ColorsNormal)
439
457
440 frame, lineno = frame_lineno
458 frame, lineno = frame_lineno
441
459
442 return_value = ''
460 return_value = ''
443 if '__return__' in frame.f_locals:
461 if '__return__' in frame.f_locals:
444 rv = frame.f_locals['__return__']
462 rv = frame.f_locals['__return__']
445 #return_value += '->'
463 #return_value += '->'
446 return_value += reprlib.repr(rv) + '\n'
464 return_value += reprlib.repr(rv) + '\n'
447 ret.append(return_value)
465 ret.append(return_value)
448
466
449 #s = filename + '(' + `lineno` + ')'
467 #s = filename + '(' + `lineno` + ')'
450 filename = self.canonic(frame.f_code.co_filename)
468 filename = self.canonic(frame.f_code.co_filename)
451 link = tpl_link % py3compat.cast_unicode(filename)
469 link = tpl_link % py3compat.cast_unicode(filename)
452
470
453 if frame.f_code.co_name:
471 if frame.f_code.co_name:
454 func = frame.f_code.co_name
472 func = frame.f_code.co_name
455 else:
473 else:
456 func = "<lambda>"
474 func = "<lambda>"
457
475
458 call = ''
476 call = ''
459 if func != '?':
477 if func != '?':
460 if '__args__' in frame.f_locals:
478 if '__args__' in frame.f_locals:
461 args = reprlib.repr(frame.f_locals['__args__'])
479 args = reprlib.repr(frame.f_locals['__args__'])
462 else:
480 else:
463 args = '()'
481 args = '()'
464 call = tpl_call % (func, args)
482 call = tpl_call % (func, args)
465
483
466 # The level info should be generated in the same format pdb uses, to
484 # The level info should be generated in the same format pdb uses, to
467 # avoid breaking the pdbtrack functionality of python-mode in *emacs.
485 # avoid breaking the pdbtrack functionality of python-mode in *emacs.
468 if frame is self.curframe:
486 if frame is self.curframe:
469 ret.append('> ')
487 ret.append('> ')
470 else:
488 else:
471 ret.append(" ")
489 ret.append(" ")
472 ret.append("%s(%s)%s\n" % (link, lineno, call))
490 ret.append("%s(%s)%s\n" % (link, lineno, call))
473
491
474 start = lineno - 1 - context//2
492 start = lineno - 1 - context//2
475 lines = linecache.getlines(filename)
493 lines = linecache.getlines(filename)
476 start = min(start, len(lines) - context)
494 start = min(start, len(lines) - context)
477 start = max(start, 0)
495 start = max(start, 0)
478 lines = lines[start : start + context]
496 lines = lines[start : start + context]
479
497
480 for i, line in enumerate(lines):
498 for i, line in enumerate(lines):
481 show_arrow = start + 1 + i == lineno
499 show_arrow = start + 1 + i == lineno
482 linetpl = (frame is self.curframe or show_arrow) and tpl_line_em or tpl_line
500 linetpl = (frame is self.curframe or show_arrow) and tpl_line_em or tpl_line
483 ret.append(
501 ret.append(
484 self.__format_line(
502 self.__format_line(
485 linetpl, filename, start + 1 + i, line, arrow=show_arrow
503 linetpl, filename, start + 1 + i, line, arrow=show_arrow
486 )
504 )
487 )
505 )
488 return "".join(ret)
506 return "".join(ret)
489
507
490 def __format_line(self, tpl_line, filename, lineno, line, arrow=False):
508 def __format_line(self, tpl_line, filename, lineno, line, arrow=False):
491 bp_mark = ""
509 bp_mark = ""
492 bp_mark_color = ""
510 bp_mark_color = ""
493
511
494 new_line, err = self.parser.format2(line, 'str')
512 new_line, err = self.parser.format2(line, 'str')
495 if not err:
513 if not err:
496 line = new_line
514 line = new_line
497
515
498 bp = None
516 bp = None
499 if lineno in self.get_file_breaks(filename):
517 if lineno in self.get_file_breaks(filename):
500 bps = self.get_breaks(filename, lineno)
518 bps = self.get_breaks(filename, lineno)
501 bp = bps[-1]
519 bp = bps[-1]
502
520
503 if bp:
521 if bp:
504 Colors = self.color_scheme_table.active_colors
522 Colors = self.color_scheme_table.active_colors
505 bp_mark = str(bp.number)
523 bp_mark = str(bp.number)
506 bp_mark_color = Colors.breakpoint_enabled
524 bp_mark_color = Colors.breakpoint_enabled
507 if not bp.enabled:
525 if not bp.enabled:
508 bp_mark_color = Colors.breakpoint_disabled
526 bp_mark_color = Colors.breakpoint_disabled
509
527
510 numbers_width = 7
528 numbers_width = 7
511 if arrow:
529 if arrow:
512 # This is the line with the error
530 # This is the line with the error
513 pad = numbers_width - len(str(lineno)) - len(bp_mark)
531 pad = numbers_width - len(str(lineno)) - len(bp_mark)
514 num = '%s%s' % (make_arrow(pad), str(lineno))
532 num = '%s%s' % (make_arrow(pad), str(lineno))
515 else:
533 else:
516 num = '%*s' % (numbers_width - len(bp_mark), str(lineno))
534 num = '%*s' % (numbers_width - len(bp_mark), str(lineno))
517
535
518 return tpl_line % (bp_mark_color + bp_mark, num, line)
536 return tpl_line % (bp_mark_color + bp_mark, num, line)
519
537
520 def print_list_lines(self, filename, first, last):
538 def print_list_lines(self, filename, first, last):
521 """The printing (as opposed to the parsing part of a 'list'
539 """The printing (as opposed to the parsing part of a 'list'
522 command."""
540 command."""
523 try:
541 try:
524 Colors = self.color_scheme_table.active_colors
542 Colors = self.color_scheme_table.active_colors
525 ColorsNormal = Colors.Normal
543 ColorsNormal = Colors.Normal
526 tpl_line = '%%s%s%%s %s%%s' % (Colors.lineno, ColorsNormal)
544 tpl_line = '%%s%s%%s %s%%s' % (Colors.lineno, ColorsNormal)
527 tpl_line_em = '%%s%s%%s %s%%s%s' % (Colors.linenoEm, Colors.line, ColorsNormal)
545 tpl_line_em = '%%s%s%%s %s%%s%s' % (Colors.linenoEm, Colors.line, ColorsNormal)
528 src = []
546 src = []
529 if filename == "<string>" and hasattr(self, "_exec_filename"):
547 if filename == "<string>" and hasattr(self, "_exec_filename"):
530 filename = self._exec_filename
548 filename = self._exec_filename
531
549
532 for lineno in range(first, last+1):
550 for lineno in range(first, last+1):
533 line = linecache.getline(filename, lineno)
551 line = linecache.getline(filename, lineno)
534 if not line:
552 if not line:
535 break
553 break
536
554
537 if lineno == self.curframe.f_lineno:
555 if lineno == self.curframe.f_lineno:
538 line = self.__format_line(
556 line = self.__format_line(
539 tpl_line_em, filename, lineno, line, arrow=True
557 tpl_line_em, filename, lineno, line, arrow=True
540 )
558 )
541 else:
559 else:
542 line = self.__format_line(
560 line = self.__format_line(
543 tpl_line, filename, lineno, line, arrow=False
561 tpl_line, filename, lineno, line, arrow=False
544 )
562 )
545
563
546 src.append(line)
564 src.append(line)
547 self.lineno = lineno
565 self.lineno = lineno
548
566
549 print(''.join(src), file=self.stdout)
567 print(''.join(src), file=self.stdout)
550
568
551 except KeyboardInterrupt:
569 except KeyboardInterrupt:
552 pass
570 pass
553
571
554 def do_skip_predicates(self, args):
572 def do_skip_predicates(self, args):
555 """
573 """
556 Turn on/off individual predicates as to whether a frame should be hidden/skip.
574 Turn on/off individual predicates as to whether a frame should be hidden/skip.
557
575
558 The global option to skip (or not) hidden frames is set with skip_hidden
576 The global option to skip (or not) hidden frames is set with skip_hidden
559
577
560 To change the value of a predicate
578 To change the value of a predicate
561
579
562 skip_predicates key [true|false]
580 skip_predicates key [true|false]
563
581
564 Call without arguments to see the current values.
582 Call without arguments to see the current values.
565
583
584 To permanently change the value of an option add the corresponding
585 command to your ``~/.pdbrc`` file. If you are programmatically using the
586 Pdb instance you can also change the ``default_predicates`` class
587 attribute.
566 """
588 """
567 if not args.strip():
589 if not args.strip():
568 print("current predicates:")
590 print("current predicates:")
569 for (p, v) in self._predicates.items():
591 for (p, v) in self._predicates.items():
570 print(" ", p, ":", v)
592 print(" ", p, ":", v)
571 return
593 return
572 type_value = args.strip().split(" ")
594 type_value = args.strip().split(" ")
573 if len(type_value) != 2:
595 if len(type_value) != 2:
574 print(
596 print(
575 f"Usage: skip_predicates <type> <value>, with <type> one of {set(self._predicates.keys())}"
597 f"Usage: skip_predicates <type> <value>, with <type> one of {set(self._predicates.keys())}"
576 )
598 )
577 return
599 return
578
600
579 type_, value = type_value
601 type_, value = type_value
580 if type_ not in self._predicates:
602 if type_ not in self._predicates:
581 print(f"{type_!r} not in {set(self._predicates.keys())}")
603 print(f"{type_!r} not in {set(self._predicates.keys())}")
582 return
604 return
583 if value.lower() not in ("true", "yes", "1", "no", "false", "0"):
605 if value.lower() not in ("true", "yes", "1", "no", "false", "0"):
584 print(
606 print(
585 f"{value!r} is invalid - use one of ('true', 'yes', '1', 'no', 'false', '0')"
607 f"{value!r} is invalid - use one of ('true', 'yes', '1', 'no', 'false', '0')"
586 )
608 )
587 return
609 return
588
610
589 self._predicates[type_] = value.lower() in ("true", "yes", "1")
611 self._predicates[type_] = value.lower() in ("true", "yes", "1")
590 if not any(self._predicates.values()):
612 if not any(self._predicates.values()):
591 print(
613 print(
592 "Warning, all predicates set to False, skip_hidden may not have any effects."
614 "Warning, all predicates set to False, skip_hidden may not have any effects."
593 )
615 )
594
616
595 def do_skip_hidden(self, arg):
617 def do_skip_hidden(self, arg):
596 """
618 """
597 Change whether or not we should skip frames with the
619 Change whether or not we should skip frames with the
598 __tracebackhide__ attribute.
620 __tracebackhide__ attribute.
599 """
621 """
600 if not arg.strip():
622 if not arg.strip():
601 print(
623 print(
602 f"skip_hidden = {self.skip_hidden}, use 'yes','no', 'true', or 'false' to change."
624 f"skip_hidden = {self.skip_hidden}, use 'yes','no', 'true', or 'false' to change."
603 )
625 )
604 elif arg.strip().lower() in ("true", "yes"):
626 elif arg.strip().lower() in ("true", "yes"):
605 self.skip_hidden = True
627 self.skip_hidden = True
606 elif arg.strip().lower() in ("false", "no"):
628 elif arg.strip().lower() in ("false", "no"):
607 self.skip_hidden = False
629 self.skip_hidden = False
608 if not any(self._predicates.values()):
630 if not any(self._predicates.values()):
609 print(
631 print(
610 "Warning, all predicates set to False, skip_hidden may not have any effects."
632 "Warning, all predicates set to False, skip_hidden may not have any effects."
611 )
633 )
612
634
613 def do_list(self, arg):
635 def do_list(self, arg):
614 """Print lines of code from the current stack frame
636 """Print lines of code from the current stack frame
615 """
637 """
616 self.lastcmd = 'list'
638 self.lastcmd = 'list'
617 last = None
639 last = None
618 if arg:
640 if arg:
619 try:
641 try:
620 x = eval(arg, {}, {})
642 x = eval(arg, {}, {})
621 if type(x) == type(()):
643 if type(x) == type(()):
622 first, last = x
644 first, last = x
623 first = int(first)
645 first = int(first)
624 last = int(last)
646 last = int(last)
625 if last < first:
647 if last < first:
626 # Assume it's a count
648 # Assume it's a count
627 last = first + last
649 last = first + last
628 else:
650 else:
629 first = max(1, int(x) - 5)
651 first = max(1, int(x) - 5)
630 except:
652 except:
631 print('*** Error in argument:', repr(arg), file=self.stdout)
653 print('*** Error in argument:', repr(arg), file=self.stdout)
632 return
654 return
633 elif self.lineno is None:
655 elif self.lineno is None:
634 first = max(1, self.curframe.f_lineno - 5)
656 first = max(1, self.curframe.f_lineno - 5)
635 else:
657 else:
636 first = self.lineno + 1
658 first = self.lineno + 1
637 if last is None:
659 if last is None:
638 last = first + 10
660 last = first + 10
639 self.print_list_lines(self.curframe.f_code.co_filename, first, last)
661 self.print_list_lines(self.curframe.f_code.co_filename, first, last)
640
662
641 # vds: >>
663 # vds: >>
642 lineno = first
664 lineno = first
643 filename = self.curframe.f_code.co_filename
665 filename = self.curframe.f_code.co_filename
644 self.shell.hooks.synchronize_with_editor(filename, lineno, 0)
666 self.shell.hooks.synchronize_with_editor(filename, lineno, 0)
645 # vds: <<
667 # vds: <<
646
668
647 do_l = do_list
669 do_l = do_list
648
670
649 def getsourcelines(self, obj):
671 def getsourcelines(self, obj):
650 lines, lineno = inspect.findsource(obj)
672 lines, lineno = inspect.findsource(obj)
651 if inspect.isframe(obj) and obj.f_globals is obj.f_locals:
673 if inspect.isframe(obj) and obj.f_globals is obj.f_locals:
652 # must be a module frame: do not try to cut a block out of it
674 # must be a module frame: do not try to cut a block out of it
653 return lines, 1
675 return lines, 1
654 elif inspect.ismodule(obj):
676 elif inspect.ismodule(obj):
655 return lines, 1
677 return lines, 1
656 return inspect.getblock(lines[lineno:]), lineno+1
678 return inspect.getblock(lines[lineno:]), lineno+1
657
679
658 def do_longlist(self, arg):
680 def do_longlist(self, arg):
659 """Print lines of code from the current stack frame.
681 """Print lines of code from the current stack frame.
660
682
661 Shows more lines than 'list' does.
683 Shows more lines than 'list' does.
662 """
684 """
663 self.lastcmd = 'longlist'
685 self.lastcmd = 'longlist'
664 try:
686 try:
665 lines, lineno = self.getsourcelines(self.curframe)
687 lines, lineno = self.getsourcelines(self.curframe)
666 except OSError as err:
688 except OSError as err:
667 self.error(err)
689 self.error(err)
668 return
690 return
669 last = lineno + len(lines)
691 last = lineno + len(lines)
670 self.print_list_lines(self.curframe.f_code.co_filename, lineno, last)
692 self.print_list_lines(self.curframe.f_code.co_filename, lineno, last)
671 do_ll = do_longlist
693 do_ll = do_longlist
672
694
673 def do_debug(self, arg):
695 def do_debug(self, arg):
674 """debug code
696 """debug code
675 Enter a recursive debugger that steps through the code
697 Enter a recursive debugger that steps through the code
676 argument (which is an arbitrary expression or statement to be
698 argument (which is an arbitrary expression or statement to be
677 executed in the current environment).
699 executed in the current environment).
678 """
700 """
679 trace_function = sys.gettrace()
701 trace_function = sys.gettrace()
680 sys.settrace(None)
702 sys.settrace(None)
681 globals = self.curframe.f_globals
703 globals = self.curframe.f_globals
682 locals = self.curframe_locals
704 locals = self.curframe_locals
683 p = self.__class__(completekey=self.completekey,
705 p = self.__class__(completekey=self.completekey,
684 stdin=self.stdin, stdout=self.stdout)
706 stdin=self.stdin, stdout=self.stdout)
685 p.use_rawinput = self.use_rawinput
707 p.use_rawinput = self.use_rawinput
686 p.prompt = "(%s) " % self.prompt.strip()
708 p.prompt = "(%s) " % self.prompt.strip()
687 self.message("ENTERING RECURSIVE DEBUGGER")
709 self.message("ENTERING RECURSIVE DEBUGGER")
688 sys.call_tracing(p.run, (arg, globals, locals))
710 sys.call_tracing(p.run, (arg, globals, locals))
689 self.message("LEAVING RECURSIVE DEBUGGER")
711 self.message("LEAVING RECURSIVE DEBUGGER")
690 sys.settrace(trace_function)
712 sys.settrace(trace_function)
691 self.lastcmd = p.lastcmd
713 self.lastcmd = p.lastcmd
692
714
693 def do_pdef(self, arg):
715 def do_pdef(self, arg):
694 """Print the call signature for any callable object.
716 """Print the call signature for any callable object.
695
717
696 The debugger interface to %pdef"""
718 The debugger interface to %pdef"""
697 namespaces = [
719 namespaces = [
698 ("Locals", self.curframe_locals),
720 ("Locals", self.curframe_locals),
699 ("Globals", self.curframe.f_globals),
721 ("Globals", self.curframe.f_globals),
700 ]
722 ]
701 self.shell.find_line_magic("pdef")(arg, namespaces=namespaces)
723 self.shell.find_line_magic("pdef")(arg, namespaces=namespaces)
702
724
703 def do_pdoc(self, arg):
725 def do_pdoc(self, arg):
704 """Print the docstring for an object.
726 """Print the docstring for an object.
705
727
706 The debugger interface to %pdoc."""
728 The debugger interface to %pdoc."""
707 namespaces = [
729 namespaces = [
708 ("Locals", self.curframe_locals),
730 ("Locals", self.curframe_locals),
709 ("Globals", self.curframe.f_globals),
731 ("Globals", self.curframe.f_globals),
710 ]
732 ]
711 self.shell.find_line_magic("pdoc")(arg, namespaces=namespaces)
733 self.shell.find_line_magic("pdoc")(arg, namespaces=namespaces)
712
734
713 def do_pfile(self, arg):
735 def do_pfile(self, arg):
714 """Print (or run through pager) the file where an object is defined.
736 """Print (or run through pager) the file where an object is defined.
715
737
716 The debugger interface to %pfile.
738 The debugger interface to %pfile.
717 """
739 """
718 namespaces = [
740 namespaces = [
719 ("Locals", self.curframe_locals),
741 ("Locals", self.curframe_locals),
720 ("Globals", self.curframe.f_globals),
742 ("Globals", self.curframe.f_globals),
721 ]
743 ]
722 self.shell.find_line_magic("pfile")(arg, namespaces=namespaces)
744 self.shell.find_line_magic("pfile")(arg, namespaces=namespaces)
723
745
724 def do_pinfo(self, arg):
746 def do_pinfo(self, arg):
725 """Provide detailed information about an object.
747 """Provide detailed information about an object.
726
748
727 The debugger interface to %pinfo, i.e., obj?."""
749 The debugger interface to %pinfo, i.e., obj?."""
728 namespaces = [
750 namespaces = [
729 ("Locals", self.curframe_locals),
751 ("Locals", self.curframe_locals),
730 ("Globals", self.curframe.f_globals),
752 ("Globals", self.curframe.f_globals),
731 ]
753 ]
732 self.shell.find_line_magic("pinfo")(arg, namespaces=namespaces)
754 self.shell.find_line_magic("pinfo")(arg, namespaces=namespaces)
733
755
734 def do_pinfo2(self, arg):
756 def do_pinfo2(self, arg):
735 """Provide extra detailed information about an object.
757 """Provide extra detailed information about an object.
736
758
737 The debugger interface to %pinfo2, i.e., obj??."""
759 The debugger interface to %pinfo2, i.e., obj??."""
738 namespaces = [
760 namespaces = [
739 ("Locals", self.curframe_locals),
761 ("Locals", self.curframe_locals),
740 ("Globals", self.curframe.f_globals),
762 ("Globals", self.curframe.f_globals),
741 ]
763 ]
742 self.shell.find_line_magic("pinfo2")(arg, namespaces=namespaces)
764 self.shell.find_line_magic("pinfo2")(arg, namespaces=namespaces)
743
765
744 def do_psource(self, arg):
766 def do_psource(self, arg):
745 """Print (or run through pager) the source code for an object."""
767 """Print (or run through pager) the source code for an object."""
746 namespaces = [
768 namespaces = [
747 ("Locals", self.curframe_locals),
769 ("Locals", self.curframe_locals),
748 ("Globals", self.curframe.f_globals),
770 ("Globals", self.curframe.f_globals),
749 ]
771 ]
750 self.shell.find_line_magic("psource")(arg, namespaces=namespaces)
772 self.shell.find_line_magic("psource")(arg, namespaces=namespaces)
751
773
752 def do_where(self, arg):
774 def do_where(self, arg):
753 """w(here)
775 """w(here)
754 Print a stack trace, with the most recent frame at the bottom.
776 Print a stack trace, with the most recent frame at the bottom.
755 An arrow indicates the "current frame", which determines the
777 An arrow indicates the "current frame", which determines the
756 context of most commands. 'bt' is an alias for this command.
778 context of most commands. 'bt' is an alias for this command.
757
779
758 Take a number as argument as an (optional) number of context line to
780 Take a number as argument as an (optional) number of context line to
759 print"""
781 print"""
760 if arg:
782 if arg:
761 try:
783 try:
762 context = int(arg)
784 context = int(arg)
763 except ValueError as err:
785 except ValueError as err:
764 self.error(err)
786 self.error(err)
765 return
787 return
766 self.print_stack_trace(context)
788 self.print_stack_trace(context)
767 else:
789 else:
768 self.print_stack_trace()
790 self.print_stack_trace()
769
791
770 do_w = do_where
792 do_w = do_where
771
793
772 def stop_here(self, frame):
794 def stop_here(self, frame):
773 hidden = False
795 hidden = False
774 if self.skip_hidden:
796 if self.skip_hidden:
775 hidden = self._hidden_predicate(frame)
797 hidden = self._hidden_predicate(frame)
776 if hidden:
798 if hidden:
777 Colors = self.color_scheme_table.active_colors
799 Colors = self.color_scheme_table.active_colors
778 ColorsNormal = Colors.Normal
800 ColorsNormal = Colors.Normal
779 print(f"{Colors.excName} [... skipped 1 hidden frame]{ColorsNormal}\n")
801 print(f"{Colors.excName} [... skipped 1 hidden frame]{ColorsNormal}\n")
780
802
781 return super().stop_here(frame)
803 return super().stop_here(frame)
782
804
783 def do_up(self, arg):
805 def do_up(self, arg):
784 """u(p) [count]
806 """u(p) [count]
785 Move the current frame count (default one) levels up in the
807 Move the current frame count (default one) levels up in the
786 stack trace (to an older frame).
808 stack trace (to an older frame).
787
809
788 Will skip hidden frames.
810 Will skip hidden frames.
789 """
811 """
790 # modified version of upstream that skips
812 # modified version of upstream that skips
791 # frames with __tracebackhide__
813 # frames with __tracebackhide__
792 if self.curindex == 0:
814 if self.curindex == 0:
793 self.error("Oldest frame")
815 self.error("Oldest frame")
794 return
816 return
795 try:
817 try:
796 count = int(arg or 1)
818 count = int(arg or 1)
797 except ValueError:
819 except ValueError:
798 self.error("Invalid frame count (%s)" % arg)
820 self.error("Invalid frame count (%s)" % arg)
799 return
821 return
800 skipped = 0
822 skipped = 0
801 if count < 0:
823 if count < 0:
802 _newframe = 0
824 _newframe = 0
803 else:
825 else:
804 counter = 0
826 counter = 0
805 hidden_frames = self.hidden_frames(self.stack)
827 hidden_frames = self.hidden_frames(self.stack)
806 for i in range(self.curindex - 1, -1, -1):
828 for i in range(self.curindex - 1, -1, -1):
807 if hidden_frames[i] and self.skip_hidden:
829 if hidden_frames[i] and self.skip_hidden:
808 skipped += 1
830 skipped += 1
809 continue
831 continue
810 counter += 1
832 counter += 1
811 if counter >= count:
833 if counter >= count:
812 break
834 break
813 else:
835 else:
814 # if no break occured.
836 # if no break occured.
815 self.error(
837 self.error(
816 "all frames above hidden, use `skip_hidden False` to get get into those."
838 "all frames above hidden, use `skip_hidden False` to get get into those."
817 )
839 )
818 return
840 return
819
841
820 Colors = self.color_scheme_table.active_colors
842 Colors = self.color_scheme_table.active_colors
821 ColorsNormal = Colors.Normal
843 ColorsNormal = Colors.Normal
822 _newframe = i
844 _newframe = i
823 self._select_frame(_newframe)
845 self._select_frame(_newframe)
824 if skipped:
846 if skipped:
825 print(
847 print(
826 f"{Colors.excName} [... skipped {skipped} hidden frame(s)]{ColorsNormal}\n"
848 f"{Colors.excName} [... skipped {skipped} hidden frame(s)]{ColorsNormal}\n"
827 )
849 )
828
850
829 def do_down(self, arg):
851 def do_down(self, arg):
830 """d(own) [count]
852 """d(own) [count]
831 Move the current frame count (default one) levels down in the
853 Move the current frame count (default one) levels down in the
832 stack trace (to a newer frame).
854 stack trace (to a newer frame).
833
855
834 Will skip hidden frames.
856 Will skip hidden frames.
835 """
857 """
836 if self.curindex + 1 == len(self.stack):
858 if self.curindex + 1 == len(self.stack):
837 self.error("Newest frame")
859 self.error("Newest frame")
838 return
860 return
839 try:
861 try:
840 count = int(arg or 1)
862 count = int(arg or 1)
841 except ValueError:
863 except ValueError:
842 self.error("Invalid frame count (%s)" % arg)
864 self.error("Invalid frame count (%s)" % arg)
843 return
865 return
844 if count < 0:
866 if count < 0:
845 _newframe = len(self.stack) - 1
867 _newframe = len(self.stack) - 1
846 else:
868 else:
847 counter = 0
869 counter = 0
848 skipped = 0
870 skipped = 0
849 hidden_frames = self.hidden_frames(self.stack)
871 hidden_frames = self.hidden_frames(self.stack)
850 for i in range(self.curindex + 1, len(self.stack)):
872 for i in range(self.curindex + 1, len(self.stack)):
851 if hidden_frames[i] and self.skip_hidden:
873 if hidden_frames[i] and self.skip_hidden:
852 skipped += 1
874 skipped += 1
853 continue
875 continue
854 counter += 1
876 counter += 1
855 if counter >= count:
877 if counter >= count:
856 break
878 break
857 else:
879 else:
858 self.error(
880 self.error(
859 "all frames bellow hidden, use `skip_hidden False` to get get into those."
881 "all frames bellow hidden, use `skip_hidden False` to get get into those."
860 )
882 )
861 return
883 return
862
884
863 Colors = self.color_scheme_table.active_colors
885 Colors = self.color_scheme_table.active_colors
864 ColorsNormal = Colors.Normal
886 ColorsNormal = Colors.Normal
865 if skipped:
887 if skipped:
866 print(
888 print(
867 f"{Colors.excName} [... skipped {skipped} hidden frame(s)]{ColorsNormal}\n"
889 f"{Colors.excName} [... skipped {skipped} hidden frame(s)]{ColorsNormal}\n"
868 )
890 )
869 _newframe = i
891 _newframe = i
870
892
871 self._select_frame(_newframe)
893 self._select_frame(_newframe)
872
894
873 do_d = do_down
895 do_d = do_down
874 do_u = do_up
896 do_u = do_up
875
897
876 def do_context(self, context):
898 def do_context(self, context):
877 """context number_of_lines
899 """context number_of_lines
878 Set the number of lines of source code to show when displaying
900 Set the number of lines of source code to show when displaying
879 stacktrace information.
901 stacktrace information.
880 """
902 """
881 try:
903 try:
882 new_context = int(context)
904 new_context = int(context)
883 if new_context <= 0:
905 if new_context <= 0:
884 raise ValueError()
906 raise ValueError()
885 self.context = new_context
907 self.context = new_context
886 except ValueError:
908 except ValueError:
887 self.error("The 'context' command requires a positive integer argument.")
909 self.error("The 'context' command requires a positive integer argument.")
888
910
889
911
890 class InterruptiblePdb(Pdb):
912 class InterruptiblePdb(Pdb):
891 """Version of debugger where KeyboardInterrupt exits the debugger altogether."""
913 """Version of debugger where KeyboardInterrupt exits the debugger altogether."""
892
914
893 def cmdloop(self):
915 def cmdloop(self):
894 """Wrap cmdloop() such that KeyboardInterrupt stops the debugger."""
916 """Wrap cmdloop() such that KeyboardInterrupt stops the debugger."""
895 try:
917 try:
896 return OldPdb.cmdloop(self)
918 return OldPdb.cmdloop(self)
897 except KeyboardInterrupt:
919 except KeyboardInterrupt:
898 self.stop_here = lambda frame: False
920 self.stop_here = lambda frame: False
899 self.do_quit("")
921 self.do_quit("")
900 sys.settrace(None)
922 sys.settrace(None)
901 self.quitting = False
923 self.quitting = False
902 raise
924 raise
903
925
904 def _cmdloop(self):
926 def _cmdloop(self):
905 while True:
927 while True:
906 try:
928 try:
907 # keyboard interrupts allow for an easy way to cancel
929 # keyboard interrupts allow for an easy way to cancel
908 # the current command, so allow them during interactive input
930 # the current command, so allow them during interactive input
909 self.allow_kbdint = True
931 self.allow_kbdint = True
910 self.cmdloop()
932 self.cmdloop()
911 self.allow_kbdint = False
933 self.allow_kbdint = False
912 break
934 break
913 except KeyboardInterrupt:
935 except KeyboardInterrupt:
914 self.message('--KeyboardInterrupt--')
936 self.message('--KeyboardInterrupt--')
915 raise
937 raise
916
938
917
939
918 def set_trace(frame=None):
940 def set_trace(frame=None):
919 """
941 """
920 Start debugging from `frame`.
942 Start debugging from `frame`.
921
943
922 If frame is not specified, debugging starts from caller's frame.
944 If frame is not specified, debugging starts from caller's frame.
923 """
945 """
924 Pdb().set_trace(frame or sys._getframe().f_back)
946 Pdb().set_trace(frame or sys._getframe().f_back)
@@ -1,1414 +1,1430 b''
1 ============
1 ============
2 7.x Series
2 7.x Series
3 ============
3 ============
4
4
5 .. _version 7.24:
5 .. _version 7.24:
6
6
7 IPython 7.24
7 IPython 7.24
8 ============
8 ============
9
9
10 Third release of IPython for 2021, mostly containing bug fixes. A couple of not
10 Third release of IPython for 2021, mostly containing bug fixes. A couple of not
11 typical updates:
11 typical updates:
12
12
13 Misc
13 Misc
14 ----
14 ----
15
15
16
16
17 - Fix an issue where ``%recall`` would both succeeded and print an error message
17 - Fix an issue where ``%recall`` would both succeeded and print an error message
18 it failed. :ghpull:`12952`
18 it failed. :ghpull:`12952`
19 - Drop support for NumPy 1.16 – practically has no effect beyond indicating in
19 - Drop support for NumPy 1.16 – practically has no effect beyond indicating in
20 package metadata that we do not support it. :ghpull:`12937`
20 package metadata that we do not support it. :ghpull:`12937`
21
21
22 Debugger improvements
22 Debugger improvements
23 ---------------------
23 ---------------------
24
24
25 The debugger (and ``%debug`` magic) have been improved and can skip or hide frames
25 The debugger (and ``%debug`` magic) have been improved and can skip or hide frames
26 originating from files that are not writable to the user, as these are less
26 originating from files that are not writable to the user, as these are less
27 likely to be the source of errors, or be part of system files this can be a useful
27 likely to be the source of errors, or be part of system files this can be a useful
28 addition when debugging long errors.
28 addition when debugging long errors.
29
29
30 In addition to the global ``skip_hidden True|False`` command, the debugger has
30 In addition to the global ``skip_hidden True|False`` command, the debugger has
31 gained finer grained control of predicates as to whether to a frame should be
31 gained finer grained control of predicates as to whether to a frame should be
32 considered hidden. So far 3 predicates are available :
32 considered hidden. So far 3 predicates are available :
33
33
34 - ``tbhide``: frames containing the local variable ``__tracebackhide__`` set to
34 - ``tbhide``: frames containing the local variable ``__tracebackhide__`` set to
35 True.
35 True.
36 - ``readonly``: frames originating from readonly files, set to False.
36 - ``readonly``: frames originating from readonly files, set to False.
37 - ``ipython_internal``: frames that are likely to be from IPython internal
37 - ``ipython_internal``: frames that are likely to be from IPython internal
38 code, set to True.
38 code, set to True.
39
39
40 You can toggle individual predicates during a session with
40 You can toggle individual predicates during a session with
41
41
42 .. code-block::
42 .. code-block::
43
43
44 ipdb> skip_predicates readonly True
44 ipdb> skip_predicates readonly True
45
45
46 Read-only files will now be considered hidden frames.
46 Read-only files will now be considered hidden frames.
47
47
48
48
49 You can call ``skip_predicates`` without arguments to see the states of current
49 You can call ``skip_predicates`` without arguments to see the states of current
50 predicates:
50 predicates:
51
51
52 .. code-block::
52 .. code-block::
53
53
54 ipdb> skip_predicates
54 ipdb> skip_predicates
55 current predicates:
55 current predicates:
56 tbhide : True
56 tbhide : True
57 readonly : False
57 readonly : False
58 ipython_internal : True
58 ipython_internal : True
59
59
60 If all predicates are set to ``False``, ``skip_hidden`` will practically have
60 If all predicates are set to ``False``, ``skip_hidden`` will practically have
61 no effect. We attempt to warn you when all predicates are False.
61 no effect. We attempt to warn you when all predicates are False.
62
62
63 Note that the ``readonly`` predicate may increase disk access as we check for
63 Note that the ``readonly`` predicate may increase disk access as we check for
64 file access permission for all frames on many command invocation, but is usually
64 file access permission for all frames on many command invocation, but is usually
65 cached by operating systems. Let us know if you encounter any issues.
65 cached by operating systems. Let us know if you encounter any issues.
66
66
67 As the IPython debugger does not use the traitlets infrastructure for
68 configuration, by editing your ``.pdbrc`` files and appending commands you would
69 like to be executed just before entering the interactive prompt. For example:
70
71
72 .. code::
73
74 # file : ~/.pdbrc
75 skip_predicates readonly True
76 skip_predicates tbhide False
77
78 Will hide read only frames by default and show frames marked with
79 ``__tracebackhide__``.
80
81
82
67
83
68 Thanks
84 Thanks
69 ------
85 ------
70
86
71 Many thanks to all the contributors to this release you can find all individual
87 Many thanks to all the contributors to this release you can find all individual
72 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/87>`__.
88 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/87>`__.
73
89
74 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
90 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
75 work on IPython and related libraries, in particular above mentioned
91 work on IPython and related libraries, in particular above mentioned
76 improvements to the debugger.
92 improvements to the debugger.
77
93
78
94
79
95
80
96
81 .. _version 7.23:
97 .. _version 7.23:
82
98
83 IPython 7.23 and 7.23.1
99 IPython 7.23 and 7.23.1
84 =======================
100 =======================
85
101
86
102
87 Third release of IPython for 2021, mostly containing bug fixes. A couple of not
103 Third release of IPython for 2021, mostly containing bug fixes. A couple of not
88 typical updates:
104 typical updates:
89
105
90 - We moved to GitHub actions away from Travis-CI, the transition may not be
106 - We moved to GitHub actions away from Travis-CI, the transition may not be
91 100% complete (not testing on nightly anymore), but as we ran out of
107 100% complete (not testing on nightly anymore), but as we ran out of
92 Travis-Ci hours on the IPython organisation that was a necessary step.
108 Travis-Ci hours on the IPython organisation that was a necessary step.
93 :ghpull:`12900`.
109 :ghpull:`12900`.
94
110
95 - We have a new dependency: ``matplotlib-inline``, which try to extract
111 - We have a new dependency: ``matplotlib-inline``, which try to extract
96 matplotlib inline backend specific behavior. It is available on PyPI and
112 matplotlib inline backend specific behavior. It is available on PyPI and
97 conda-forge thus should not be a problem to upgrade to this version. If you
113 conda-forge thus should not be a problem to upgrade to this version. If you
98 are a package maintainer that might be an extra dependency to package first.
114 are a package maintainer that might be an extra dependency to package first.
99 :ghpull:`12817` (IPython 7.23.1 fix a typo that made this change fail)
115 :ghpull:`12817` (IPython 7.23.1 fix a typo that made this change fail)
100
116
101 In the addition/new feature category, ``display()`` now have a ``clear=True``
117 In the addition/new feature category, ``display()`` now have a ``clear=True``
102 option to clear the display if any further outputs arrives, allowing users to
118 option to clear the display if any further outputs arrives, allowing users to
103 avoid having to use ``clear_output()`` directly. :ghpull:`12823`.
119 avoid having to use ``clear_output()`` directly. :ghpull:`12823`.
104
120
105 In bug fixes category, this release fix an issue when printing tracebacks
121 In bug fixes category, this release fix an issue when printing tracebacks
106 containing Unicode characters :ghpull:`12758`.
122 containing Unicode characters :ghpull:`12758`.
107
123
108 In code cleanup category :ghpull:`12932` remove usage of some deprecated
124 In code cleanup category :ghpull:`12932` remove usage of some deprecated
109 functionality for compatibility with Python 3.10.
125 functionality for compatibility with Python 3.10.
110
126
111
127
112
128
113 Thanks
129 Thanks
114 ------
130 ------
115
131
116 Many thanks to all the contributors to this release you can find all individual
132 Many thanks to all the contributors to this release you can find all individual
117 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/86>`__.
133 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/86>`__.
118 In particular MrMino for responding to almost all new issues, and triaging many
134 In particular MrMino for responding to almost all new issues, and triaging many
119 of the old ones, as well as takluyver, minrk, willingc for reacting quikly when
135 of the old ones, as well as takluyver, minrk, willingc for reacting quikly when
120 we ran out of CI Hours.
136 we ran out of CI Hours.
121
137
122 Thanks as well to organisations, QuantStack (martinRenou and SylvainCorlay) for
138 Thanks as well to organisations, QuantStack (martinRenou and SylvainCorlay) for
123 extracting matplotlib inline backend into its own package, and the `D. E. Shaw group
139 extracting matplotlib inline backend into its own package, and the `D. E. Shaw group
124 <https://deshaw.com/>`__ for sponsoring work on IPython and related libraries.
140 <https://deshaw.com/>`__ for sponsoring work on IPython and related libraries.
125
141
126
142
127 .. _version 7.22:
143 .. _version 7.22:
128
144
129 IPython 7.22
145 IPython 7.22
130 ============
146 ============
131
147
132 Second release of IPython for 2021, mostly containing bug fixes. Here is a quick
148 Second release of IPython for 2021, mostly containing bug fixes. Here is a quick
133 rundown of the few changes.
149 rundown of the few changes.
134
150
135 - Fix some ``sys.excepthook`` shenanigan when embedding with qt, recommended if
151 - Fix some ``sys.excepthook`` shenanigan when embedding with qt, recommended if
136 you – for example – use `napari <https://napari.org>`__. :ghpull:`12842`.
152 you – for example – use `napari <https://napari.org>`__. :ghpull:`12842`.
137 - Fix bug when using the new ipdb ``%context`` magic :ghpull:`12844`
153 - Fix bug when using the new ipdb ``%context`` magic :ghpull:`12844`
138 - Couples of deprecation cleanup :ghpull:`12868`
154 - Couples of deprecation cleanup :ghpull:`12868`
139 - Update for new dpast.com api if you use the ``%pastbin`` magic. :ghpull:`12712`
155 - Update for new dpast.com api if you use the ``%pastbin`` magic. :ghpull:`12712`
140 - Remove support for numpy before 1.16. :ghpull:`12836`
156 - Remove support for numpy before 1.16. :ghpull:`12836`
141
157
142
158
143 Thanks
159 Thanks
144 ------
160 ------
145
161
146 We have a new team member that you should see more often on the IPython
162 We have a new team member that you should see more often on the IPython
147 repository, BΕ‚aΕΌej Michalik (@MrMino) have been doing regular contributions to
163 repository, BΕ‚aΕΌej Michalik (@MrMino) have been doing regular contributions to
148 IPython, and spent time replying to many issues and guiding new users to the
164 IPython, and spent time replying to many issues and guiding new users to the
149 codebase; they now have triage permissions to the IPython repository and we'll
165 codebase; they now have triage permissions to the IPython repository and we'll
150 work toward giving them more permission in the future.
166 work toward giving them more permission in the future.
151
167
152 Many thanks to all the contributors to this release you can find all individual
168 Many thanks to all the contributors to this release you can find all individual
153 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/84>`__.
169 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/84>`__.
154
170
155 Thanks as well to organisations, QuantStack for working on debugger
171 Thanks as well to organisations, QuantStack for working on debugger
156 compatibility for Xeus_python, and the `D. E. Shaw group
172 compatibility for Xeus_python, and the `D. E. Shaw group
157 <https://deshaw.com/>`__ for sponsoring work on IPython and related libraries.
173 <https://deshaw.com/>`__ for sponsoring work on IPython and related libraries.
158
174
159 .. _version 721:
175 .. _version 721:
160
176
161 IPython 7.21
177 IPython 7.21
162 ============
178 ============
163
179
164 IPython 7.21 is the first release we have back on schedule of one release every
180 IPython 7.21 is the first release we have back on schedule of one release every
165 month; it contains a number of minor fixes and improvements, notably, the new
181 month; it contains a number of minor fixes and improvements, notably, the new
166 context command for ipdb
182 context command for ipdb
167
183
168
184
169 New "context" command in ipdb
185 New "context" command in ipdb
170 -----------------------------
186 -----------------------------
171
187
172 It is now possible to change the number of lines shown in the backtrace
188 It is now possible to change the number of lines shown in the backtrace
173 information in ipdb using "context" command. :ghpull:`12826`
189 information in ipdb using "context" command. :ghpull:`12826`
174
190
175 (thanks @MrMino, there are other improvement from them on master).
191 (thanks @MrMino, there are other improvement from them on master).
176
192
177 Other notable changes in IPython 7.21
193 Other notable changes in IPython 7.21
178 -------------------------------------
194 -------------------------------------
179
195
180 - Fix some issues on new osx-arm64 :ghpull:`12804`, :ghpull:`12807`.
196 - Fix some issues on new osx-arm64 :ghpull:`12804`, :ghpull:`12807`.
181 - Compatibility with Xeus-Python for debugger protocol, :ghpull:`12809`
197 - Compatibility with Xeus-Python for debugger protocol, :ghpull:`12809`
182 - Misc docs fixes for compatibility and uniformity with Numpydoc.
198 - Misc docs fixes for compatibility and uniformity with Numpydoc.
183 :ghpull:`12824`
199 :ghpull:`12824`
184
200
185
201
186 Thanks
202 Thanks
187 ------
203 ------
188
204
189 Many thanks to all the contributors to this release you can find all individual
205 Many thanks to all the contributors to this release you can find all individual
190 contribution to this milestone `on github <https://github.com/ipython/ipython/milestone/83>`__.
206 contribution to this milestone `on github <https://github.com/ipython/ipython/milestone/83>`__.
191
207
192
208
193 .. _version 720:
209 .. _version 720:
194
210
195 IPython 7.20
211 IPython 7.20
196 ============
212 ============
197
213
198 IPython 7.20 is the accumulation of 3 month of work on IPython, spacing between
214 IPython 7.20 is the accumulation of 3 month of work on IPython, spacing between
199 IPython release have been increased from the usual once a month for various
215 IPython release have been increased from the usual once a month for various
200 reason.
216 reason.
201
217
202 - Mainly as I'm too busy and the effectively sole maintainer, and
218 - Mainly as I'm too busy and the effectively sole maintainer, and
203 - Second because not much changes happened before mid December.
219 - Second because not much changes happened before mid December.
204
220
205 The main driver for this release was the new version of Jedi 0.18 breaking API;
221 The main driver for this release was the new version of Jedi 0.18 breaking API;
206 which was taken care of in the master branch early in 2020 but not in 7.x as I
222 which was taken care of in the master branch early in 2020 but not in 7.x as I
207 though that by now 8.0 would be out.
223 though that by now 8.0 would be out.
208
224
209 The inclusion of a resolver in pip did not help and actually made things worse.
225 The inclusion of a resolver in pip did not help and actually made things worse.
210 If usually I would have simply pinned Jedi to ``<0.18``; this is not a solution
226 If usually I would have simply pinned Jedi to ``<0.18``; this is not a solution
211 anymore as now pip is free to install Jedi 0.18, and downgrade IPython.
227 anymore as now pip is free to install Jedi 0.18, and downgrade IPython.
212
228
213 I'll do my best to keep the regular release, but as the 8.0-dev branch and 7.x
229 I'll do my best to keep the regular release, but as the 8.0-dev branch and 7.x
214 are starting to diverge this is becoming difficult in particular with my limited
230 are starting to diverge this is becoming difficult in particular with my limited
215 time, so if you have any cycles to spare I'll appreciate your help to respond to
231 time, so if you have any cycles to spare I'll appreciate your help to respond to
216 issues and pushing 8.0 forward.
232 issues and pushing 8.0 forward.
217
233
218 Here are thus some of the changes for IPython 7.20.
234 Here are thus some of the changes for IPython 7.20.
219
235
220 - Support for PyQt5 >= 5.11 :ghpull:`12715`
236 - Support for PyQt5 >= 5.11 :ghpull:`12715`
221 - ``%reset`` remove imports more agressively :ghpull:`12718`
237 - ``%reset`` remove imports more agressively :ghpull:`12718`
222 - fix the ``%conda`` magic :ghpull:`12739`
238 - fix the ``%conda`` magic :ghpull:`12739`
223 - compatibility with Jedi 0.18, and bump minimum Jedi version. :ghpull:`12793`
239 - compatibility with Jedi 0.18, and bump minimum Jedi version. :ghpull:`12793`
224
240
225
241
226 .. _version 719:
242 .. _version 719:
227
243
228 IPython 7.19
244 IPython 7.19
229 ============
245 ============
230
246
231 IPython 7.19 accumulative two month of works, bug fixes and improvements, there
247 IPython 7.19 accumulative two month of works, bug fixes and improvements, there
232 was exceptionally no release last month.
248 was exceptionally no release last month.
233
249
234 - Fix to restore the ability to specify more than one extension using command
250 - Fix to restore the ability to specify more than one extension using command
235 line flags when using traitlets 5.0 :ghpull:`12543`
251 line flags when using traitlets 5.0 :ghpull:`12543`
236 - Docs docs formatting that make the install commands work on zsh
252 - Docs docs formatting that make the install commands work on zsh
237 :ghpull:`12587`
253 :ghpull:`12587`
238 - Always display the last frame in tracebacks even if hidden with
254 - Always display the last frame in tracebacks even if hidden with
239 ``__traceback_hide__`` :ghpull:`12601`
255 ``__tracebackhide__`` :ghpull:`12601`
240 - Avoid an issue where a callback can be registered multiple times.
256 - Avoid an issue where a callback can be registered multiple times.
241 :ghpull:`12625`
257 :ghpull:`12625`
242 - Avoid an issue in debugger mode where frames changes could be lost.
258 - Avoid an issue in debugger mode where frames changes could be lost.
243 :ghpull:`12627`
259 :ghpull:`12627`
244
260
245 - Never hide the frames that invoke a debugger, even if marked as hidden by
261 - Never hide the frames that invoke a debugger, even if marked as hidden by
246 ``__traceback_hide__`` :ghpull:`12631`
262 ``__tracebackhide__`` :ghpull:`12631`
247 - Fix calling the debugger in a recursive manner :ghpull:`12659`
263 - Fix calling the debugger in a recursive manner :ghpull:`12659`
248
264
249
265
250 A number of code changes have landed on master and we are getting close to
266 A number of code changes have landed on master and we are getting close to
251 enough new features and codebase improvement that a 8.0 start to make sens.
267 enough new features and codebase improvement that a 8.0 start to make sens.
252 For downstream packages, please start working on migrating downstream testing
268 For downstream packages, please start working on migrating downstream testing
253 away from iptest and using pytest, as nose will not work on Python 3.10 and we
269 away from iptest and using pytest, as nose will not work on Python 3.10 and we
254 will likely start removing it as a dependency for testing.
270 will likely start removing it as a dependency for testing.
255
271
256 .. _version 718:
272 .. _version 718:
257
273
258 IPython 7.18
274 IPython 7.18
259 ============
275 ============
260
276
261 IPython 7.18 is a minor release that mostly contains bugfixes.
277 IPython 7.18 is a minor release that mostly contains bugfixes.
262
278
263 - ``CRLF`` is now handled by magics my default; solving some issues due to copy
279 - ``CRLF`` is now handled by magics my default; solving some issues due to copy
264 pasting on windows. :ghpull:`12475`
280 pasting on windows. :ghpull:`12475`
265
281
266 - Requiring pexpect ``>=4.3`` as we are Python 3.7+ only and earlier version of
282 - Requiring pexpect ``>=4.3`` as we are Python 3.7+ only and earlier version of
267 pexpect will be incompatible. :ghpull:`12510`
283 pexpect will be incompatible. :ghpull:`12510`
268
284
269 - Minimum jedi version is now 0.16. :ghpull:`12488`
285 - Minimum jedi version is now 0.16. :ghpull:`12488`
270
286
271
287
272
288
273 .. _version 717:
289 .. _version 717:
274
290
275 IPython 7.17
291 IPython 7.17
276 ============
292 ============
277
293
278 IPython 7.17 brings a couple of new improvements to API and a couple of user
294 IPython 7.17 brings a couple of new improvements to API and a couple of user
279 facing changes to make the terminal experience more user friendly.
295 facing changes to make the terminal experience more user friendly.
280
296
281 :ghpull:`12407` introduces the ability to pass extra argument to the IPython
297 :ghpull:`12407` introduces the ability to pass extra argument to the IPython
282 debugger class; this is to help a new project from ``kmaork``
298 debugger class; this is to help a new project from ``kmaork``
283 (https://github.com/kmaork/madbg) to feature a fully remote debugger.
299 (https://github.com/kmaork/madbg) to feature a fully remote debugger.
284
300
285 :ghpull:`12410` finally remove support for 3.6, while the codebase is still
301 :ghpull:`12410` finally remove support for 3.6, while the codebase is still
286 technically compatible; IPython will not install on Python 3.6.
302 technically compatible; IPython will not install on Python 3.6.
287
303
288 lots of work on the debugger and hidden frames from ``@impact27`` in
304 lots of work on the debugger and hidden frames from ``@impact27`` in
289 :ghpull:`12437`, :ghpull:`12445`, :ghpull:`12460` and in particular
305 :ghpull:`12437`, :ghpull:`12445`, :ghpull:`12460` and in particular
290 :ghpull:`12453` which make the debug magic more robust at handling spaces.
306 :ghpull:`12453` which make the debug magic more robust at handling spaces.
291
307
292 Biggest API addition is code transformation which is done before code execution;
308 Biggest API addition is code transformation which is done before code execution;
293 IPython allows a number of hooks to catch non-valid Python syntax (magic, prompt
309 IPython allows a number of hooks to catch non-valid Python syntax (magic, prompt
294 stripping...etc). Transformers are usually called many time; typically:
310 stripping...etc). Transformers are usually called many time; typically:
295
311
296 - When trying to figure out whether the code is complete and valid (should we
312 - When trying to figure out whether the code is complete and valid (should we
297 insert a new line or execute ?)
313 insert a new line or execute ?)
298 - During actual code execution pass before giving the code to Python's
314 - During actual code execution pass before giving the code to Python's
299 ``exec``.
315 ``exec``.
300
316
301 This lead to issues when transformer might have had side effects; or do external
317 This lead to issues when transformer might have had side effects; or do external
302 queries. Starting with IPython 7.17 you can expect your transformer to be called
318 queries. Starting with IPython 7.17 you can expect your transformer to be called
303 less time.
319 less time.
304
320
305 Input transformers are now called only once in the execution path of
321 Input transformers are now called only once in the execution path of
306 `InteractiveShell`, allowing to register transformer that potentially have side
322 `InteractiveShell`, allowing to register transformer that potentially have side
307 effects (note that this is not recommended). Internal methods `should_run_async`, and
323 effects (note that this is not recommended). Internal methods `should_run_async`, and
308 `run_cell_async` now take a recommended optional `transformed_cell`, and
324 `run_cell_async` now take a recommended optional `transformed_cell`, and
309 `preprocessing_exc_tuple` parameters that will become mandatory at some point in
325 `preprocessing_exc_tuple` parameters that will become mandatory at some point in
310 the future; that is to say cells need to be explicitly transformed to be valid
326 the future; that is to say cells need to be explicitly transformed to be valid
311 Python syntax ahead of trying to run them. :ghpull:`12440`;
327 Python syntax ahead of trying to run them. :ghpull:`12440`;
312
328
313 ``input_transformers`` can now also have an attribute ``has_side_effects`` set
329 ``input_transformers`` can now also have an attribute ``has_side_effects`` set
314 to `True`, when this attribute is present; this will prevent the transformers
330 to `True`, when this attribute is present; this will prevent the transformers
315 from being ran when IPython is trying to guess whether the user input is
331 from being ran when IPython is trying to guess whether the user input is
316 complete. Note that this may means you will need to explicitly execute in some
332 complete. Note that this may means you will need to explicitly execute in some
317 case where your transformations are now not ran; but will not affect users with
333 case where your transformations are now not ran; but will not affect users with
318 no custom extensions.
334 no custom extensions.
319
335
320
336
321 API Changes
337 API Changes
322 -----------
338 -----------
323
339
324 Change of API and exposed objects automatically detected using `frappuccino
340 Change of API and exposed objects automatically detected using `frappuccino
325 <https://pypi.org/project/frappuccino/>`_
341 <https://pypi.org/project/frappuccino/>`_
326
342
327
343
328 The following items are new since 7.16.0::
344 The following items are new since 7.16.0::
329
345
330 + IPython.core.interactiveshell.InteractiveShell.get_local_scope(self, stack_depth)
346 + IPython.core.interactiveshell.InteractiveShell.get_local_scope(self, stack_depth)
331
347
332 The following signatures differ since 7.16.0::
348 The following signatures differ since 7.16.0::
333
349
334 - IPython.core.interactiveshell.InteractiveShell.run_cell_async(self, raw_cell, store_history=False, silent=False, shell_futures=True)
350 - IPython.core.interactiveshell.InteractiveShell.run_cell_async(self, raw_cell, store_history=False, silent=False, shell_futures=True)
335 + IPython.core.interactiveshell.InteractiveShell.run_cell_async(self, raw_cell, store_history=False, silent=False, shell_futures=True, *, transformed_cell=None, preprocessing_exc_tuple=None)
351 + IPython.core.interactiveshell.InteractiveShell.run_cell_async(self, raw_cell, store_history=False, silent=False, shell_futures=True, *, transformed_cell=None, preprocessing_exc_tuple=None)
336
352
337 - IPython.core.interactiveshell.InteractiveShell.should_run_async(self, raw_cell)
353 - IPython.core.interactiveshell.InteractiveShell.should_run_async(self, raw_cell)
338 + IPython.core.interactiveshell.InteractiveShell.should_run_async(self, raw_cell, *, transformed_cell=None, preprocessing_exc_tuple=None)
354 + IPython.core.interactiveshell.InteractiveShell.should_run_async(self, raw_cell, *, transformed_cell=None, preprocessing_exc_tuple=None)
339
355
340 - IPython.terminal.debugger.TerminalPdb.pt_init(self)
356 - IPython.terminal.debugger.TerminalPdb.pt_init(self)
341 + IPython.terminal.debugger.TerminalPdb.pt_init(self, pt_session_options=None)
357 + IPython.terminal.debugger.TerminalPdb.pt_init(self, pt_session_options=None)
342
358
343 This method was added::
359 This method was added::
344
360
345 + IPython.core.interactiveshell.InteractiveShell.get_local_scope
361 + IPython.core.interactiveshell.InteractiveShell.get_local_scope
346
362
347 Which is now also present on subclasses::
363 Which is now also present on subclasses::
348
364
349 + IPython.terminal.embed.InteractiveShellEmbed.get_local_scope
365 + IPython.terminal.embed.InteractiveShellEmbed.get_local_scope
350 + IPython.terminal.interactiveshell.TerminalInteractiveShell.get_local_scope
366 + IPython.terminal.interactiveshell.TerminalInteractiveShell.get_local_scope
351
367
352
368
353 .. _version 716:
369 .. _version 716:
354
370
355 IPython 7.16
371 IPython 7.16
356 ============
372 ============
357
373
358
374
359 The default traceback mode will now skip frames that are marked with
375 The default traceback mode will now skip frames that are marked with
360 ``__tracebackhide__ = True`` and show how many traceback frames have been
376 ``__tracebackhide__ = True`` and show how many traceback frames have been
361 skipped. This can be toggled by using :magic:`xmode` with the ``--show`` or
377 skipped. This can be toggled by using :magic:`xmode` with the ``--show`` or
362 ``--hide`` attribute. It will have no effect on non verbose traceback modes.
378 ``--hide`` attribute. It will have no effect on non verbose traceback modes.
363
379
364 The ipython debugger also now understands ``__tracebackhide__`` as well and will
380 The ipython debugger also now understands ``__tracebackhide__`` as well and will
365 skip hidden frames when displaying. Movement up and down the stack will skip the
381 skip hidden frames when displaying. Movement up and down the stack will skip the
366 hidden frames and will show how many frames were hidden. Internal IPython frames
382 hidden frames and will show how many frames were hidden. Internal IPython frames
367 are also now hidden by default. The behavior can be changed with the
383 are also now hidden by default. The behavior can be changed with the
368 ``skip_hidden`` while in the debugger, command and accepts "yes", "no", "true"
384 ``skip_hidden`` while in the debugger, command and accepts "yes", "no", "true"
369 and "false" case insensitive parameters.
385 and "false" case insensitive parameters.
370
386
371
387
372 Misc Noticeable changes:
388 Misc Noticeable changes:
373 ------------------------
389 ------------------------
374
390
375 - Exceptions are now (re)raised when running notebooks via the :magic:`%run`, helping to catch issues in workflows and
391 - Exceptions are now (re)raised when running notebooks via the :magic:`%run`, helping to catch issues in workflows and
376 pipelines. :ghpull:`12301`
392 pipelines. :ghpull:`12301`
377 - Fix inputhook for qt 5.15.0 :ghpull:`12355`
393 - Fix inputhook for qt 5.15.0 :ghpull:`12355`
378 - Fix wx inputhook :ghpull:`12375`
394 - Fix wx inputhook :ghpull:`12375`
379 - Add handling for malformed pathext env var (Windows) :ghpull:`12367`
395 - Add handling for malformed pathext env var (Windows) :ghpull:`12367`
380 - use $SHELL in system_piped :ghpull:`12360` for uniform behavior with
396 - use $SHELL in system_piped :ghpull:`12360` for uniform behavior with
381 ipykernel.
397 ipykernel.
382
398
383 Reproducible Build
399 Reproducible Build
384 ------------------
400 ------------------
385
401
386 IPython 7.15 reproducible build did not work, so we try again this month
402 IPython 7.15 reproducible build did not work, so we try again this month
387 :ghpull:`12358`.
403 :ghpull:`12358`.
388
404
389
405
390 API Changes
406 API Changes
391 -----------
407 -----------
392
408
393 Change of API and exposed objects automatically detected using `frappuccino
409 Change of API and exposed objects automatically detected using `frappuccino
394 <https://pypi.org/project/frappuccino/>`_ (still in beta):
410 <https://pypi.org/project/frappuccino/>`_ (still in beta):
395
411
396
412
397 The following items are new and mostly related to understanding ``__tracebackbhide__``::
413 The following items are new and mostly related to understanding ``__tracebackbide__``::
398
414
399 + IPython.core.debugger.Pdb.do_down(self, arg)
415 + IPython.core.debugger.Pdb.do_down(self, arg)
400 + IPython.core.debugger.Pdb.do_skip_hidden(self, arg)
416 + IPython.core.debugger.Pdb.do_skip_hidden(self, arg)
401 + IPython.core.debugger.Pdb.do_up(self, arg)
417 + IPython.core.debugger.Pdb.do_up(self, arg)
402 + IPython.core.debugger.Pdb.hidden_frames(self, stack)
418 + IPython.core.debugger.Pdb.hidden_frames(self, stack)
403 + IPython.core.debugger.Pdb.stop_here(self, frame)
419 + IPython.core.debugger.Pdb.stop_here(self, frame)
404
420
405
421
406 The following items have been removed::
422 The following items have been removed::
407
423
408 - IPython.core.debugger.Pdb.new_do_down
424 - IPython.core.debugger.Pdb.new_do_down
409 - IPython.core.debugger.Pdb.new_do_up
425 - IPython.core.debugger.Pdb.new_do_up
410
426
411 Those were implementation details.
427 Those were implementation details.
412
428
413
429
414 .. _version 715:
430 .. _version 715:
415
431
416 IPython 7.15
432 IPython 7.15
417 ============
433 ============
418
434
419 IPython 7.15 brings a number of bug fixes and user facing improvements.
435 IPython 7.15 brings a number of bug fixes and user facing improvements.
420
436
421 Misc Noticeable changes:
437 Misc Noticeable changes:
422 ------------------------
438 ------------------------
423
439
424 - Long completion name have better elision in terminal :ghpull:`12284`
440 - Long completion name have better elision in terminal :ghpull:`12284`
425 - I've started to test on Python 3.9 :ghpull:`12307` and fix some errors.
441 - I've started to test on Python 3.9 :ghpull:`12307` and fix some errors.
426 - Hi DPI scaling of figures when using qt eventloop :ghpull:`12314`
442 - Hi DPI scaling of figures when using qt eventloop :ghpull:`12314`
427 - Document the ability to have systemwide configuration for IPython.
443 - Document the ability to have systemwide configuration for IPython.
428 :ghpull:`12328`
444 :ghpull:`12328`
429 - Fix issues with input autoformatting :ghpull:`12336`
445 - Fix issues with input autoformatting :ghpull:`12336`
430 - ``IPython.core.debugger.Pdb`` is now interruptible (:ghpull:`12168`, in 7.14
446 - ``IPython.core.debugger.Pdb`` is now interruptible (:ghpull:`12168`, in 7.14
431 but forgotten in release notes)
447 but forgotten in release notes)
432 - Video HTML attributes (:ghpull:`12212`, in 7.14 but forgotten in release
448 - Video HTML attributes (:ghpull:`12212`, in 7.14 but forgotten in release
433 notes)
449 notes)
434
450
435 Reproducible Build
451 Reproducible Build
436 ------------------
452 ------------------
437
453
438 Starting with IPython 7.15, I am attempting to provide reproducible builds,
454 Starting with IPython 7.15, I am attempting to provide reproducible builds,
439 that is to say you should be able from the source tree to generate an sdist
455 that is to say you should be able from the source tree to generate an sdist
440 and wheel that are identical byte for byte with the publish version on PyPI.
456 and wheel that are identical byte for byte with the publish version on PyPI.
441
457
442 I've only tested on a couple of machines so far and the process is relatively
458 I've only tested on a couple of machines so far and the process is relatively
443 straightforward, so this mean that IPython not only have a deterministic build
459 straightforward, so this mean that IPython not only have a deterministic build
444 process, but also I have either removed, or put under control all effects of
460 process, but also I have either removed, or put under control all effects of
445 the build environments on the final artifact. I encourage you to attempt the
461 the build environments on the final artifact. I encourage you to attempt the
446 build process on your machine as documented in :ref:`core_developer_guide`
462 build process on your machine as documented in :ref:`core_developer_guide`
447 and let me know if you do not obtain an identical artifact.
463 and let me know if you do not obtain an identical artifact.
448
464
449 While reproducible builds is critical to check that the supply chain of (open
465 While reproducible builds is critical to check that the supply chain of (open
450 source) software has not been compromised, it can also help to speedup many
466 source) software has not been compromised, it can also help to speedup many
451 of the build processes in large environment (conda, apt...) by allowing
467 of the build processes in large environment (conda, apt...) by allowing
452 better caching of intermediate build steps.
468 better caching of intermediate build steps.
453
469
454 Learn more on `<https://reproducible-builds.org/>`_. `Reflections on trusting
470 Learn more on `<https://reproducible-builds.org/>`_. `Reflections on trusting
455 trust <https://dl.acm.org/doi/10.1145/358198.358210>`_ is also one of the
471 trust <https://dl.acm.org/doi/10.1145/358198.358210>`_ is also one of the
456 cornerstone and recommended reads on this subject.
472 cornerstone and recommended reads on this subject.
457
473
458 .. note::
474 .. note::
459
475
460 The build commit from which the sdist is generated is also `signed
476 The build commit from which the sdist is generated is also `signed
461 <https://en.wikipedia.org/wiki/Digital_signature>`_, so you should be able to
477 <https://en.wikipedia.org/wiki/Digital_signature>`_, so you should be able to
462 check it has not been compromised, and the git repository is a `merkle-tree
478 check it has not been compromised, and the git repository is a `merkle-tree
463 <https://en.wikipedia.org/wiki/Merkle_tree>`_, you can check the consistency
479 <https://en.wikipedia.org/wiki/Merkle_tree>`_, you can check the consistency
464 with `git-fsck <https://git-scm.com/docs/git-fsck>`_ which you likely `want
480 with `git-fsck <https://git-scm.com/docs/git-fsck>`_ which you likely `want
465 to enable by default
481 to enable by default
466 <https://gist.github.com/mbbx6spp/14b86437e794bffb4120>`_.
482 <https://gist.github.com/mbbx6spp/14b86437e794bffb4120>`_.
467
483
468 NEP29: Last version to support Python 3.6
484 NEP29: Last version to support Python 3.6
469 -----------------------------------------
485 -----------------------------------------
470
486
471 IPython 7.15 will be the Last IPython version to officially support Python
487 IPython 7.15 will be the Last IPython version to officially support Python
472 3.6, as stated by `NumPy Enhancement Proposal 29
488 3.6, as stated by `NumPy Enhancement Proposal 29
473 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_. Starting with
489 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_. Starting with
474 next minor version of IPython I may stop testing on Python 3.6 and may stop
490 next minor version of IPython I may stop testing on Python 3.6 and may stop
475 publishing release artifacts that install on Python 3.6
491 publishing release artifacts that install on Python 3.6
476
492
477 Highlighted features
493 Highlighted features
478 --------------------
494 --------------------
479
495
480 Highlighted features are not new, but seem to not be widely known, this
496 Highlighted features are not new, but seem to not be widely known, this
481 section will help you discover in more narrative form what you can do with
497 section will help you discover in more narrative form what you can do with
482 IPython.
498 IPython.
483
499
484 Increase Tab Completion Menu Height
500 Increase Tab Completion Menu Height
485 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
501 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
486
502
487 In terminal IPython it is possible to increase the hight of the tab-completion
503 In terminal IPython it is possible to increase the hight of the tab-completion
488 menu. To do so set the value of
504 menu. To do so set the value of
489 :configtrait:`TerminalInteractiveShell.space_for_menu`, this will reserve more
505 :configtrait:`TerminalInteractiveShell.space_for_menu`, this will reserve more
490 space at the bottom of the screen for various kind of menus in IPython including
506 space at the bottom of the screen for various kind of menus in IPython including
491 tab completion and searching in history.
507 tab completion and searching in history.
492
508
493 Autoformat Code in the terminal
509 Autoformat Code in the terminal
494 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
510 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
495
511
496 If you have a preferred code formatter, you can configure IPython to
512 If you have a preferred code formatter, you can configure IPython to
497 reformat your code. Set the value of
513 reformat your code. Set the value of
498 :configtrait:`TerminalInteractiveShell.autoformatter` to for example ``'black'``
514 :configtrait:`TerminalInteractiveShell.autoformatter` to for example ``'black'``
499 and IPython will auto format your code when possible.
515 and IPython will auto format your code when possible.
500
516
501
517
502 .. _version 714:
518 .. _version 714:
503
519
504 IPython 7.14
520 IPython 7.14
505 ============
521 ============
506
522
507 IPython 7.14 is a minor release that fix a couple of bugs and prepare
523 IPython 7.14 is a minor release that fix a couple of bugs and prepare
508 compatibility with new or future versions of some libraries.
524 compatibility with new or future versions of some libraries.
509
525
510 Important changes:
526 Important changes:
511 ------------------
527 ------------------
512
528
513 - Fix compatibility with Sphinx 3+ :ghpull:`12235`
529 - Fix compatibility with Sphinx 3+ :ghpull:`12235`
514 - Remove deprecated matplotlib parameter usage, compatibility with matplotlib
530 - Remove deprecated matplotlib parameter usage, compatibility with matplotlib
515 3.3+ :`122250`
531 3.3+ :`122250`
516
532
517 Misc Changes
533 Misc Changes
518 ------------
534 ------------
519
535
520 - set ``.py`` extension when editing current buffer in vi/emacs. :ghpull:`12167`
536 - set ``.py`` extension when editing current buffer in vi/emacs. :ghpull:`12167`
521 - support for unicode identifiers in ``?``/``??`` :ghpull:`12208`
537 - support for unicode identifiers in ``?``/``??`` :ghpull:`12208`
522 - add extra options to the ``Video`` Rich objects :ghpull:`12212`
538 - add extra options to the ``Video`` Rich objects :ghpull:`12212`
523 - add pretty-printing to ``SimpleNamespace`` :ghpull:`12230`
539 - add pretty-printing to ``SimpleNamespace`` :ghpull:`12230`
524
540
525 IPython.core.debugger.Pdb is now interruptible
541 IPython.core.debugger.Pdb is now interruptible
526 ----------------------------------------------
542 ----------------------------------------------
527
543
528 A ``KeyboardInterrupt`` will now interrupt IPython's extended debugger, in order to make Jupyter able to interrupt it. (:ghpull:`12168`)
544 A ``KeyboardInterrupt`` will now interrupt IPython's extended debugger, in order to make Jupyter able to interrupt it. (:ghpull:`12168`)
529
545
530 Video HTML attributes
546 Video HTML attributes
531 ---------------------
547 ---------------------
532
548
533 Add an option to `IPython.display.Video` to change the attributes of the HTML display of the video (:ghpull:`12212`)
549 Add an option to `IPython.display.Video` to change the attributes of the HTML display of the video (:ghpull:`12212`)
534
550
535
551
536 Pending deprecated imports
552 Pending deprecated imports
537 --------------------------
553 --------------------------
538
554
539 Many object present in ``IPython.core.display`` are there for internal use only,
555 Many object present in ``IPython.core.display`` are there for internal use only,
540 and should already been imported from ``IPython.display`` by users and external
556 and should already been imported from ``IPython.display`` by users and external
541 libraries. Trying to import those from ``IPython.core.display`` is still possible
557 libraries. Trying to import those from ``IPython.core.display`` is still possible
542 but will trigger a
558 but will trigger a
543 deprecation warning in later versions of IPython and will become errors in the
559 deprecation warning in later versions of IPython and will become errors in the
544 future.
560 future.
545
561
546 This will simplify compatibility with other Python kernels (like Xeus-Python),
562 This will simplify compatibility with other Python kernels (like Xeus-Python),
547 and simplify code base.
563 and simplify code base.
548
564
549
565
550
566
551
567
552 .. _version 713:
568 .. _version 713:
553
569
554 IPython 7.13
570 IPython 7.13
555 ============
571 ============
556
572
557 IPython 7.13 is the final release of the 7.x branch since master is diverging
573 IPython 7.13 is the final release of the 7.x branch since master is diverging
558 toward an 8.0. Exiting new features have already been merged in 8.0 and will
574 toward an 8.0. Exiting new features have already been merged in 8.0 and will
559 not be available on the 7.x branch. All the changes below have been backported
575 not be available on the 7.x branch. All the changes below have been backported
560 from the master branch.
576 from the master branch.
561
577
562
578
563 - Fix inability to run PDB when inside an event loop :ghpull:`12141`
579 - Fix inability to run PDB when inside an event loop :ghpull:`12141`
564 - Fix ability to interrupt some processes on windows :ghpull:`12137`
580 - Fix ability to interrupt some processes on windows :ghpull:`12137`
565 - Fix debugger shortcuts :ghpull:`12132`
581 - Fix debugger shortcuts :ghpull:`12132`
566 - improve tab completion when inside a string by removing irrelevant elements :ghpull:`12128`
582 - improve tab completion when inside a string by removing irrelevant elements :ghpull:`12128`
567 - Fix display of filename tab completion when the path is long :ghpull:`12122`
583 - Fix display of filename tab completion when the path is long :ghpull:`12122`
568 - Many removal of Python 2 specific code path :ghpull:`12110`
584 - Many removal of Python 2 specific code path :ghpull:`12110`
569 - displaying wav files do not require NumPy anymore, and is 5x to 30x faster :ghpull:`12113`
585 - displaying wav files do not require NumPy anymore, and is 5x to 30x faster :ghpull:`12113`
570
586
571 See the list of all closed issues and pull request on `github
587 See the list of all closed issues and pull request on `github
572 <https://github.com/ipython/ipython/pulls?q=is%3Aclosed+milestone%3A7.13>`_.
588 <https://github.com/ipython/ipython/pulls?q=is%3Aclosed+milestone%3A7.13>`_.
573
589
574 .. _version 712:
590 .. _version 712:
575
591
576 IPython 7.12
592 IPython 7.12
577 ============
593 ============
578
594
579 IPython 7.12 is a minor update that mostly brings code cleanup, removal of
595 IPython 7.12 is a minor update that mostly brings code cleanup, removal of
580 longtime deprecated function and a couple update to documentation cleanup as well.
596 longtime deprecated function and a couple update to documentation cleanup as well.
581
597
582 Notable changes are the following:
598 Notable changes are the following:
583
599
584 - Exit non-zero when ipython is given a file path to run that doesn't exist :ghpull:`12074`
600 - Exit non-zero when ipython is given a file path to run that doesn't exist :ghpull:`12074`
585 - Test PR on ARM64 with Travis-CI :ghpull:`12073`
601 - Test PR on ARM64 with Travis-CI :ghpull:`12073`
586 - Update CI to work with latest Pytest :ghpull:`12086`
602 - Update CI to work with latest Pytest :ghpull:`12086`
587 - Add infrastructure to run ipykernel eventloop via trio :ghpull:`12097`
603 - Add infrastructure to run ipykernel eventloop via trio :ghpull:`12097`
588 - Support git blame ignore revs :ghpull:`12091`
604 - Support git blame ignore revs :ghpull:`12091`
589 - Start multi-line ``__repr__`` s on their own line :ghpull:`12099`
605 - Start multi-line ``__repr__`` s on their own line :ghpull:`12099`
590
606
591 .. _version 7111:
607 .. _version 7111:
592
608
593 IPython 7.11.1
609 IPython 7.11.1
594 ==============
610 ==============
595
611
596 A couple of deprecated functions (no-op) have been reintroduces in py3compat as
612 A couple of deprecated functions (no-op) have been reintroduces in py3compat as
597 Cython was still relying on them, and will be removed in a couple of versions.
613 Cython was still relying on them, and will be removed in a couple of versions.
598
614
599 .. _version 711:
615 .. _version 711:
600
616
601 IPython 7.11
617 IPython 7.11
602 ============
618 ============
603
619
604 IPython 7.11 received a couple of compatibility fixes and code cleanup.
620 IPython 7.11 received a couple of compatibility fixes and code cleanup.
605
621
606 A number of function in the ``py3compat`` have been removed; a number of types
622 A number of function in the ``py3compat`` have been removed; a number of types
607 in the IPython code base are now non-ambiguous and now always ``unicode``
623 in the IPython code base are now non-ambiguous and now always ``unicode``
608 instead of ``Union[Unicode,bytes]``; many of the relevant code path have thus
624 instead of ``Union[Unicode,bytes]``; many of the relevant code path have thus
609 been simplified/cleaned and types annotation added.
625 been simplified/cleaned and types annotation added.
610
626
611 IPython support several verbosity level from exceptions. ``xmode plain`` now
627 IPython support several verbosity level from exceptions. ``xmode plain`` now
612 support chained exceptions. :ghpull:`11999`
628 support chained exceptions. :ghpull:`11999`
613
629
614 We are starting to remove ``shell=True`` in some usages of subprocess. While not directly
630 We are starting to remove ``shell=True`` in some usages of subprocess. While not directly
615 a security issue (as IPython is made to run arbitrary code anyway) it is not good
631 a security issue (as IPython is made to run arbitrary code anyway) it is not good
616 practice and we'd like to show the example. :ghissue:`12023`. This discussion
632 practice and we'd like to show the example. :ghissue:`12023`. This discussion
617 was started by ``@mschwager`` thanks to a new auditing tool they are working on
633 was started by ``@mschwager`` thanks to a new auditing tool they are working on
618 with duo-labs (`dlint <https://github.com/duo-labs/dlint>`_).
634 with duo-labs (`dlint <https://github.com/duo-labs/dlint>`_).
619
635
620 Work around some bugs in Python 3.9 tokenizer :ghpull:`12057`
636 Work around some bugs in Python 3.9 tokenizer :ghpull:`12057`
621
637
622 IPython will now print its version after a crash. :ghpull:`11986`
638 IPython will now print its version after a crash. :ghpull:`11986`
623
639
624 This is likely the last release from the 7.x series that will see new feature.
640 This is likely the last release from the 7.x series that will see new feature.
625 The master branch will soon accept large code changes and thrilling new
641 The master branch will soon accept large code changes and thrilling new
626 features; the 7.x branch will only start to accept critical bug fixes, and
642 features; the 7.x branch will only start to accept critical bug fixes, and
627 update dependencies.
643 update dependencies.
628
644
629 .. _version 7102:
645 .. _version 7102:
630
646
631 IPython 7.10.2
647 IPython 7.10.2
632 ==============
648 ==============
633
649
634 IPython 7.10.2 fix a couple of extra incompatibility between IPython, ipdb,
650 IPython 7.10.2 fix a couple of extra incompatibility between IPython, ipdb,
635 asyncio and Prompt Toolkit 3.
651 asyncio and Prompt Toolkit 3.
636
652
637 .. _version 7101:
653 .. _version 7101:
638
654
639 IPython 7.10.1
655 IPython 7.10.1
640 ==============
656 ==============
641
657
642 IPython 7.10.1 fix a couple of incompatibilities with Prompt toolkit 3 (please
658 IPython 7.10.1 fix a couple of incompatibilities with Prompt toolkit 3 (please
643 update Prompt toolkit to 3.0.2 at least), and fixes some interaction with
659 update Prompt toolkit to 3.0.2 at least), and fixes some interaction with
644 headless IPython.
660 headless IPython.
645
661
646 .. _version 7100:
662 .. _version 7100:
647
663
648 IPython 7.10.0
664 IPython 7.10.0
649 ==============
665 ==============
650
666
651 IPython 7.10 is the first double digit minor release in the last decade, and
667 IPython 7.10 is the first double digit minor release in the last decade, and
652 first since the release of IPython 1.0, previous double digit minor release was
668 first since the release of IPython 1.0, previous double digit minor release was
653 in August 2009.
669 in August 2009.
654
670
655 We've been trying to give you regular release on the last Friday of every month
671 We've been trying to give you regular release on the last Friday of every month
656 for a guaranty of rapid access to bug fixes and new features.
672 for a guaranty of rapid access to bug fixes and new features.
657
673
658 Unlike the previous first few releases that have seen only a couple of code
674 Unlike the previous first few releases that have seen only a couple of code
659 changes, 7.10 bring a number of changes, new features and bugfixes.
675 changes, 7.10 bring a number of changes, new features and bugfixes.
660
676
661 Stop Support for Python 3.5 – Adopt NEP 29
677 Stop Support for Python 3.5 – Adopt NEP 29
662 ------------------------------------------
678 ------------------------------------------
663
679
664 IPython has decided to follow the informational `NEP 29
680 IPython has decided to follow the informational `NEP 29
665 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_ which layout a clear
681 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_ which layout a clear
666 policy as to which version of (C)Python and NumPy are supported.
682 policy as to which version of (C)Python and NumPy are supported.
667
683
668 We thus dropped support for Python 3.5, and cleaned up a number of code path
684 We thus dropped support for Python 3.5, and cleaned up a number of code path
669 that were Python-version dependant. If you are on 3.5 or earlier pip should
685 that were Python-version dependant. If you are on 3.5 or earlier pip should
670 automatically give you the latest compatible version of IPython so you do not
686 automatically give you the latest compatible version of IPython so you do not
671 need to pin to a given version.
687 need to pin to a given version.
672
688
673 Support for Prompt Toolkit 3.0
689 Support for Prompt Toolkit 3.0
674 ------------------------------
690 ------------------------------
675
691
676 Prompt Toolkit 3.0 was release a week before IPython 7.10 and introduces a few
692 Prompt Toolkit 3.0 was release a week before IPython 7.10 and introduces a few
677 breaking changes. We believe IPython 7.10 should be compatible with both Prompt
693 breaking changes. We believe IPython 7.10 should be compatible with both Prompt
678 Toolkit 2.x and 3.x, though it has not been extensively tested with 3.x so
694 Toolkit 2.x and 3.x, though it has not been extensively tested with 3.x so
679 please report any issues.
695 please report any issues.
680
696
681
697
682 Prompt Rendering Performance improvements
698 Prompt Rendering Performance improvements
683 -----------------------------------------
699 -----------------------------------------
684
700
685 Pull Request :ghpull:`11933` introduced an optimisation in the prompt rendering
701 Pull Request :ghpull:`11933` introduced an optimisation in the prompt rendering
686 logic that should decrease the resource usage of IPython when using the
702 logic that should decrease the resource usage of IPython when using the
687 _default_ configuration but could potentially introduce a regression of
703 _default_ configuration but could potentially introduce a regression of
688 functionalities if you are using a custom prompt.
704 functionalities if you are using a custom prompt.
689
705
690 We know assume if you haven't changed the default keybindings that the prompt
706 We know assume if you haven't changed the default keybindings that the prompt
691 **will not change** during the duration of your input – which is for example
707 **will not change** during the duration of your input – which is for example
692 not true when using vi insert mode that switches between `[ins]` and `[nor]`
708 not true when using vi insert mode that switches between `[ins]` and `[nor]`
693 for the current mode.
709 for the current mode.
694
710
695 If you are experiencing any issue let us know.
711 If you are experiencing any issue let us know.
696
712
697 Code autoformatting
713 Code autoformatting
698 -------------------
714 -------------------
699
715
700 The IPython terminal can now auto format your code just before entering a new
716 The IPython terminal can now auto format your code just before entering a new
701 line or executing a command. To do so use the
717 line or executing a command. To do so use the
702 ``--TerminalInteractiveShell.autoformatter`` option and set it to ``'black'``;
718 ``--TerminalInteractiveShell.autoformatter`` option and set it to ``'black'``;
703 if black is installed IPython will use black to format your code when possible.
719 if black is installed IPython will use black to format your code when possible.
704
720
705 IPython cannot always properly format your code; in particular it will
721 IPython cannot always properly format your code; in particular it will
706 auto formatting with *black* will only work if:
722 auto formatting with *black* will only work if:
707
723
708 - Your code does not contains magics or special python syntax.
724 - Your code does not contains magics or special python syntax.
709
725
710 - There is no code after your cursor.
726 - There is no code after your cursor.
711
727
712 The Black API is also still in motion; so this may not work with all versions of
728 The Black API is also still in motion; so this may not work with all versions of
713 black.
729 black.
714
730
715 It should be possible to register custom formatter, though the API is till in
731 It should be possible to register custom formatter, though the API is till in
716 flux.
732 flux.
717
733
718 Arbitrary Mimetypes Handing in Terminal (Aka inline images in terminal)
734 Arbitrary Mimetypes Handing in Terminal (Aka inline images in terminal)
719 -----------------------------------------------------------------------
735 -----------------------------------------------------------------------
720
736
721 When using IPython terminal it is now possible to register function to handle
737 When using IPython terminal it is now possible to register function to handle
722 arbitrary mimetypes. While rendering non-text based representation was possible in
738 arbitrary mimetypes. While rendering non-text based representation was possible in
723 many jupyter frontend; it was not possible in terminal IPython, as usually
739 many jupyter frontend; it was not possible in terminal IPython, as usually
724 terminal are limited to displaying text. As many terminal these days provide
740 terminal are limited to displaying text. As many terminal these days provide
725 escape sequences to display non-text; bringing this loved feature to IPython CLI
741 escape sequences to display non-text; bringing this loved feature to IPython CLI
726 made a lot of sens. This functionality will not only allow inline images; but
742 made a lot of sens. This functionality will not only allow inline images; but
727 allow opening of external program; for example ``mplayer`` to "display" sound
743 allow opening of external program; for example ``mplayer`` to "display" sound
728 files.
744 files.
729
745
730 So far only the hooks necessary for this are in place, but no default mime
746 So far only the hooks necessary for this are in place, but no default mime
731 renderers added; so inline images will only be available via extensions. We will
747 renderers added; so inline images will only be available via extensions. We will
732 progressively enable these features by default in the next few releases, and
748 progressively enable these features by default in the next few releases, and
733 contribution is welcomed.
749 contribution is welcomed.
734
750
735 We welcome any feedback on the API. See :ref:`shell_mimerenderer` for more
751 We welcome any feedback on the API. See :ref:`shell_mimerenderer` for more
736 informations.
752 informations.
737
753
738 This is originally based on work form in :ghpull:`10610` from @stephanh42
754 This is originally based on work form in :ghpull:`10610` from @stephanh42
739 started over two years ago, and still a lot need to be done.
755 started over two years ago, and still a lot need to be done.
740
756
741 MISC
757 MISC
742 ----
758 ----
743
759
744 - Completions can define their own ordering :ghpull:`11855`
760 - Completions can define their own ordering :ghpull:`11855`
745 - Enable Plotting in the same cell than the one that import matplotlib
761 - Enable Plotting in the same cell than the one that import matplotlib
746 :ghpull:`11916`
762 :ghpull:`11916`
747 - Allow to store and restore multiple variables at once :ghpull:`11930`
763 - Allow to store and restore multiple variables at once :ghpull:`11930`
748
764
749 You can see `all pull-requests <https://github.com/ipython/ipython/pulls?q=is%3Apr+milestone%3A7.10+is%3Aclosed>`_ for this release.
765 You can see `all pull-requests <https://github.com/ipython/ipython/pulls?q=is%3Apr+milestone%3A7.10+is%3Aclosed>`_ for this release.
750
766
751 API Changes
767 API Changes
752 -----------
768 -----------
753
769
754 Change of API and exposed objects automatically detected using `frappuccino <https://pypi.org/project/frappuccino/>`_ (still in beta):
770 Change of API and exposed objects automatically detected using `frappuccino <https://pypi.org/project/frappuccino/>`_ (still in beta):
755
771
756 The following items are new in IPython 7.10::
772 The following items are new in IPython 7.10::
757
773
758 + IPython.terminal.shortcuts.reformat_text_before_cursor(buffer, document, shell)
774 + IPython.terminal.shortcuts.reformat_text_before_cursor(buffer, document, shell)
759 + IPython.terminal.interactiveshell.PTK3
775 + IPython.terminal.interactiveshell.PTK3
760 + IPython.terminal.interactiveshell.black_reformat_handler(text_before_cursor)
776 + IPython.terminal.interactiveshell.black_reformat_handler(text_before_cursor)
761 + IPython.terminal.prompts.RichPromptDisplayHook.write_format_data(self, format_dict, md_dict='None')
777 + IPython.terminal.prompts.RichPromptDisplayHook.write_format_data(self, format_dict, md_dict='None')
762
778
763 The following items have been removed in 7.10::
779 The following items have been removed in 7.10::
764
780
765 - IPython.lib.pretty.DICT_IS_ORDERED
781 - IPython.lib.pretty.DICT_IS_ORDERED
766
782
767 The following signatures differ between versions::
783 The following signatures differ between versions::
768
784
769 - IPython.extensions.storemagic.restore_aliases(ip)
785 - IPython.extensions.storemagic.restore_aliases(ip)
770 + IPython.extensions.storemagic.restore_aliases(ip, alias='None')
786 + IPython.extensions.storemagic.restore_aliases(ip, alias='None')
771
787
772 Special Thanks
788 Special Thanks
773 --------------
789 --------------
774
790
775 - @stephanh42 who started the work on inline images in terminal 2 years ago
791 - @stephanh42 who started the work on inline images in terminal 2 years ago
776 - @augustogoulart who spent a lot of time triaging issues and responding to
792 - @augustogoulart who spent a lot of time triaging issues and responding to
777 users.
793 users.
778 - @con-f-use who is my (@Carreau) first sponsor on GitHub, as a reminder if you
794 - @con-f-use who is my (@Carreau) first sponsor on GitHub, as a reminder if you
779 like IPython, Jupyter and many other library of the SciPy stack you can
795 like IPython, Jupyter and many other library of the SciPy stack you can
780 donate to numfocus.org non profit
796 donate to numfocus.org non profit
781
797
782 .. _version 790:
798 .. _version 790:
783
799
784 IPython 7.9.0
800 IPython 7.9.0
785 =============
801 =============
786
802
787 IPython 7.9 is a small release with a couple of improvement and bug fixes.
803 IPython 7.9 is a small release with a couple of improvement and bug fixes.
788
804
789 - Xterm terminal title should be restored on exit :ghpull:`11910`
805 - Xterm terminal title should be restored on exit :ghpull:`11910`
790 - special variables ``_``,``__``, ``___`` are not set anymore when cache size
806 - special variables ``_``,``__``, ``___`` are not set anymore when cache size
791 is 0 or less. :ghpull:`11877`
807 is 0 or less. :ghpull:`11877`
792 - Autoreload should have regained some speed by using a new heuristic logic to
808 - Autoreload should have regained some speed by using a new heuristic logic to
793 find all objects needing reload. This should avoid large objects traversal
809 find all objects needing reload. This should avoid large objects traversal
794 like pandas dataframes. :ghpull:`11876`
810 like pandas dataframes. :ghpull:`11876`
795 - Get ready for Python 4. :ghpull:`11874`
811 - Get ready for Python 4. :ghpull:`11874`
796 - `%env` Magic now has heuristic to hide potentially sensitive values :ghpull:`11896`
812 - `%env` Magic now has heuristic to hide potentially sensitive values :ghpull:`11896`
797
813
798 This is a small release despite a number of Pull Request Pending that need to
814 This is a small release despite a number of Pull Request Pending that need to
799 be reviewed/worked on. Many of the core developers have been busy outside of
815 be reviewed/worked on. Many of the core developers have been busy outside of
800 IPython/Jupyter and we thanks all contributor for their patience; we'll work on
816 IPython/Jupyter and we thanks all contributor for their patience; we'll work on
801 these as soon as we have time.
817 these as soon as we have time.
802
818
803
819
804 .. _version780:
820 .. _version780:
805
821
806 IPython 7.8.0
822 IPython 7.8.0
807 =============
823 =============
808
824
809 IPython 7.8.0 contain a few bugfix and 2 new APIs:
825 IPython 7.8.0 contain a few bugfix and 2 new APIs:
810
826
811 - Enable changing the font color for LaTeX rendering :ghpull:`11840`
827 - Enable changing the font color for LaTeX rendering :ghpull:`11840`
812 - and Re-Expose some PDB API (see below)
828 - and Re-Expose some PDB API (see below)
813
829
814 Expose Pdb API
830 Expose Pdb API
815 --------------
831 --------------
816
832
817 Expose the built-in ``pdb.Pdb`` API. ``Pdb`` constructor arguments are generically
833 Expose the built-in ``pdb.Pdb`` API. ``Pdb`` constructor arguments are generically
818 exposed, regardless of python version.
834 exposed, regardless of python version.
819 Newly exposed arguments:
835 Newly exposed arguments:
820
836
821 - ``skip`` - Python 3.1+
837 - ``skip`` - Python 3.1+
822 - ``nosiginnt`` - Python 3.2+
838 - ``nosiginnt`` - Python 3.2+
823 - ``readrc`` - Python 3.6+
839 - ``readrc`` - Python 3.6+
824
840
825 Try it out::
841 Try it out::
826
842
827 from IPython.terminal.debugger import TerminalPdb
843 from IPython.terminal.debugger import TerminalPdb
828 pdb = TerminalPdb(skip=["skipthismodule"])
844 pdb = TerminalPdb(skip=["skipthismodule"])
829
845
830
846
831 See :ghpull:`11840`
847 See :ghpull:`11840`
832
848
833 .. _version770:
849 .. _version770:
834
850
835 IPython 7.7.0
851 IPython 7.7.0
836 =============
852 =============
837
853
838 IPython 7.7.0 contain multiple bug fixes and documentation updates; Here are a
854 IPython 7.7.0 contain multiple bug fixes and documentation updates; Here are a
839 few of the outstanding issue fixed:
855 few of the outstanding issue fixed:
840
856
841 - Fix a bug introduced in 7.6 where the ``%matplotlib`` magic would fail on
857 - Fix a bug introduced in 7.6 where the ``%matplotlib`` magic would fail on
842 previously acceptable arguments :ghpull:`11814`.
858 previously acceptable arguments :ghpull:`11814`.
843 - Fix the manage location on freebsd :ghpull:`11808`.
859 - Fix the manage location on freebsd :ghpull:`11808`.
844 - Fix error message about aliases after ``%reset`` call in ipykernel
860 - Fix error message about aliases after ``%reset`` call in ipykernel
845 :ghpull:`11806`
861 :ghpull:`11806`
846 - Fix Duplication completions in emacs :ghpull:`11803`
862 - Fix Duplication completions in emacs :ghpull:`11803`
847
863
848 We are planning to adopt `NEP29 <https://github.com/numpy/numpy/pull/14086>`_
864 We are planning to adopt `NEP29 <https://github.com/numpy/numpy/pull/14086>`_
849 (still currently in draft) which may make this minor version of IPython the
865 (still currently in draft) which may make this minor version of IPython the
850 last one to support Python 3.5 and will make the code base more aggressive
866 last one to support Python 3.5 and will make the code base more aggressive
851 toward removing compatibility with older versions of Python.
867 toward removing compatibility with older versions of Python.
852
868
853 GitHub now support to give only "Triage" permissions to users; if you'd like to
869 GitHub now support to give only "Triage" permissions to users; if you'd like to
854 help close stale issues and labels issues please reach to us with your GitHub
870 help close stale issues and labels issues please reach to us with your GitHub
855 Username and we'll add you to the triage team. It is a great way to start
871 Username and we'll add you to the triage team. It is a great way to start
856 contributing and a path toward getting commit rights.
872 contributing and a path toward getting commit rights.
857
873
858 .. _version761:
874 .. _version761:
859
875
860 IPython 7.6.1
876 IPython 7.6.1
861 =============
877 =============
862
878
863 IPython 7.6.1 contain a critical bugfix in the ``%timeit`` magic, which would
879 IPython 7.6.1 contain a critical bugfix in the ``%timeit`` magic, which would
864 crash on some inputs as a side effect of :ghpull:`11716`. See :ghpull:`11812`
880 crash on some inputs as a side effect of :ghpull:`11716`. See :ghpull:`11812`
865
881
866
882
867 .. _whatsnew760:
883 .. _whatsnew760:
868
884
869 IPython 7.6.0
885 IPython 7.6.0
870 =============
886 =============
871
887
872 IPython 7.6.0 contains a couple of bug fixes and number of small features
888 IPython 7.6.0 contains a couple of bug fixes and number of small features
873 additions as well as some compatibility with the current development version of
889 additions as well as some compatibility with the current development version of
874 Python 3.8.
890 Python 3.8.
875
891
876 - Add a ``-l`` option to :magic:`psearch` to list the available search
892 - Add a ``-l`` option to :magic:`psearch` to list the available search
877 types. :ghpull:`11672`
893 types. :ghpull:`11672`
878 - Support ``PathLike`` for ``DisplayObject`` and ``Image``. :ghpull:`11764`
894 - Support ``PathLike`` for ``DisplayObject`` and ``Image``. :ghpull:`11764`
879 - Configurability of timeout in the test suite for slow platforms.
895 - Configurability of timeout in the test suite for slow platforms.
880 :ghpull:`11756`
896 :ghpull:`11756`
881 - Accept any casing for matplotlib backend. :ghpull:`121748`
897 - Accept any casing for matplotlib backend. :ghpull:`121748`
882 - Properly skip test that requires numpy to be installed :ghpull:`11723`
898 - Properly skip test that requires numpy to be installed :ghpull:`11723`
883 - More support for Python 3.8 and positional only arguments (pep570)
899 - More support for Python 3.8 and positional only arguments (pep570)
884 :ghpull:`11720`
900 :ghpull:`11720`
885 - Unicode names for the completion are loaded lazily on first use which
901 - Unicode names for the completion are loaded lazily on first use which
886 should decrease startup time. :ghpull:`11693`
902 should decrease startup time. :ghpull:`11693`
887 - Autoreload now update the types of reloaded objects; this for example allow
903 - Autoreload now update the types of reloaded objects; this for example allow
888 pickling of reloaded objects. :ghpull:`11644`
904 pickling of reloaded objects. :ghpull:`11644`
889 - Fix a bug where ``%%time`` magic would suppress cell output. :ghpull:`11716`
905 - Fix a bug where ``%%time`` magic would suppress cell output. :ghpull:`11716`
890
906
891
907
892 Prepare migration to pytest (instead of nose) for testing
908 Prepare migration to pytest (instead of nose) for testing
893 ---------------------------------------------------------
909 ---------------------------------------------------------
894
910
895 Most of the work between 7.5 and 7.6 was to prepare the migration from our
911 Most of the work between 7.5 and 7.6 was to prepare the migration from our
896 testing framework to pytest. Most of the test suite should now work by simply
912 testing framework to pytest. Most of the test suite should now work by simply
897 issuing ``pytest`` from the root of the repository.
913 issuing ``pytest`` from the root of the repository.
898
914
899 The migration to pytest is just at its beginning. Many of our test still rely
915 The migration to pytest is just at its beginning. Many of our test still rely
900 on IPython-specific plugins for nose using pytest (doctest using IPython syntax
916 on IPython-specific plugins for nose using pytest (doctest using IPython syntax
901 is one example of this where test appear as "passing", while no code has been
917 is one example of this where test appear as "passing", while no code has been
902 ran). Many test also need to be updated like ``yield-test`` to be properly
918 ran). Many test also need to be updated like ``yield-test`` to be properly
903 parametrized tests.
919 parametrized tests.
904
920
905 Migration to pytest allowed me to discover a number of issues in our test
921 Migration to pytest allowed me to discover a number of issues in our test
906 suite; which was hiding a number of subtle issues – or not actually running
922 suite; which was hiding a number of subtle issues – or not actually running
907 some of the tests in our test suite – I have thus corrected many of those; like
923 some of the tests in our test suite – I have thus corrected many of those; like
908 improperly closed resources; or used of deprecated features. I also made use of
924 improperly closed resources; or used of deprecated features. I also made use of
909 the ``pytest --durations=...`` to find some of our slowest test and speed them
925 the ``pytest --durations=...`` to find some of our slowest test and speed them
910 up (our test suite can now be up to 10% faster). Pytest as also a variety of
926 up (our test suite can now be up to 10% faster). Pytest as also a variety of
911 plugins and flags which will make the code quality of IPython and the testing
927 plugins and flags which will make the code quality of IPython and the testing
912 experience better.
928 experience better.
913
929
914 Misc
930 Misc
915 ----
931 ----
916
932
917 We skipped the release of 7.6 at the end of May, but will attempt to get back
933 We skipped the release of 7.6 at the end of May, but will attempt to get back
918 on schedule. We are starting to think about making introducing backward
934 on schedule. We are starting to think about making introducing backward
919 incompatible change and start the 8.0 series.
935 incompatible change and start the 8.0 series.
920
936
921 Special Thanks to Gabriel (@gpotter2 on GitHub), who among other took care many
937 Special Thanks to Gabriel (@gpotter2 on GitHub), who among other took care many
922 of the remaining task for 7.4 and 7.5, like updating the website.
938 of the remaining task for 7.4 and 7.5, like updating the website.
923
939
924 .. _whatsnew750:
940 .. _whatsnew750:
925
941
926 IPython 7.5.0
942 IPython 7.5.0
927 =============
943 =============
928
944
929 IPython 7.5.0 consist mostly of bug-fixes, and documentation updates, with one
945 IPython 7.5.0 consist mostly of bug-fixes, and documentation updates, with one
930 minor new feature. The `Audio` display element can now be assigned an element
946 minor new feature. The `Audio` display element can now be assigned an element
931 id when displayed in browser. See :ghpull:`11670`
947 id when displayed in browser. See :ghpull:`11670`
932
948
933 The major outstanding bug fix correct a change of behavior that was introduce
949 The major outstanding bug fix correct a change of behavior that was introduce
934 in 7.4.0 where some cell magics would not be able to access or modify global
950 in 7.4.0 where some cell magics would not be able to access or modify global
935 scope when using the ``@needs_local_scope`` decorator. This was typically
951 scope when using the ``@needs_local_scope`` decorator. This was typically
936 encountered with the ``%%time`` and ``%%timeit`` magics. See :ghissue:`11659`
952 encountered with the ``%%time`` and ``%%timeit`` magics. See :ghissue:`11659`
937 and :ghpull:`11698`.
953 and :ghpull:`11698`.
938
954
939 .. _whatsnew740:
955 .. _whatsnew740:
940
956
941 IPython 7.4.0
957 IPython 7.4.0
942 =============
958 =============
943
959
944 Unicode name completions
960 Unicode name completions
945 ------------------------
961 ------------------------
946
962
947 Previously, we provided completion for a unicode name with its relative symbol.
963 Previously, we provided completion for a unicode name with its relative symbol.
948 With this, now IPython provides complete suggestions to unicode name symbols.
964 With this, now IPython provides complete suggestions to unicode name symbols.
949
965
950 As on the PR, if user types ``\LAT<tab>``, IPython provides a list of
966 As on the PR, if user types ``\LAT<tab>``, IPython provides a list of
951 possible completions. In this case, it would be something like::
967 possible completions. In this case, it would be something like::
952
968
953 'LATIN CAPITAL LETTER A',
969 'LATIN CAPITAL LETTER A',
954 'LATIN CAPITAL LETTER B',
970 'LATIN CAPITAL LETTER B',
955 'LATIN CAPITAL LETTER C',
971 'LATIN CAPITAL LETTER C',
956 'LATIN CAPITAL LETTER D',
972 'LATIN CAPITAL LETTER D',
957 ....
973 ....
958
974
959 This help to type unicode character that do not have short latex aliases, and
975 This help to type unicode character that do not have short latex aliases, and
960 have long unicode names. for example ``Ν°``, ``\GREEK CAPITAL LETTER HETA``.
976 have long unicode names. for example ``Ν°``, ``\GREEK CAPITAL LETTER HETA``.
961
977
962 This feature was contributed by Luciana Marques :ghpull:`11583`.
978 This feature was contributed by Luciana Marques :ghpull:`11583`.
963
979
964 Make audio normalization optional
980 Make audio normalization optional
965 ---------------------------------
981 ---------------------------------
966
982
967 Added 'normalize' argument to `IPython.display.Audio`. This argument applies
983 Added 'normalize' argument to `IPython.display.Audio`. This argument applies
968 when audio data is given as an array of samples. The default of `normalize=True`
984 when audio data is given as an array of samples. The default of `normalize=True`
969 preserves prior behavior of normalizing the audio to the maximum possible range.
985 preserves prior behavior of normalizing the audio to the maximum possible range.
970 Setting to `False` disables normalization.
986 Setting to `False` disables normalization.
971
987
972
988
973 Miscellaneous
989 Miscellaneous
974 -------------
990 -------------
975
991
976 - Fix improper acceptation of ``return`` outside of functions. :ghpull:`11641`.
992 - Fix improper acceptation of ``return`` outside of functions. :ghpull:`11641`.
977 - Fixed PyQt 5.11 backwards incompatibility causing sip import failure.
993 - Fixed PyQt 5.11 backwards incompatibility causing sip import failure.
978 :ghpull:`11613`.
994 :ghpull:`11613`.
979 - Fix Bug where ``type?`` would crash IPython. :ghpull:`1608`.
995 - Fix Bug where ``type?`` would crash IPython. :ghpull:`1608`.
980 - Allow to apply ``@needs_local_scope`` to cell magics for convenience.
996 - Allow to apply ``@needs_local_scope`` to cell magics for convenience.
981 :ghpull:`11542`.
997 :ghpull:`11542`.
982
998
983 .. _whatsnew730:
999 .. _whatsnew730:
984
1000
985 IPython 7.3.0
1001 IPython 7.3.0
986 =============
1002 =============
987
1003
988 .. _whatsnew720:
1004 .. _whatsnew720:
989
1005
990 IPython 7.3.0 bring several bug fixes and small improvements that you will
1006 IPython 7.3.0 bring several bug fixes and small improvements that you will
991 described bellow.
1007 described bellow.
992
1008
993 The biggest change to this release is the implementation of the ``%conda`` and
1009 The biggest change to this release is the implementation of the ``%conda`` and
994 ``%pip`` magics, that will attempt to install packages in the **current
1010 ``%pip`` magics, that will attempt to install packages in the **current
995 environment**. You may still need to restart your interpreter or kernel for the
1011 environment**. You may still need to restart your interpreter or kernel for the
996 change to be taken into account, but it should simplify installation of packages
1012 change to be taken into account, but it should simplify installation of packages
997 into remote environment. Installing using pip/conda from the command line is
1013 into remote environment. Installing using pip/conda from the command line is
998 still the prefer method.
1014 still the prefer method.
999
1015
1000 The ``%pip`` magic was already present, but was only printing a warning; now it
1016 The ``%pip`` magic was already present, but was only printing a warning; now it
1001 will actually forward commands to pip.
1017 will actually forward commands to pip.
1002
1018
1003 Misc bug fixes and improvements:
1019 Misc bug fixes and improvements:
1004
1020
1005 - Compatibility with Python 3.8.
1021 - Compatibility with Python 3.8.
1006 - Do not expand shell variable in execution magics, and added the
1022 - Do not expand shell variable in execution magics, and added the
1007 ``no_var_expand`` decorator for magic requiring a similar functionality
1023 ``no_var_expand`` decorator for magic requiring a similar functionality
1008 :ghpull:`11516`
1024 :ghpull:`11516`
1009 - Add ``%pip`` and ``%conda`` magic :ghpull:`11524`
1025 - Add ``%pip`` and ``%conda`` magic :ghpull:`11524`
1010 - Re-initialize posix aliases after a ``%reset`` :ghpull:`11528`
1026 - Re-initialize posix aliases after a ``%reset`` :ghpull:`11528`
1011 - Allow the IPython command line to run ``*.ipynb`` files :ghpull:`11529`
1027 - Allow the IPython command line to run ``*.ipynb`` files :ghpull:`11529`
1012
1028
1013 IPython 7.2.0
1029 IPython 7.2.0
1014 =============
1030 =============
1015
1031
1016 IPython 7.2.0 brings minor bugfixes, improvements, and new configuration options:
1032 IPython 7.2.0 brings minor bugfixes, improvements, and new configuration options:
1017
1033
1018 - Fix a bug preventing PySide2 GUI integration from working :ghpull:`11464`
1034 - Fix a bug preventing PySide2 GUI integration from working :ghpull:`11464`
1019 - Run CI on Mac OS ! :ghpull:`11471`
1035 - Run CI on Mac OS ! :ghpull:`11471`
1020 - Fix IPython "Demo" mode. :ghpull:`11498`
1036 - Fix IPython "Demo" mode. :ghpull:`11498`
1021 - Fix ``%run`` magic with path in name :ghpull:`11499`
1037 - Fix ``%run`` magic with path in name :ghpull:`11499`
1022 - Fix: add CWD to sys.path *after* stdlib :ghpull:`11502`
1038 - Fix: add CWD to sys.path *after* stdlib :ghpull:`11502`
1023 - Better rendering of signatures, especially long ones. :ghpull:`11505`
1039 - Better rendering of signatures, especially long ones. :ghpull:`11505`
1024 - Re-enable jedi by default if it's installed :ghpull:`11506`
1040 - Re-enable jedi by default if it's installed :ghpull:`11506`
1025 - Add New ``minimal`` exception reporting mode (useful for educational purpose). See :ghpull:`11509`
1041 - Add New ``minimal`` exception reporting mode (useful for educational purpose). See :ghpull:`11509`
1026
1042
1027
1043
1028 Added ability to show subclasses when using pinfo and other utilities
1044 Added ability to show subclasses when using pinfo and other utilities
1029 ---------------------------------------------------------------------
1045 ---------------------------------------------------------------------
1030
1046
1031 When using ``?``/``??`` on a class, IPython will now list the first 10 subclasses.
1047 When using ``?``/``??`` on a class, IPython will now list the first 10 subclasses.
1032
1048
1033 Special Thanks to Chris Mentzel of the Moore Foundation for this feature. Chris
1049 Special Thanks to Chris Mentzel of the Moore Foundation for this feature. Chris
1034 is one of the people who played a critical role in IPython/Jupyter getting
1050 is one of the people who played a critical role in IPython/Jupyter getting
1035 funding.
1051 funding.
1036
1052
1037 We are grateful for all the help Chris has given us over the years,
1053 We are grateful for all the help Chris has given us over the years,
1038 and we're now proud to have code contributed by Chris in IPython.
1054 and we're now proud to have code contributed by Chris in IPython.
1039
1055
1040 OSMagics.cd_force_quiet configuration option
1056 OSMagics.cd_force_quiet configuration option
1041 --------------------------------------------
1057 --------------------------------------------
1042
1058
1043 You can set this option to force the %cd magic to behave as if ``-q`` was passed:
1059 You can set this option to force the %cd magic to behave as if ``-q`` was passed:
1044 ::
1060 ::
1045
1061
1046 In [1]: cd /
1062 In [1]: cd /
1047 /
1063 /
1048
1064
1049 In [2]: %config OSMagics.cd_force_quiet = True
1065 In [2]: %config OSMagics.cd_force_quiet = True
1050
1066
1051 In [3]: cd /tmp
1067 In [3]: cd /tmp
1052
1068
1053 In [4]:
1069 In [4]:
1054
1070
1055 See :ghpull:`11491`
1071 See :ghpull:`11491`
1056
1072
1057 In vi editing mode, whether the prompt includes the current vi mode can now be configured
1073 In vi editing mode, whether the prompt includes the current vi mode can now be configured
1058 -----------------------------------------------------------------------------------------
1074 -----------------------------------------------------------------------------------------
1059
1075
1060 Set the ``TerminalInteractiveShell.prompt_includes_vi_mode`` to a boolean value
1076 Set the ``TerminalInteractiveShell.prompt_includes_vi_mode`` to a boolean value
1061 (default: True) to control this feature. See :ghpull:`11492`
1077 (default: True) to control this feature. See :ghpull:`11492`
1062
1078
1063 .. _whatsnew710:
1079 .. _whatsnew710:
1064
1080
1065 IPython 7.1.0
1081 IPython 7.1.0
1066 =============
1082 =============
1067
1083
1068 IPython 7.1.0 is the first minor release after 7.0.0 and mostly brings fixes to
1084 IPython 7.1.0 is the first minor release after 7.0.0 and mostly brings fixes to
1069 new features, internal refactoring, and fixes for regressions that happened during the 6.x->7.x
1085 new features, internal refactoring, and fixes for regressions that happened during the 6.x->7.x
1070 transition. It also brings **Compatibility with Python 3.7.1**, as we're
1086 transition. It also brings **Compatibility with Python 3.7.1**, as we're
1071 unwillingly relying on a bug in CPython.
1087 unwillingly relying on a bug in CPython.
1072
1088
1073 New Core Dev:
1089 New Core Dev:
1074
1090
1075 - We welcome Jonathan Slenders to the commiters. Jonathan has done a fantastic
1091 - We welcome Jonathan Slenders to the commiters. Jonathan has done a fantastic
1076 work on prompt_toolkit, and we'd like to recognise his impact by giving him
1092 work on prompt_toolkit, and we'd like to recognise his impact by giving him
1077 commit rights. :ghissue:`11397`
1093 commit rights. :ghissue:`11397`
1078
1094
1079 Notable Changes
1095 Notable Changes
1080
1096
1081 - Major update of "latex to unicode" tab completion map (see below)
1097 - Major update of "latex to unicode" tab completion map (see below)
1082
1098
1083 Notable New Features:
1099 Notable New Features:
1084
1100
1085 - Restore functionality and documentation of the **sphinx directive**, which
1101 - Restore functionality and documentation of the **sphinx directive**, which
1086 is now stricter (fail on error by daefault), has new configuration options,
1102 is now stricter (fail on error by daefault), has new configuration options,
1087 has a brand new documentation page :ref:`ipython_directive` (which needs
1103 has a brand new documentation page :ref:`ipython_directive` (which needs
1088 some cleanup). It is also now *tested* so we hope to have less regressions.
1104 some cleanup). It is also now *tested* so we hope to have less regressions.
1089 :ghpull:`11402`
1105 :ghpull:`11402`
1090
1106
1091 - ``IPython.display.Video`` now supports ``width`` and ``height`` arguments,
1107 - ``IPython.display.Video`` now supports ``width`` and ``height`` arguments,
1092 allowing a custom width and height to be set instead of using the video's
1108 allowing a custom width and height to be set instead of using the video's
1093 width and height. :ghpull:`11353`
1109 width and height. :ghpull:`11353`
1094
1110
1095 - Warn when using ``HTML('<iframe>')`` instead of ``IFrame`` :ghpull:`11350`
1111 - Warn when using ``HTML('<iframe>')`` instead of ``IFrame`` :ghpull:`11350`
1096
1112
1097 - Allow Dynamic switching of editing mode between vi/emacs and show
1113 - Allow Dynamic switching of editing mode between vi/emacs and show
1098 normal/input mode in prompt when using vi. :ghpull:`11390`. Use ``%config
1114 normal/input mode in prompt when using vi. :ghpull:`11390`. Use ``%config
1099 TerminalInteractiveShell.editing_mode = 'vi'`` or ``%config
1115 TerminalInteractiveShell.editing_mode = 'vi'`` or ``%config
1100 TerminalInteractiveShell.editing_mode = 'emacs'`` to dynamically switch
1116 TerminalInteractiveShell.editing_mode = 'emacs'`` to dynamically switch
1101 between modes.
1117 between modes.
1102
1118
1103
1119
1104 Notable Fixes:
1120 Notable Fixes:
1105
1121
1106 - Fix entering of **multi-line blocks in terminal** IPython, and various
1122 - Fix entering of **multi-line blocks in terminal** IPython, and various
1107 crashes in the new input transformation machinery :ghpull:`11354`,
1123 crashes in the new input transformation machinery :ghpull:`11354`,
1108 :ghpull:`11356`, :ghpull:`11358`. These also fix a **Compatibility bug
1124 :ghpull:`11356`, :ghpull:`11358`. These also fix a **Compatibility bug
1109 with Python 3.7.1**.
1125 with Python 3.7.1**.
1110
1126
1111 - Fix moving through generator stack in ipdb :ghpull:`11266`
1127 - Fix moving through generator stack in ipdb :ghpull:`11266`
1112
1128
1113 - %Magic command arguments now support quoting. :ghpull:`11330`
1129 - %Magic command arguments now support quoting. :ghpull:`11330`
1114
1130
1115 - Re-add ``rprint`` and ``rprinte`` aliases. :ghpull:`11331`
1131 - Re-add ``rprint`` and ``rprinte`` aliases. :ghpull:`11331`
1116
1132
1117 - Remove implicit dependency on ``ipython_genutils`` :ghpull:`11317`
1133 - Remove implicit dependency on ``ipython_genutils`` :ghpull:`11317`
1118
1134
1119 - Make ``nonlocal`` raise ``SyntaxError`` instead of silently failing in async
1135 - Make ``nonlocal`` raise ``SyntaxError`` instead of silently failing in async
1120 mode. :ghpull:`11382`
1136 mode. :ghpull:`11382`
1121
1137
1122 - Fix mishandling of magics and ``= !`` assignment just after a dedent in
1138 - Fix mishandling of magics and ``= !`` assignment just after a dedent in
1123 nested code blocks :ghpull:`11418`
1139 nested code blocks :ghpull:`11418`
1124
1140
1125 - Fix instructions for custom shortcuts :ghpull:`11426`
1141 - Fix instructions for custom shortcuts :ghpull:`11426`
1126
1142
1127
1143
1128 Notable Internals improvements:
1144 Notable Internals improvements:
1129
1145
1130 - Use of ``os.scandir`` (Python 3 only) to speed up some file system operations.
1146 - Use of ``os.scandir`` (Python 3 only) to speed up some file system operations.
1131 :ghpull:`11365`
1147 :ghpull:`11365`
1132
1148
1133 - use ``perf_counter`` instead of ``clock`` for more precise
1149 - use ``perf_counter`` instead of ``clock`` for more precise
1134 timing results with ``%time`` :ghpull:`11376`
1150 timing results with ``%time`` :ghpull:`11376`
1135
1151
1136 Many thanks to all the contributors and in particular to ``bartskowron`` and
1152 Many thanks to all the contributors and in particular to ``bartskowron`` and
1137 ``tonyfast`` who handled some pretty complicated bugs in the input machinery. We
1153 ``tonyfast`` who handled some pretty complicated bugs in the input machinery. We
1138 had a number of first time contributors and maybe hacktoberfest participants that
1154 had a number of first time contributors and maybe hacktoberfest participants that
1139 made significant contributions and helped us free some time to focus on more
1155 made significant contributions and helped us free some time to focus on more
1140 complicated bugs.
1156 complicated bugs.
1141
1157
1142 You
1158 You
1143 can see all the closed issues and Merged PR, new features and fixes `here
1159 can see all the closed issues and Merged PR, new features and fixes `here
1144 <https://github.com/ipython/ipython/issues?utf8=%E2%9C%93&q=+is%3Aclosed+milestone%3A7.1+>`_.
1160 <https://github.com/ipython/ipython/issues?utf8=%E2%9C%93&q=+is%3Aclosed+milestone%3A7.1+>`_.
1145
1161
1146 Unicode Completion update
1162 Unicode Completion update
1147 -------------------------
1163 -------------------------
1148
1164
1149 In IPython 7.1 the Unicode completion map has been updated and synchronized with
1165 In IPython 7.1 the Unicode completion map has been updated and synchronized with
1150 the Julia language.
1166 the Julia language.
1151
1167
1152 Added and removed character characters:
1168 Added and removed character characters:
1153
1169
1154 ``\jmath`` (``Θ·``), ``\\underleftrightarrow`` (U+034D, combining) have been
1170 ``\jmath`` (``Θ·``), ``\\underleftrightarrow`` (U+034D, combining) have been
1155 added, while ``\\textasciicaron`` have been removed
1171 added, while ``\\textasciicaron`` have been removed
1156
1172
1157 Some sequences have seen their prefix removed:
1173 Some sequences have seen their prefix removed:
1158
1174
1159 - 6 characters ``\text...<tab>`` should now be inputed with ``\...<tab>`` directly,
1175 - 6 characters ``\text...<tab>`` should now be inputed with ``\...<tab>`` directly,
1160 - 45 characters ``\Elz...<tab>`` should now be inputed with ``\...<tab>`` directly,
1176 - 45 characters ``\Elz...<tab>`` should now be inputed with ``\...<tab>`` directly,
1161 - 65 characters ``\B...<tab>`` should now be inputed with ``\...<tab>`` directly,
1177 - 65 characters ``\B...<tab>`` should now be inputed with ``\...<tab>`` directly,
1162 - 450 characters ``\m...<tab>`` should now be inputed with ``\...<tab>`` directly,
1178 - 450 characters ``\m...<tab>`` should now be inputed with ``\...<tab>`` directly,
1163
1179
1164 Some sequences have seen their prefix shortened:
1180 Some sequences have seen their prefix shortened:
1165
1181
1166 - 5 characters ``\mitBbb...<tab>`` should now be inputed with ``\bbi...<tab>`` directly,
1182 - 5 characters ``\mitBbb...<tab>`` should now be inputed with ``\bbi...<tab>`` directly,
1167 - 52 characters ``\mit...<tab>`` should now be inputed with ``\i...<tab>`` directly,
1183 - 52 characters ``\mit...<tab>`` should now be inputed with ``\i...<tab>`` directly,
1168 - 216 characters ``\mbfit...<tab>`` should now be inputed with ``\bi...<tab>`` directly,
1184 - 216 characters ``\mbfit...<tab>`` should now be inputed with ``\bi...<tab>`` directly,
1169 - 222 characters ``\mbf...<tab>`` should now be inputed with ``\b...<tab>`` directly,
1185 - 222 characters ``\mbf...<tab>`` should now be inputed with ``\b...<tab>`` directly,
1170
1186
1171 A couple of characters had their sequence simplified:
1187 A couple of characters had their sequence simplified:
1172
1188
1173 - ``Γ°``, type ``\dh<tab>``, instead of ``\eth<tab>``
1189 - ``Γ°``, type ``\dh<tab>``, instead of ``\eth<tab>``
1174 - ``Δ§``, type ``\hbar<tab>``, instead of ``\Elzxh<tab>``
1190 - ``Δ§``, type ``\hbar<tab>``, instead of ``\Elzxh<tab>``
1175 - ``ΙΈ``, type ``\ltphi<tab>``, instead of ``\textphi<tab>``
1191 - ``ΙΈ``, type ``\ltphi<tab>``, instead of ``\textphi<tab>``
1176 - ``Ο΄``, type ``\varTheta<tab>``, instead of ``\textTheta<tab>``
1192 - ``Ο΄``, type ``\varTheta<tab>``, instead of ``\textTheta<tab>``
1177 - ``ℇ``, type ``\eulermascheroni<tab>``, instead of ``\Eulerconst<tab>``
1193 - ``ℇ``, type ``\eulermascheroni<tab>``, instead of ``\Eulerconst<tab>``
1178 - ``β„Ž``, type ``\planck<tab>``, instead of ``\Planckconst<tab>``
1194 - ``β„Ž``, type ``\planck<tab>``, instead of ``\Planckconst<tab>``
1179
1195
1180 - U+0336 (COMBINING LONG STROKE OVERLAY), type ``\strike<tab>``, instead of ``\Elzbar<tab>``.
1196 - U+0336 (COMBINING LONG STROKE OVERLAY), type ``\strike<tab>``, instead of ``\Elzbar<tab>``.
1181
1197
1182 A couple of sequences have been updated:
1198 A couple of sequences have been updated:
1183
1199
1184 - ``\varepsilon`` now gives ``Ι›`` (GREEK SMALL LETTER EPSILON) instead of ``Ξ΅`` (GREEK LUNATE EPSILON SYMBOL),
1200 - ``\varepsilon`` now gives ``Ι›`` (GREEK SMALL LETTER EPSILON) instead of ``Ξ΅`` (GREEK LUNATE EPSILON SYMBOL),
1185 - ``\underbar`` now gives U+0331 (COMBINING MACRON BELOW) instead of U+0332 (COMBINING LOW LINE).
1201 - ``\underbar`` now gives U+0331 (COMBINING MACRON BELOW) instead of U+0332 (COMBINING LOW LINE).
1186
1202
1187
1203
1188 .. _whatsnew700:
1204 .. _whatsnew700:
1189
1205
1190 IPython 7.0.0
1206 IPython 7.0.0
1191 =============
1207 =============
1192
1208
1193 Released Thursday September 27th, 2018
1209 Released Thursday September 27th, 2018
1194
1210
1195 IPython 7 includes major feature improvements.
1211 IPython 7 includes major feature improvements.
1196 This is also the second major version of IPython to support only
1212 This is also the second major version of IPython to support only
1197 Python 3 – starting at Python 3.4. Python 2 is still community-supported
1213 Python 3 – starting at Python 3.4. Python 2 is still community-supported
1198 on the bugfix only 5.x branch, but we remind you that Python 2 "end of life"
1214 on the bugfix only 5.x branch, but we remind you that Python 2 "end of life"
1199 is on Jan 1st 2020.
1215 is on Jan 1st 2020.
1200
1216
1201 We were able to backport bug fixes to the 5.x branch thanks to our backport bot which
1217 We were able to backport bug fixes to the 5.x branch thanks to our backport bot which
1202 backported more than `70 Pull-Requests
1218 backported more than `70 Pull-Requests
1203 <https://github.com/ipython/ipython/pulls?page=3&q=is%3Apr+sort%3Aupdated-desc+author%3Aapp%2Fmeeseeksdev++5.x&utf8=%E2%9C%93>`_, but there are still many PRs that required manual work. This is an area of the project where you can easily contribute by looking for `PRs that still need manual backport <https://github.com/ipython/ipython/issues?q=label%3A%22Still+Needs+Manual+Backport%22+is%3Aclosed+sort%3Aupdated-desc>`_
1219 <https://github.com/ipython/ipython/pulls?page=3&q=is%3Apr+sort%3Aupdated-desc+author%3Aapp%2Fmeeseeksdev++5.x&utf8=%E2%9C%93>`_, but there are still many PRs that required manual work. This is an area of the project where you can easily contribute by looking for `PRs that still need manual backport <https://github.com/ipython/ipython/issues?q=label%3A%22Still+Needs+Manual+Backport%22+is%3Aclosed+sort%3Aupdated-desc>`_
1204
1220
1205 The IPython 6.x branch will likely not see any further release unless critical
1221 The IPython 6.x branch will likely not see any further release unless critical
1206 bugs are found.
1222 bugs are found.
1207
1223
1208 Make sure you have pip > 9.0 before upgrading. You should be able to update by running:
1224 Make sure you have pip > 9.0 before upgrading. You should be able to update by running:
1209
1225
1210 .. code::
1226 .. code::
1211
1227
1212 pip install ipython --upgrade
1228 pip install ipython --upgrade
1213
1229
1214 .. only:: ipydev
1230 .. only:: ipydev
1215
1231
1216 If you are trying to install or update an ``alpha``, ``beta``, or ``rc``
1232 If you are trying to install or update an ``alpha``, ``beta``, or ``rc``
1217 version, use pip ``--pre`` flag.
1233 version, use pip ``--pre`` flag.
1218
1234
1219 .. code::
1235 .. code::
1220
1236
1221 pip install ipython --upgrade --pre
1237 pip install ipython --upgrade --pre
1222
1238
1223
1239
1224 Or, if you have conda installed:
1240 Or, if you have conda installed:
1225
1241
1226 .. code::
1242 .. code::
1227
1243
1228 conda install ipython
1244 conda install ipython
1229
1245
1230
1246
1231
1247
1232 Prompt Toolkit 2.0
1248 Prompt Toolkit 2.0
1233 ------------------
1249 ------------------
1234
1250
1235 IPython 7.0+ now uses ``prompt_toolkit 2.0``. If you still need to use an earlier
1251 IPython 7.0+ now uses ``prompt_toolkit 2.0``. If you still need to use an earlier
1236 ``prompt_toolkit`` version, you may need to pin IPython to ``<7.0``.
1252 ``prompt_toolkit`` version, you may need to pin IPython to ``<7.0``.
1237
1253
1238 Autowait: Asynchronous REPL
1254 Autowait: Asynchronous REPL
1239 ---------------------------
1255 ---------------------------
1240
1256
1241 Staring with IPython 7.0 on Python 3.6+, IPython can automatically ``await``
1257 Staring with IPython 7.0 on Python 3.6+, IPython can automatically ``await``
1242 top level code. You should not need to access an event loop or runner
1258 top level code. You should not need to access an event loop or runner
1243 yourself. To learn more, read the :ref:`autoawait` section of our docs, see
1259 yourself. To learn more, read the :ref:`autoawait` section of our docs, see
1244 :ghpull:`11265`, or try the following code::
1260 :ghpull:`11265`, or try the following code::
1245
1261
1246 Python 3.6.0
1262 Python 3.6.0
1247 Type 'copyright', 'credits' or 'license' for more information
1263 Type 'copyright', 'credits' or 'license' for more information
1248 IPython 7.0.0 -- An enhanced Interactive Python. Type '?' for help.
1264 IPython 7.0.0 -- An enhanced Interactive Python. Type '?' for help.
1249
1265
1250 In [1]: import aiohttp
1266 In [1]: import aiohttp
1251 ...: result = aiohttp.get('https://api.github.com')
1267 ...: result = aiohttp.get('https://api.github.com')
1252
1268
1253 In [2]: response = await result
1269 In [2]: response = await result
1254 <pause for a few 100s ms>
1270 <pause for a few 100s ms>
1255
1271
1256 In [3]: await response.json()
1272 In [3]: await response.json()
1257 Out[3]:
1273 Out[3]:
1258 {'authorizations_url': 'https://api.github.com/authorizations',
1274 {'authorizations_url': 'https://api.github.com/authorizations',
1259 'code_search_url': 'https://api.github.com/search/code?q={query}{&page,per_page,sort,order}',
1275 'code_search_url': 'https://api.github.com/search/code?q={query}{&page,per_page,sort,order}',
1260 ...
1276 ...
1261 }
1277 }
1262
1278
1263 .. note::
1279 .. note::
1264
1280
1265 Async integration is experimental code, behavior may change or be removed
1281 Async integration is experimental code, behavior may change or be removed
1266 between Python and IPython versions without warnings.
1282 between Python and IPython versions without warnings.
1267
1283
1268 Integration is by default with `asyncio`, but other libraries can be configured --
1284 Integration is by default with `asyncio`, but other libraries can be configured --
1269 like ``curio`` or ``trio`` -- to improve concurrency in the REPL::
1285 like ``curio`` or ``trio`` -- to improve concurrency in the REPL::
1270
1286
1271 In [1]: %autoawait trio
1287 In [1]: %autoawait trio
1272
1288
1273 In [2]: import trio
1289 In [2]: import trio
1274
1290
1275 In [3]: async def child(i):
1291 In [3]: async def child(i):
1276 ...: print(" child %s goes to sleep"%i)
1292 ...: print(" child %s goes to sleep"%i)
1277 ...: await trio.sleep(2)
1293 ...: await trio.sleep(2)
1278 ...: print(" child %s wakes up"%i)
1294 ...: print(" child %s wakes up"%i)
1279
1295
1280 In [4]: print('parent start')
1296 In [4]: print('parent start')
1281 ...: async with trio.open_nursery() as n:
1297 ...: async with trio.open_nursery() as n:
1282 ...: for i in range(3):
1298 ...: for i in range(3):
1283 ...: n.spawn(child, i)
1299 ...: n.spawn(child, i)
1284 ...: print('parent end')
1300 ...: print('parent end')
1285 parent start
1301 parent start
1286 child 2 goes to sleep
1302 child 2 goes to sleep
1287 child 0 goes to sleep
1303 child 0 goes to sleep
1288 child 1 goes to sleep
1304 child 1 goes to sleep
1289 <about 2 seconds pause>
1305 <about 2 seconds pause>
1290 child 2 wakes up
1306 child 2 wakes up
1291 child 1 wakes up
1307 child 1 wakes up
1292 child 0 wakes up
1308 child 0 wakes up
1293 parent end
1309 parent end
1294
1310
1295 See :ref:`autoawait` for more information.
1311 See :ref:`autoawait` for more information.
1296
1312
1297
1313
1298 Asynchronous code in a Notebook interface or any other frontend using the
1314 Asynchronous code in a Notebook interface or any other frontend using the
1299 Jupyter Protocol will require further updates to the IPykernel package.
1315 Jupyter Protocol will require further updates to the IPykernel package.
1300
1316
1301 Non-Asynchronous code
1317 Non-Asynchronous code
1302 ~~~~~~~~~~~~~~~~~~~~~
1318 ~~~~~~~~~~~~~~~~~~~~~
1303
1319
1304 As the internal API of IPython is now asynchronous, IPython needs to run under
1320 As the internal API of IPython is now asynchronous, IPython needs to run under
1305 an event loop. In order to allow many workflows, (like using the :magic:`%run`
1321 an event loop. In order to allow many workflows, (like using the :magic:`%run`
1306 magic, or copy-pasting code that explicitly starts/stop event loop), when
1322 magic, or copy-pasting code that explicitly starts/stop event loop), when
1307 top-level code is detected as not being asynchronous, IPython code is advanced
1323 top-level code is detected as not being asynchronous, IPython code is advanced
1308 via a pseudo-synchronous runner, and may not advance pending tasks.
1324 via a pseudo-synchronous runner, and may not advance pending tasks.
1309
1325
1310 Change to Nested Embed
1326 Change to Nested Embed
1311 ~~~~~~~~~~~~~~~~~~~~~~
1327 ~~~~~~~~~~~~~~~~~~~~~~
1312
1328
1313 The introduction of the ability to run async code had some effect on the
1329 The introduction of the ability to run async code had some effect on the
1314 ``IPython.embed()`` API. By default, embed will not allow you to run asynchronous
1330 ``IPython.embed()`` API. By default, embed will not allow you to run asynchronous
1315 code unless an event loop is specified.
1331 code unless an event loop is specified.
1316
1332
1317 Effects on Magics
1333 Effects on Magics
1318 ~~~~~~~~~~~~~~~~~
1334 ~~~~~~~~~~~~~~~~~
1319
1335
1320 Some magics will not work with async until they're updated.
1336 Some magics will not work with async until they're updated.
1321 Contributions welcome.
1337 Contributions welcome.
1322
1338
1323 Expected Future changes
1339 Expected Future changes
1324 ~~~~~~~~~~~~~~~~~~~~~~~
1340 ~~~~~~~~~~~~~~~~~~~~~~~
1325
1341
1326 We expect more internal but public IPython functions to become ``async``, and
1342 We expect more internal but public IPython functions to become ``async``, and
1327 will likely end up having a persistent event loop while IPython is running.
1343 will likely end up having a persistent event loop while IPython is running.
1328
1344
1329 Thanks
1345 Thanks
1330 ~~~~~~
1346 ~~~~~~
1331
1347
1332 This release took more than a year in the making.
1348 This release took more than a year in the making.
1333 The code was rebased a number of
1349 The code was rebased a number of
1334 times; leading to commit authorship that may have been lost in the final
1350 times; leading to commit authorship that may have been lost in the final
1335 Pull-Request. Huge thanks to many people for contribution, discussion, code,
1351 Pull-Request. Huge thanks to many people for contribution, discussion, code,
1336 documentation, use-cases: dalejung, danielballan, ellisonbg, fperez, gnestor,
1352 documentation, use-cases: dalejung, danielballan, ellisonbg, fperez, gnestor,
1337 minrk, njsmith, pganssle, tacaswell, takluyver , vidartf ... And many others.
1353 minrk, njsmith, pganssle, tacaswell, takluyver , vidartf ... And many others.
1338
1354
1339
1355
1340 Autoreload Improvement
1356 Autoreload Improvement
1341 ----------------------
1357 ----------------------
1342
1358
1343 The magic :magic:`%autoreload 2 <autoreload>` now captures new methods added to
1359 The magic :magic:`%autoreload 2 <autoreload>` now captures new methods added to
1344 classes. Earlier, only methods existing as of the initial import were being
1360 classes. Earlier, only methods existing as of the initial import were being
1345 tracked and updated.
1361 tracked and updated.
1346
1362
1347 This new feature helps dual environment development - Jupyter+IDE - where the
1363 This new feature helps dual environment development - Jupyter+IDE - where the
1348 code gradually moves from notebook cells to package files as it gets
1364 code gradually moves from notebook cells to package files as it gets
1349 structured.
1365 structured.
1350
1366
1351 **Example**: An instance of the class ``MyClass`` will be able to access the
1367 **Example**: An instance of the class ``MyClass`` will be able to access the
1352 method ``cube()`` after it is uncommented and the file ``file1.py`` is saved on
1368 method ``cube()`` after it is uncommented and the file ``file1.py`` is saved on
1353 disk.
1369 disk.
1354
1370
1355
1371
1356 .. code::
1372 .. code::
1357
1373
1358 # notebook
1374 # notebook
1359
1375
1360 from mymodule import MyClass
1376 from mymodule import MyClass
1361 first = MyClass(5)
1377 first = MyClass(5)
1362
1378
1363 .. code::
1379 .. code::
1364
1380
1365 # mymodule/file1.py
1381 # mymodule/file1.py
1366
1382
1367 class MyClass:
1383 class MyClass:
1368
1384
1369 def __init__(self, a=10):
1385 def __init__(self, a=10):
1370 self.a = a
1386 self.a = a
1371
1387
1372 def square(self):
1388 def square(self):
1373 print('compute square')
1389 print('compute square')
1374 return self.a*self.a
1390 return self.a*self.a
1375
1391
1376 # def cube(self):
1392 # def cube(self):
1377 # print('compute cube')
1393 # print('compute cube')
1378 # return self.a*self.a*self.a
1394 # return self.a*self.a*self.a
1379
1395
1380
1396
1381
1397
1382
1398
1383 Misc
1399 Misc
1384 ----
1400 ----
1385
1401
1386 The autoindent feature that was deprecated in 5.x was re-enabled and
1402 The autoindent feature that was deprecated in 5.x was re-enabled and
1387 un-deprecated in :ghpull:`11257`
1403 un-deprecated in :ghpull:`11257`
1388
1404
1389 Make :magic:`%run -n -i ... <run>` work correctly. Earlier, if :magic:`%run` was
1405 Make :magic:`%run -n -i ... <run>` work correctly. Earlier, if :magic:`%run` was
1390 passed both arguments, ``-n`` would be silently ignored. See :ghpull:`10308`
1406 passed both arguments, ``-n`` would be silently ignored. See :ghpull:`10308`
1391
1407
1392
1408
1393 The :cellmagic:`%%script` (as well as :cellmagic:`%%bash`,
1409 The :cellmagic:`%%script` (as well as :cellmagic:`%%bash`,
1394 :cellmagic:`%%ruby`... ) cell magics now raise by default if the return code of
1410 :cellmagic:`%%ruby`... ) cell magics now raise by default if the return code of
1395 the given code is non-zero (thus halting execution of further cells in a
1411 the given code is non-zero (thus halting execution of further cells in a
1396 notebook). The behavior can be disable by passing the ``--no-raise-error`` flag.
1412 notebook). The behavior can be disable by passing the ``--no-raise-error`` flag.
1397
1413
1398
1414
1399 Deprecations
1415 Deprecations
1400 ------------
1416 ------------
1401
1417
1402 A couple of unused functions and methods have been deprecated and will be removed
1418 A couple of unused functions and methods have been deprecated and will be removed
1403 in future versions:
1419 in future versions:
1404
1420
1405 - ``IPython.utils.io.raw_print_err``
1421 - ``IPython.utils.io.raw_print_err``
1406 - ``IPython.utils.io.raw_print``
1422 - ``IPython.utils.io.raw_print``
1407
1423
1408
1424
1409 Backwards incompatible changes
1425 Backwards incompatible changes
1410 ------------------------------
1426 ------------------------------
1411
1427
1412 * The API for transforming input before it is parsed as Python code has been
1428 * The API for transforming input before it is parsed as Python code has been
1413 completely redesigned: any custom input transformations will need to be
1429 completely redesigned: any custom input transformations will need to be
1414 rewritten. See :doc:`/config/inputtransforms` for details of the new API.
1430 rewritten. See :doc:`/config/inputtransforms` for details of the new API.
General Comments 0
You need to be logged in to leave comments. Login now