Just started ipdb on a directory that happened to contain a pyproject.toml file inside to get a TypeError exception.
To reproduce this problem, pip install the latest ipdb, create an empty pyproject.toml (n.b: it does not have to empty, it should just not contain any tool section) in the directory you are launching it, and then you will observe the crash (tested with ipdb 0.13.8):
$ pip install ipdb
$ mkdir tmp
$ cd tmp
$ touch pyproject.toml
$ touch test.py
$ python -m ipdb test.py
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py:126: RuntimeWarning: 'ipdb.__main__' found in sys.modules after import of package 'ipdb', but prior to execution of 'ipdb.__main__'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
Traceback (most recent call last):
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/user/.virtualenv/temp/lib/python3.8/site-packages/ipdb/__main__.py", line 327, in <module>
main()
File "/Users/user/.virtualenv/temp/lib/python3.8/site-packages/ipdb/__main__.py", line 299, in main
pdb = _init_pdb(commands=commands)
File "/Users/user/.virtualenv/temp/lib/python3.8/site-packages/ipdb/__main__.py", line 53, in _init_pdb
context = os.getenv("IPDB_CONTEXT_SIZE", get_context_from_config())
File "/Users/user/.virtualenv/temp/lib/python3.8/site-packages/ipdb/__main__.py", line 84, in get_context_from_config
parser = get_config()
File "/Users/user/.virtualenv/temp/lib/python3.8/site-packages/ipdb/__main__.py", line 181, in get_config
if "ipdb" in toml_file.get("tool"):
TypeError: argument of type 'NoneType' is not iterable
This is almost the exact same error as described in #227 except the fix for that just traded a NameError for a TypeError.
To actually fix it would need to be
if "tool" in toml_file and "ipdb" in toml_file["tool"]:
Just started ipdb on a directory that happened to contain a pyproject.toml file inside to get a TypeError exception.
To reproduce this problem, pip install the latest ipdb, create an empty pyproject.toml (n.b: it does not have to empty, it should just not contain any tool section) in the directory you are launching it, and then you will observe the crash (tested with ipdb 0.13.8):
This is almost the exact same error as described in #227 except the fix for that just traded a
NameError
for aTypeError
.To actually fix it would need to be