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