{"id":13502689,"url":"https://github.com/gotcha/ipdb","last_synced_at":"2025-05-13T18:18:43.693Z","repository":{"id":1313484,"uuid":"1258258","full_name":"gotcha/ipdb","owner":"gotcha","description":"Integration of IPython pdb","archived":false,"fork":false,"pushed_at":"2024-08-09T11:23:55.000Z","size":240,"stargazers_count":1907,"open_issues_count":79,"forks_count":147,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-04-25T17:58:50.039Z","etag":null,"topics":["debugger","ipython","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gotcha.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.txt","contributing":null,"funding":null,"license":"COPYING.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-01-15T17:51:47.000Z","updated_at":"2025-04-23T15:56:29.000Z","dependencies_parsed_at":"2023-07-06T01:54:32.693Z","dependency_job_id":"48dc18b3-586d-4bd0-bbdc-6602f2f7ce35","html_url":"https://github.com/gotcha/ipdb","commit_stats":{"total_commits":331,"total_committers":61,"mean_commits":5.426229508196721,"dds":0.5015105740181269,"last_synced_commit":"400e37c56c9772fdc4c04ddb29d8a4a20568fb1a"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotcha%2Fipdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotcha%2Fipdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotcha%2Fipdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotcha%2Fipdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotcha","download_url":"https://codeload.github.com/gotcha/ipdb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254000895,"owners_count":21997444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debugger","ipython","python"],"created_at":"2024-07-31T22:02:22.421Z","updated_at":"2025-05-13T18:18:43.504Z","avatar_url":"https://github.com/gotcha.png","language":"Python","readme":"IPython `pdb`\n=============\n\n.. image:: https://github.com/gotcha/ipdb/actions/workflows/tests.yml/badge.svg\n  :target: https://github.com/gotcha/ipdb/actions/workflows/tests.yml\n.. image:: https://codecov.io/gh/gotcha/ipdb/branch/master/graphs/badge.svg?style=flat\n  :target: https://codecov.io/gh/gotcha/ipdb?branch=master\n\nUse\n---\n\nipdb exports functions to access the IPython_ debugger, which features\ntab completion, syntax highlighting, better tracebacks, better introspection\nwith the same interface as the `pdb` module.\n\nExample usage:\n\n.. code-block:: python\n\n        import ipdb\n        ipdb.set_trace()\n        ipdb.set_trace(context=5)  # will show five lines of code\n                                   # instead of the default three lines\n                                   # or you can set it via IPDB_CONTEXT_SIZE env variable\n                                   # or setup.cfg file\n        ipdb.pm()\n        ipdb.run('x[0] = 3')\n        result = ipdb.runcall(function, arg0, arg1, kwarg='foo')\n        result = ipdb.runeval('f(1,2) - 3')\n\n\nArguments for `set_trace`\n+++++++++++++++++++++++++\n\nThe `set_trace` function accepts `context` which will show as many lines of code as defined,\nand `cond`, which accepts boolean values (such as `abc == 17`) and will start ipdb's\ninterface whenever `cond` equals to `True`.\n\nUsing configuration file\n++++++++++++++++++++++++\n\nIt's possible to set up context using a `.ipdb` file on your home folder, `setup.cfg`\nor `pyproject.toml` on your project folder. You can also set your file location via\nenv var `$IPDB_CONFIG`. Your environment variable has priority over the home\nconfiguration file, which in turn has priority over the setup config file.\nCurrently, only context setting is available.\n\nA valid setup.cfg is as follows\n\n::\n\n        [ipdb]\n        context=5\n\n\nA valid .ipdb is as follows\n\n::\n\n        context=5\n\n\nA valid pyproject.toml is as follows\n\n::\n\n        [tool.ipdb]\n        context=5\n\n\nThe post-mortem function, ``ipdb.pm()``, is equivalent to the magic function\n``%debug``.\n\n.. _IPython: http://ipython.org\n\nIf you install ``ipdb`` with a tool which supports ``setuptools`` entry points,\nan ``ipdb`` script is made for you. You can use it to debug your python 2 scripts like\n\n::\n\n        $ bin/ipdb mymodule.py\n\nAnd for python 3\n\n::\n\n        $ bin/ipdb3 mymodule.py\n\nAlternatively with Python 2.7 only, you can also use\n\n::\n\n        $ python -m ipdb mymodule.py\n\nYou can also enclose code with the ``with`` statement to launch ipdb if an exception is raised:\n\n.. code-block:: python\n\n        from ipdb import launch_ipdb_on_exception\n\n        with launch_ipdb_on_exception():\n            [...]\n\n.. warning::\n   Context managers were introduced in Python 2.5.\n   Adding a context manager implies dropping Python 2.4 support.\n   Use ``ipdb==0.6`` with 2.4.\n\nOr you can use ``iex`` as a function decorator to launch ipdb if an exception is raised:\n\n.. code-block:: python\n\n        from ipdb import iex\n\n        @iex\n        def main():\n            [...]\n\n.. warning::\n   Using ``from future import print_function`` for Python 3 compat implies dropping Python 2.5 support.\n   Use ``ipdb\u003c=0.8`` with 2.5.\n\nIssues with ``stdout``\n----------------------\n\nSome tools, like ``nose`` fiddle with ``stdout``.\n\nUntil ``ipdb==0.9.4``, we tried to guess when we should also\nfiddle with ``stdout`` to support those tools.\nHowever, all strategies tried until 0.9.4 have proven brittle.\n\nIf you use ``nose`` or another tool that fiddles with ``stdout``, you should\nexplicitly ask for ``stdout`` fiddling by using ``ipdb`` like this\n\n.. code-block:: python\n\n        import ipdb\n        ipdb.sset_trace()\n        ipdb.spm()\n\n        from ipdb import slaunch_ipdb_on_exception\n        with slaunch_ipdb_on_exception():\n            [...]\n\n\nDevelopment\n-----------\n\n``ipdb`` source code and tracker are at https://github.com/gotcha/ipdb.\n\nPull requests should take care of updating the changelog ``HISTORY.txt``.\n\nUnder the unreleased section, add your changes and your username.\n\nManual testing\n++++++++++++++\n\nTo test your changes, make use of ``manual_test.py``. Create a virtual environment,\ninstall IPython and run ``python manual_test.py`` and check if your changes are in effect.\nIf possible, create automated tests for better behaviour control.\n\nAutomated testing\n+++++++++++++++++\n\nTo run automated tests locally, create a virtual environment, install `coverage`\nand run `coverage run setup.py test`.\n\nThird-party support\n-------------------\n\nProducts.PDBDebugMode\n+++++++++++++++++++++\n\nZope2 Products.PDBDebugMode_ uses ``ipdb``, if available, in place of ``pdb``.\n\n.. _Products.PDBDebugMode: http://pypi.python.org/pypi/Products.PDBDebugMode\n\niw.debug\n++++++++\n\niw.debug_ allows you to trigger an ``ipdb`` debugger on any published object\nof a Zope2 application.\n\n.. _iw.debug: http://pypi.python.org/pypi/iw.debug\n\nipdbplugin\n++++++++++\n\nipdbplugin_ is a nose_ test runner plugin that also uses the IPython debugger\ninstead of ``pdb``. (It does not depend on ``ipdb`` anymore).\n\n.. _ipdbplugin: http://pypi.python.org/pypi/ipdbplugin\n.. _nose: http://readthedocs.org/docs/nose\n\n\npytest\n+++++++\npytest_ supports a ``--pdb`` option which can run ``ipdb`` /\n``IPython.terminal.debugger:Pdb`` on ``Exception`` and ``breakpoint()``:\n\n.. code:: bash\n\n    pytest --pdb --pdbcls=IPython.terminal.debugger:Pdb -v ./test_example.py\n\nYou don't need to specify ``--pdbcls`` for every ``pytest`` invocation \nif you add ``addopts`` to ``pytest.ini`` or ``pyproject.toml``.\n\n``pytest.ini``:\n\n.. code:: bash\n\n  [tool.pytest.ini_options]\n  addopts = \"--pdbcls=IPython.terminal.debugger:Pdb\"\n\n``pyproject.toml``:\n\n.. code:: yml\n\n  [tool.pytest.ini_options]\n  addopts = \"--pdbcls=IPython.terminal.debugger:Pdb\"\n\n\n.. _pytest: https://pypi.python.org/pypi/pytest\n","funding_links":[],"categories":["Debugging Tools","Python","Uncategorized","调试工具","Debugging Tools [🔝](#readme)"],"sub_categories":["Uncategorized","Other dialects and variants","Python tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotcha%2Fipdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotcha%2Fipdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotcha%2Fipdb/lists"}