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