Skip to content

%debug --breakpoint doesn't work with space in filename #14098

Closed

Description

@gwerbin

The %debug --breakpoint magic does not appear to support spaces in the filename. This can make it impossible to use %debug to set certain breakpoints in site-packages files on certain Mac installations (e.g. a Hatch venv), due to the Application Support directory.

I tried several variants of quoting and backslash-escaping, but never made progress.

mkdir 'My Project'
echo 'def f(x): return 1' > 'My Project/thing.py'
export PYTHONPATH='My Project'
ipython
Python 3.11.4 (main, Jun 10 2023, 09:07:43) [Clang 13.1.6 (clang-1316.0.21.2.5)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.13.2 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %debug --breakpoint My Project/a.py:1
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 1
----> 1 get_ipython().run_line_magic('debug', '--breakpoint My Project/a.py:1')

File ~/.local/opt/pipx/venvs/jupyterlab/lib/python3.11/site-packages/IPython/core/interactiveshell.py:2417, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
   2415     kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2416 with self.builtin_trap:
-> 2417     result = fn(*args, **kwargs)
   2419 # The code below prevents the output from being displayed
   2420 # when using magics with decodator @output_can_be_silenced
   2421 # when the last Python token in the expression is a ';'.
   2422 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File ~/.local/opt/pipx/venvs/jupyterlab/lib/python3.11/site-packages/IPython/core/magics/execution.py:465, in ExecutionMagics.debug(self, line, cell, local_ns)
    463 if cell:
    464     code += "\n" + cell
--> 465 self._debug_exec(code, args.breakpoint, local_ns)

File ~/.local/opt/pipx/venvs/jupyterlab/lib/python3.11/site-packages/IPython/core/magics/execution.py:472, in ExecutionMagics._debug_exec(self, code, breakpoint, local_ns)
    470 def _debug_exec(self, code, breakpoint, local_ns=None):
    471     if breakpoint:
--> 472         (filename, bp_line) = breakpoint.rsplit(':', 1)
    473         bp_line = int(bp_line)
    474     else:

ValueError: not enough values to unpack (expected 2, got 1)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions