Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyproject.toml reading upon initialization raises TypeError exception #229

Closed
markab1018 opened this issue May 27, 2021 · 2 comments
Closed

Comments

@markab1018
Copy link

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"]:
@anjos
Copy link
Contributor

anjos commented Jun 1, 2021

You are right (n.b.: author of that patch).

@gotcha
Copy link
Owner

gotcha commented Jun 2, 2021

Thanks, released in 0.13.9

@gotcha gotcha closed this as completed Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants