[Python-Dev] PEP 553: Built-in debug()

Barry Warsaw barry at python.org
Wed Sep 6 18:24:20 EDT 2017

On Sep 6, 2017, at 10:14, Fabio Zadrozny <fabiofz at gmail.com> wrote:
> I think it's a nice idea.


> Related to the name, on the windows c++ there's "DebugBreak":  https://msdn.microsoft.com/en-us/library/windows/desktop/ms679297(v=vs.85).aspx, which I think is a better name (so, it'd be debug_break for Python -- I think it's better than plain breakpoint(), and wouldn't clash as debug()).

It’s important to understand that a new built-in is technically never going to clash with existing code, regardless of what it’s called.  Given Python’s name resolution rules, if your code uses any built, it’ll just shadow it.  That’s one big reason why the PEP proposed a built-in rather than say a keyword.

That said, while I like the more succinct `debug()` name, Guido prefers `breakpoint()` and that works fine for me.

> I think I could change the hook on a custom sitecustomize (there's already one in place in PyDev) so that the debug_break() would actually read some env var to do that work (and provide some utility for users to pre-setup it when not launching from inside the IDE).

I had meant to add an open issue about the idea of adding an environment variable, such as $PYTHONBREAKPOINTHOOK which could be set to the callable to bind to sys.breakpointhook().  I’ve now added that to PEP 553, and I think that handles the use case you outline above.

> Still, there may be other settings that the user needs to pass to settrace() when doing a remote debug session -- i.e.: things such as the host, port to connect, etc -- see: https://github.com/fabioz/PyDev.Debugger/blob/master/pydevd.py#L1121, so, maybe the debug_break() method should accept keyword arguments to pass along to support other backends?

Possibly, and there’s an open issue about that, but I’m skeptical about that for your use case.  Will a user setting a breakpoint know what to pass there?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 273 bytes
Desc: Message signed with OpenPGP
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170906/b422c5e6/attachment-0001.sig>

More information about the Python-Dev mailing list