Support for pyproject.toml is broken, and breaks debugging
See original GitHub issueAs found in https://github.com/gotcha/ipdb/pull/213, ipdb
tries to read configuration from pyproject.toml
using a ConfigParser
object. However, ConfigParser
does not support toml syntax, it supports ini syntax which looks a lot alike, but is not the same.
I’m using the following snippet in my pyproject.toml
, and ipdb
crashes whenever it is is started:
[tool.black]
line-length = 119
target-version = ['py38']
exclude = '''
/(
| migrations
)/
'''
I don’t have any ipdb
-related configuration in pyproject.toml
at all.
The traceback:
Traceback (most recent call last):
File "[...]/env/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "[...]/env/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "[...]/env/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "[...]/env/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "[...]/env/lib/python3.8/site-packages/django/views/generic/edit.py", line 133, in get
return self.render_to_response(self.get_context_data())
File "[...]/website/views.py", line 43, in get_context_data
breakpoint()
File "[...]/env/lib/python3.8/site-packages/ipdb/__main__.py", line 75, in set_trace
p = _init_pdb(context).set_trace(frame)
File "[...]/env/lib/python3.8/site-packages/ipdb/__main__.py", line 52, in _init_pdb
context = os.getenv("IPDB_CONTEXT_SIZE", get_context_from_config())
File "[...]/env/lib/python3.8/site-packages/ipdb/__main__.py", line 82, in get_context_from_config
parser = get_config()
File "[...]/env/lib/python3.8/site-packages/ipdb/__main__.py", line 174, in get_config
read_func(f)
File "/usr/lib/python3.8/configparser.py", line 718, in read_file
self._read(f, source)
File "/usr/lib/python3.8/configparser.py", line 1113, in _read
raise e
configparser.ParsingError: Source contains parsing errors: '[...]/pyproject.toml'
[line 13]: '/(\n'
[line 15]: ')/\n'
[line 16]: "'''\n"
I think ipdb
should use a toml parser to parse pyproject.toml
, or stay away from the file.
Note that this change will hurt a lot of people using the combination of ipdb
and black
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:10 (7 by maintainers)
Top Results From Across the Web
[BUG] unable to do a local install with pyproject.toml in ...
B. This error is caused by setuptools being loaded from outside the virtual environment. To get evidence about it we can do: Remove...
Read more >Unable to debug in pycharm with pytest
For my situation, I found what the problem is: If there is --cov in pytest.ini , then breakpoints in pycharm won't work, after...
Read more >Pip, pyproject.toml and debug builds - Packaging
We have been using Numpy debug modules built and installed in using pip. python_d.exe -m pip install --no-binary :all: --global-option build -- ...
Read more >debugging of py.test does not stop on breakpoints if coverage ...
Workaround that worked for me to ignore pytest coverage settings in pyproject.toml is to edit the pytest configuration (in edit configurations) and add...
Read more >A Poetic Apology
and run your code in post mortem debugging mode with python -m pdb -cc ... you add a pyproject.toml telling black to skip...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Important addition: if I include the specific
ipdb
snippet:to the
pyproject.toml
, it doesn’t break anymore. So it seems your toml parsing is now correct, but only the extraction of the configuration value fails (especially when the value isn’t in the config).@alexandrebarbaruiva Thanks for the quick response.
Unfortunately, in your PR stuff still is broken, but in a different way 😕 To reproduce:
pip install ../path/to/ipdb/checkout
pyproject,toml
file, with above content.pyproject.toml
, execute the commands: