ipdb icon indicating copy to clipboard operation
ipdb copied to clipboard

Support for multiple -m flags

Open dmfigol opened this issue 7 years ago • 4 comments

With Python 3.7 if you run the program as a module, it is possible to wrap it with another debugging module: python3.7 -m pdb -m <my_program_as_module> ipdb does not recognise multiple -m switches yet:

-> % pipenv run python -m ipdb -m <my_program_as_module>
Loading .env environment variables...
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py:125: 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 "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/dmfigol/projects/my/.venv/lib/python3.7/site-packages/ipdb/__main__.py", line 190, in <module>
    main()
  File "/Users/dmfigol/projects/my/.venv/lib/python3.7/site-packages/ipdb/__main__.py", line 138, in main
    opts, args = getopt.getopt(sys.argv[1:], 'hc:', ['--help', '--command='])
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/getopt.py", line 95, in getopt
    opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:])
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/getopt.py", line 195, in do_shorts
    if short_has_arg(opt, shortopts):
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/getopt.py", line 211, in short_has_arg
    raise GetoptError(_('option -%s not recognized') % opt, opt)
getopt.GetoptError: option -m not recognized

dmfigol avatar Jul 01 '18 14:07 dmfigol

I've run into the exact same issue.

philn16 avatar May 09 '19 18:05 philn16

This isn't exactly a request for supporting multiple -m flags, because actually the first -m option isn't passed to ipdb at all, but rather to the python interpreter itself. I think the request here is to support debugging modules with ipdb, just as pdb in python 3.7 and higher can.

MSK61 avatar Jun 03 '20 14:06 MSK61

PR welcome

gotcha avatar Jun 04 '20 15:06 gotcha

Fixed in #192

MrMino avatar Jan 06 '21 05:01 MrMino