• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. _debugger:
2
3:mod:`pdb` --- The Python Debugger
4==================================
5
6.. module:: pdb
7   :synopsis: The Python debugger for interactive interpreters.
8
9**Source code:** :source:`Lib/pdb.py`
10
11.. index:: single: debugging
12
13--------------
14
15The module :mod:`pdb` defines an interactive source code debugger for Python
16programs.  It supports setting (conditional) breakpoints and single stepping at
17the source line level, inspection of stack frames, source code listing, and
18evaluation of arbitrary Python code in the context of any stack frame.  It also
19supports post-mortem debugging and can be called under program control.
20
21.. index::
22   single: Pdb (class in pdb)
23   pair: module; bdb
24   pair: module; cmd
25
26The debugger is extensible -- it is actually defined as the class :class:`Pdb`.
27This is currently undocumented but easily understood by reading the source.  The
28extension interface uses the modules :mod:`bdb` and :mod:`cmd`.
29
30.. seealso::
31
32   Module :mod:`faulthandler`
33      Used to dump Python tracebacks explicitly, on a fault, after a timeout,
34      or on a user signal.
35
36   Module :mod:`traceback`
37      Standard interface to extract, format and print stack traces of Python programs.
38
39The typical usage to break into the debugger is to insert::
40
41   import pdb; pdb.set_trace()
42
43Or::
44
45   breakpoint()
46
47at the location you want to break into the debugger, and then run the program.
48You can then step through the code following this statement, and continue
49running without the debugger using the :pdbcmd:`continue` command.
50
51.. versionchanged:: 3.7
52   The built-in :func:`breakpoint`, when called with defaults, can be used
53   instead of ``import pdb; pdb.set_trace()``.
54
55::
56
57   def double(x):
58      breakpoint()
59      return x * 2
60   val = 3
61   print(f"{val} * 2 is {double(val)}")
62
63The debugger's prompt is ``(Pdb)``, which is the indicator that you are in debug mode::
64
65   > ...(2)double()
66   -> breakpoint()
67   (Pdb) p x
68   3
69   (Pdb) continue
70   3 * 2 is 6
71
72.. versionchanged:: 3.3
73   Tab-completion via the :mod:`readline` module is available for commands and
74   command arguments, e.g. the current global and local names are offered as
75   arguments of the ``p`` command.
76
77
78You can also invoke :mod:`pdb` from the command line to debug other scripts.  For
79example::
80
81   python -m pdb myscript.py
82
83When invoked as a module, pdb will automatically enter post-mortem debugging if
84the program being debugged exits abnormally.  After post-mortem debugging (or
85after normal exit of the program), pdb will restart the program.  Automatic
86restarting preserves pdb's state (such as breakpoints) and in most cases is more
87useful than quitting the debugger upon program's exit.
88
89.. versionchanged:: 3.2
90   Added the ``-c`` option to execute commands as if given
91   in a :file:`.pdbrc` file; see :ref:`debugger-commands`.
92
93.. versionchanged:: 3.7
94   Added the ``-m`` option to execute modules similar to the way
95   ``python -m`` does. As with a script, the debugger will pause execution just
96   before the first line of the module.
97
98Typical usage to execute a statement under control of the debugger is::
99
100   >>> import pdb
101   >>> def f(x):
102   ...     print(1 / x)
103   >>> pdb.run("f(2)")
104   > <string>(1)<module>()
105   (Pdb) continue
106   0.5
107   >>>
108
109The typical usage to inspect a crashed program is::
110
111   >>> import pdb
112   >>> def f(x):
113   ...     print(1 / x)
114   ...
115   >>> f(0)
116   Traceback (most recent call last):
117     File "<stdin>", line 1, in <module>
118     File "<stdin>", line 2, in f
119   ZeroDivisionError: division by zero
120   >>> pdb.pm()
121   > <stdin>(2)f()
122   (Pdb) p x
123   0
124   (Pdb)
125
126.. versionchanged:: 3.13
127   The implementation of :pep:`667` means that name assignments made via ``pdb``
128   will immediately affect the active scope, even when running inside an
129   :term:`optimized scope`.
130
131
132The module defines the following functions; each enters the debugger in a
133slightly different way:
134
135.. function:: run(statement, globals=None, locals=None)
136
137   Execute the *statement* (given as a string or a code object) under debugger
138   control.  The debugger prompt appears before any code is executed; you can
139   set breakpoints and type :pdbcmd:`continue`, or you can step through the
140   statement using :pdbcmd:`step` or :pdbcmd:`next` (all these commands are
141   explained below).  The optional *globals* and *locals* arguments specify the
142   environment in which the code is executed; by default the dictionary of the
143   module :mod:`__main__` is used.  (See the explanation of the built-in
144   :func:`exec` or :func:`eval` functions.)
145
146
147.. function:: runeval(expression, globals=None, locals=None)
148
149   Evaluate the *expression* (given as a string or a code object) under debugger
150   control.  When :func:`runeval` returns, it returns the value of the
151   *expression*.  Otherwise this function is similar to :func:`run`.
152
153
154.. function:: runcall(function, *args, **kwds)
155
156   Call the *function* (a function or method object, not a string) with the
157   given arguments.  When :func:`runcall` returns, it returns whatever the
158   function call returned.  The debugger prompt appears as soon as the function
159   is entered.
160
161
162.. function:: set_trace(*, header=None)
163
164   Enter the debugger at the calling stack frame.  This is useful to hard-code
165   a breakpoint at a given point in a program, even if the code is not
166   otherwise being debugged (e.g. when an assertion fails).  If given,
167   *header* is printed to the console just before debugging begins.
168
169   .. versionchanged:: 3.7
170      The keyword-only argument *header*.
171
172   .. versionchanged:: 3.13
173      :func:`set_trace` will enter the debugger immediately, rather than
174      on the next line of code to be executed.
175
176.. function:: post_mortem(traceback=None)
177
178   Enter post-mortem debugging of the given *traceback* object.  If no
179   *traceback* is given, it uses the one of the exception that is currently
180   being handled (an exception must be being handled if the default is to be
181   used).
182
183
184.. function:: pm()
185
186   Enter post-mortem debugging of the exception found in
187   :data:`sys.last_exc`.
188
189
190The ``run*`` functions and :func:`set_trace` are aliases for instantiating the
191:class:`Pdb` class and calling the method of the same name.  If you want to
192access further features, you have to do this yourself:
193
194.. class:: Pdb(completekey='tab', stdin=None, stdout=None, skip=None, \
195               nosigint=False, readrc=True)
196
197   :class:`Pdb` is the debugger class.
198
199   The *completekey*, *stdin* and *stdout* arguments are passed to the
200   underlying :class:`cmd.Cmd` class; see the description there.
201
202   The *skip* argument, if given, must be an iterable of glob-style module name
203   patterns.  The debugger will not step into frames that originate in a module
204   that matches one of these patterns. [1]_
205
206   By default, Pdb sets a handler for the SIGINT signal (which is sent when the
207   user presses :kbd:`Ctrl-C` on the console) when you give a :pdbcmd:`continue` command.
208   This allows you to break into the debugger again by pressing :kbd:`Ctrl-C`.  If you
209   want Pdb not to touch the SIGINT handler, set *nosigint* to true.
210
211   The *readrc* argument defaults to true and controls whether Pdb will load
212   .pdbrc files from the filesystem.
213
214   Example call to enable tracing with *skip*::
215
216      import pdb; pdb.Pdb(skip=['django.*']).set_trace()
217
218   .. audit-event:: pdb.Pdb "" pdb.Pdb
219
220   .. versionchanged:: 3.1
221      Added the *skip* parameter.
222
223   .. versionchanged:: 3.2
224      Added the *nosigint* parameter.
225      Previously, a SIGINT handler was never set by Pdb.
226
227   .. versionchanged:: 3.6
228      The *readrc* argument.
229
230   .. method:: run(statement, globals=None, locals=None)
231               runeval(expression, globals=None, locals=None)
232               runcall(function, *args, **kwds)
233               set_trace()
234
235      See the documentation for the functions explained above.
236
237
238.. _debugger-commands:
239
240Debugger Commands
241-----------------
242
243The commands recognized by the debugger are listed below.  Most commands can be
244abbreviated to one or two letters as indicated; e.g. ``h(elp)`` means that
245either ``h`` or ``help`` can be used to enter the help command (but not ``he``
246or ``hel``, nor ``H`` or ``Help`` or ``HELP``).  Arguments to commands must be
247separated by whitespace (spaces or tabs).  Optional arguments are enclosed in
248square brackets (``[]``) in the command syntax; the square brackets must not be
249typed.  Alternatives in the command syntax are separated by a vertical bar
250(``|``).
251
252Entering a blank line repeats the last command entered.  Exception: if the last
253command was a :pdbcmd:`list` command, the next 11 lines are listed.
254
255Commands that the debugger doesn't recognize are assumed to be Python statements
256and are executed in the context of the program being debugged.  Python
257statements can also be prefixed with an exclamation point (``!``).  This is a
258powerful way to inspect the program being debugged; it is even possible to
259change a variable or call a function.  When an exception occurs in such a
260statement, the exception name is printed but the debugger's state is not
261changed.
262
263.. versionchanged:: 3.13
264   Expressions/Statements whose prefix is a pdb command are now correctly
265   identified and executed.
266
267The debugger supports :ref:`aliases <debugger-aliases>`.  Aliases can have
268parameters which allows one a certain level of adaptability to the context under
269examination.
270
271Multiple commands may be entered on a single line, separated by ``;;``.  (A
272single ``;`` is not used as it is the separator for multiple commands in a line
273that is passed to the Python parser.)  No intelligence is applied to separating
274the commands; the input is split at the first ``;;`` pair, even if it is in the
275middle of a quoted string. A workaround for strings with double semicolons
276is to use implicit string concatenation ``';'';'`` or ``";"";"``.
277
278To set a temporary global variable, use a *convenience variable*. A *convenience
279variable* is a variable whose name starts with ``$``.  For example, ``$foo = 1``
280sets a global variable ``$foo`` which you can use in the debugger session.  The
281*convenience variables* are cleared when the program resumes execution so it's
282less likely to interfere with your program compared to using normal variables
283like ``foo = 1``.
284
285There are three preset *convenience variables*:
286
287* ``$_frame``: the current frame you are debugging
288* ``$_retval``: the return value if the frame is returning
289* ``$_exception``: the exception if the frame is raising an exception
290
291.. versionadded:: 3.12
292
293   Added the *convenience variable* feature.
294
295.. index::
296   pair: .pdbrc; file
297   triple: debugger; configuration; file
298
299If a file :file:`.pdbrc` exists in the user's home directory or in the current
300directory, it is read with ``'utf-8'`` encoding and executed as if it had been
301typed at the debugger prompt, with the exception that empty lines and lines
302starting with ``#`` are ignored.  This is particularly useful for aliases.  If both
303files exist, the one in the home directory is read first and aliases defined there
304can be overridden by the local file.
305
306.. versionchanged:: 3.2
307   :file:`.pdbrc` can now contain commands that continue debugging, such as
308   :pdbcmd:`continue` or :pdbcmd:`next`.  Previously, these commands had no
309   effect.
310
311.. versionchanged:: 3.11
312   :file:`.pdbrc` is now read with ``'utf-8'`` encoding. Previously, it was read
313   with the system locale encoding.
314
315
316.. pdbcommand:: h(elp) [command]
317
318   Without argument, print the list of available commands.  With a *command* as
319   argument, print help about that command.  ``help pdb`` displays the full
320   documentation (the docstring of the :mod:`pdb` module).  Since the *command*
321   argument must be an identifier, ``help exec`` must be entered to get help on
322   the ``!`` command.
323
324.. pdbcommand:: w(here)
325
326   Print a stack trace, with the most recent frame at the bottom.  An arrow (``>``)
327   indicates the current frame, which determines the context of most commands.
328
329.. pdbcommand:: d(own) [count]
330
331   Move the current frame *count* (default one) levels down in the stack trace
332   (to a newer frame).
333
334.. pdbcommand:: u(p) [count]
335
336   Move the current frame *count* (default one) levels up in the stack trace (to
337   an older frame).
338
339.. pdbcommand:: b(reak) [([filename:]lineno | function) [, condition]]
340
341   With a *lineno* argument, set a break at line *lineno* in the current file.
342   The line number may be prefixed with a *filename* and a colon,
343   to specify a breakpoint in another file (possibly one that hasn't been loaded
344   yet).  The file is searched on :data:`sys.path`.  Accepatable forms of *filename*
345   are ``/abspath/to/file.py``, ``relpath/file.py``, ``module`` and
346   ``package.module``.
347
348   With a *function* argument, set a break at the first executable statement within
349   that function. *function* can be any expression that evaluates to a function
350   in the current namespace.
351
352   If a second argument is present, it is an expression which must evaluate to
353   true before the breakpoint is honored.
354
355   Without argument, list all breaks, including for each breakpoint, the number
356   of times that breakpoint has been hit, the current ignore count, and the
357   associated condition if any.
358
359   Each breakpoint is assigned a number to which all the other
360   breakpoint commands refer.
361
362.. pdbcommand:: tbreak [([filename:]lineno | function) [, condition]]
363
364   Temporary breakpoint, which is removed automatically when it is first hit.
365   The arguments are the same as for :pdbcmd:`break`.
366
367.. pdbcommand:: cl(ear) [filename:lineno | bpnumber ...]
368
369   With a *filename:lineno* argument, clear all the breakpoints at this line.
370   With a space separated list of breakpoint numbers, clear those breakpoints.
371   Without argument, clear all breaks (but first ask confirmation).
372
373.. pdbcommand:: disable bpnumber [bpnumber ...]
374
375   Disable the breakpoints given as a space separated list of breakpoint
376   numbers.  Disabling a breakpoint means it cannot cause the program to stop
377   execution, but unlike clearing a breakpoint, it remains in the list of
378   breakpoints and can be (re-)enabled.
379
380.. pdbcommand:: enable bpnumber [bpnumber ...]
381
382   Enable the breakpoints specified.
383
384.. pdbcommand:: ignore bpnumber [count]
385
386   Set the ignore count for the given breakpoint number.  If *count* is omitted,
387   the ignore count is set to 0.  A breakpoint becomes active when the ignore
388   count is zero.  When non-zero, the *count* is decremented each time the
389   breakpoint is reached and the breakpoint is not disabled and any associated
390   condition evaluates to true.
391
392.. pdbcommand:: condition bpnumber [condition]
393
394   Set a new *condition* for the breakpoint, an expression which must evaluate
395   to true before the breakpoint is honored.  If *condition* is absent, any
396   existing condition is removed; i.e., the breakpoint is made unconditional.
397
398.. pdbcommand:: commands [bpnumber]
399
400   Specify a list of commands for breakpoint number *bpnumber*.  The commands
401   themselves appear on the following lines.  Type a line containing just
402   ``end`` to terminate the commands. An example::
403
404      (Pdb) commands 1
405      (com) p some_variable
406      (com) end
407      (Pdb)
408
409   To remove all commands from a breakpoint, type ``commands`` and follow it
410   immediately with ``end``; that is, give no commands.
411
412   With no *bpnumber* argument, ``commands`` refers to the last breakpoint set.
413
414   You can use breakpoint commands to start your program up again.  Simply use
415   the :pdbcmd:`continue` command, or :pdbcmd:`step`,
416   or any other command that resumes execution.
417
418   Specifying any command resuming execution
419   (currently :pdbcmd:`continue`, :pdbcmd:`step`, :pdbcmd:`next`,
420   :pdbcmd:`return`, :pdbcmd:`jump`, :pdbcmd:`quit` and their abbreviations)
421   terminates the command list (as if
422   that command was immediately followed by end). This is because any time you
423   resume execution (even with a simple next or step), you may encounter another
424   breakpoint—which could have its own command list, leading to ambiguities about
425   which list to execute.
426
427   If you use the ``silent`` command in the command list, the usual message about
428   stopping at a breakpoint is not printed.  This may be desirable for breakpoints
429   that are to print a specific message and then continue.  If none of the other
430   commands print anything, you see no sign that the breakpoint was reached.
431
432.. pdbcommand:: s(tep)
433
434   Execute the current line, stop at the first possible occasion (either in a
435   function that is called or on the next line in the current function).
436
437.. pdbcommand:: n(ext)
438
439   Continue execution until the next line in the current function is reached or
440   it returns.  (The difference between :pdbcmd:`next` and :pdbcmd:`step` is
441   that :pdbcmd:`step` stops inside a called function, while :pdbcmd:`next`
442   executes called functions at (nearly) full speed, only stopping at the next
443   line in the current function.)
444
445.. pdbcommand:: unt(il) [lineno]
446
447   Without argument, continue execution until the line with a number greater
448   than the current one is reached.
449
450   With *lineno*, continue execution until a line with a number greater or
451   equal to *lineno* is reached.  In both cases, also stop when the current frame
452   returns.
453
454   .. versionchanged:: 3.2
455      Allow giving an explicit line number.
456
457.. pdbcommand:: r(eturn)
458
459   Continue execution until the current function returns.
460
461.. pdbcommand:: c(ont(inue))
462
463   Continue execution, only stop when a breakpoint is encountered.
464
465.. pdbcommand:: j(ump) lineno
466
467   Set the next line that will be executed.  Only available in the bottom-most
468   frame.  This lets you jump back and execute code again, or jump forward to
469   skip code that you don't want to run.
470
471   It should be noted that not all jumps are allowed -- for instance it is not
472   possible to jump into the middle of a :keyword:`for` loop or out of a
473   :keyword:`finally` clause.
474
475.. pdbcommand:: l(ist) [first[, last]]
476
477   List source code for the current file.  Without arguments, list 11 lines
478   around the current line or continue the previous listing.  With ``.`` as
479   argument, list 11 lines around the current line.  With one argument,
480   list 11 lines around at that line.  With two arguments, list the given range;
481   if the second argument is less than the first, it is interpreted as a count.
482
483   The current line in the current frame is indicated by ``->``.  If an
484   exception is being debugged, the line where the exception was originally
485   raised or propagated is indicated by ``>>``, if it differs from the current
486   line.
487
488   .. versionchanged:: 3.2
489      Added the ``>>`` marker.
490
491.. pdbcommand:: ll | longlist
492
493   List all source code for the current function or frame.  Interesting lines
494   are marked as for :pdbcmd:`list`.
495
496   .. versionadded:: 3.2
497
498.. pdbcommand:: a(rgs)
499
500   Print the arguments of the current function and their current values.
501
502.. pdbcommand:: p expression
503
504   Evaluate *expression* in the current context and print its value.
505
506   .. note::
507
508      ``print()`` can also be used, but is not a debugger command --- this executes the
509      Python :func:`print` function.
510
511
512.. pdbcommand:: pp expression
513
514   Like the :pdbcmd:`p` command, except the value of *expression* is
515   pretty-printed using the :mod:`pprint` module.
516
517.. pdbcommand:: whatis expression
518
519   Print the type of *expression*.
520
521.. pdbcommand:: source expression
522
523   Try to get source code of *expression* and display it.
524
525   .. versionadded:: 3.2
526
527.. pdbcommand:: display [expression]
528
529   Display the value of *expression* if it changed, each time execution stops
530   in the current frame.
531
532   Without *expression*, list all display expressions for the current frame.
533
534   .. note::
535
536      Display evaluates *expression* and compares to the result of the previous
537      evaluation of *expression*, so when the result is mutable, display may not
538      be able to pick up the changes.
539
540   Example::
541
542      lst = []
543      breakpoint()
544      pass
545      lst.append(1)
546      print(lst)
547
548   Display won't realize ``lst`` has been changed because the result of evaluation
549   is modified in place by ``lst.append(1)`` before being compared::
550
551      > example.py(3)<module>()
552      -> pass
553      (Pdb) display lst
554      display lst: []
555      (Pdb) n
556      > example.py(4)<module>()
557      -> lst.append(1)
558      (Pdb) n
559      > example.py(5)<module>()
560      -> print(lst)
561      (Pdb)
562
563   You can do some tricks with copy mechanism to make it work::
564
565      > example.py(3)<module>()
566      -> pass
567      (Pdb) display lst[:]
568      display lst[:]: []
569      (Pdb) n
570      > example.py(4)<module>()
571      -> lst.append(1)
572      (Pdb) n
573      > example.py(5)<module>()
574      -> print(lst)
575      display lst[:]: [1]  [old: []]
576      (Pdb)
577
578   .. versionadded:: 3.2
579
580.. pdbcommand:: undisplay [expression]
581
582   Do not display *expression* anymore in the current frame.  Without
583   *expression*, clear all display expressions for the current frame.
584
585   .. versionadded:: 3.2
586
587.. pdbcommand:: interact
588
589   Start an interactive interpreter (using the :mod:`code` module) in a new
590   global namespace initialised from the local and global namespaces for the
591   current scope. Use ``exit()`` or ``quit()`` to exit the interpreter and
592   return to the debugger.
593
594   .. note::
595
596      As ``interact`` creates a new dedicated namespace for code execution,
597      assignments to variables will not affect the original namespaces.
598      However, modifications to any referenced mutable objects will be reflected
599      in the original namespaces as usual.
600
601   .. versionadded:: 3.2
602
603   .. versionchanged:: 3.13
604      ``exit()`` and ``quit()`` can be used to exit the :pdbcmd:`interact`
605      command.
606
607   .. versionchanged:: 3.13
608      :pdbcmd:`interact` directs its output to the debugger's
609      output channel rather than :data:`sys.stderr`.
610
611.. _debugger-aliases:
612
613.. pdbcommand:: alias [name [command]]
614
615   Create an alias called *name* that executes *command*.  The *command* must
616   *not* be enclosed in quotes.  Replaceable parameters can be indicated by
617   ``%1``, ``%2``, ... and ``%9``, while ``%*`` is replaced by all the parameters.
618   If *command* is omitted, the current alias for *name* is shown. If no
619   arguments are given, all aliases are listed.
620
621   Aliases may be nested and can contain anything that can be legally typed at
622   the pdb prompt.  Note that internal pdb commands *can* be overridden by
623   aliases.  Such a command is then hidden until the alias is removed.  Aliasing
624   is recursively applied to the first word of the command line; all other words
625   in the line are left alone.
626
627   As an example, here are two useful aliases (especially when placed in the
628   :file:`.pdbrc` file)::
629
630      # Print instance variables (usage "pi classInst")
631      alias pi for k in %1.__dict__.keys(): print(f"%1.{k} = {%1.__dict__[k]}")
632      # Print instance variables in self
633      alias ps pi self
634
635.. pdbcommand:: unalias name
636
637   Delete the specified alias *name*.
638
639.. pdbcommand:: ! statement
640
641   Execute the (one-line) *statement* in the context of the current stack frame.
642   The exclamation point can be omitted unless the first word of the statement
643   resembles a debugger command, e.g.:
644
645   .. code-block:: none
646
647      (Pdb) ! n=42
648      (Pdb)
649
650   To set a global variable, you can prefix the assignment command with a
651   :keyword:`global` statement on the same line, e.g.:
652
653   .. code-block:: none
654
655      (Pdb) global list_options; list_options = ['-l']
656      (Pdb)
657
658.. pdbcommand:: run [args ...]
659                restart [args ...]
660
661   Restart the debugged Python program.  If *args* is supplied, it is split
662   with :mod:`shlex` and the result is used as the new :data:`sys.argv`.
663   History, breakpoints, actions and debugger options are preserved.
664   :pdbcmd:`restart` is an alias for :pdbcmd:`run`.
665
666.. pdbcommand:: q(uit)
667
668   Quit from the debugger.  The program being executed is aborted.
669
670.. pdbcommand:: debug code
671
672   Enter a recursive debugger that steps through *code*
673   (which is an arbitrary expression or statement to be
674   executed in the current environment).
675
676.. pdbcommand:: retval
677
678   Print the return value for the last return of the current function.
679
680.. pdbcommand:: exceptions [excnumber]
681
682   List or jump between chained exceptions.
683
684   When using ``pdb.pm()``  or ``Pdb.post_mortem(...)`` with a chained exception
685   instead of a traceback, it allows the user to move between the
686   chained exceptions using ``exceptions`` command to list exceptions, and
687   ``exception <number>`` to switch to that exception.
688
689
690   Example::
691
692        def out():
693            try:
694                middle()
695            except Exception as e:
696                raise ValueError("reraise middle() error") from e
697
698        def middle():
699            try:
700                return inner(0)
701            except Exception as e:
702                raise ValueError("Middle fail")
703
704        def inner(x):
705            1 / x
706
707         out()
708
709   calling ``pdb.pm()`` will allow to move between exceptions::
710
711    > example.py(5)out()
712    -> raise ValueError("reraise middle() error") from e
713
714    (Pdb) exceptions
715      0 ZeroDivisionError('division by zero')
716      1 ValueError('Middle fail')
717    > 2 ValueError('reraise middle() error')
718
719    (Pdb) exceptions 0
720    > example.py(16)inner()
721    -> 1 / x
722
723    (Pdb) up
724    > example.py(10)middle()
725    -> return inner(0)
726
727   .. versionadded:: 3.13
728
729.. rubric:: Footnotes
730
731.. [1] Whether a frame is considered to originate in a certain module
732       is determined by the ``__name__`` in the frame globals.
733