(original) (raw)
I think programmatic overrides should be able to decide for themselves if they want to honor PYTHONBREAKPOINT or not, since I can imagine use cases that go both ways. So it should be checked in sys.breakpointhook().
On Sun, Sep 10, 2017 at 12:06 PM, Barry Warsaw <barry@python.org> wrote:
For PEP 553, I think it’s a good idea to support the environment variable $PYTHONBREAKPOINT\[\*\] but I’m stuck on a design question, so I’d like to get some feedback.
Should $PYTHONBREAKPOINT be consulted in breakpoint() or in sys.breakpointhook()?
If we support it in breakpoint() then it means if $PYTHONBREAKPOINT is set, Python will never call sys.breakpointhook() so programmatic override of that will be ignored.
If we support it in sys.breakpointhook(), then if you programmatically override that, PYTHONBREAKPOINTwillbeignoredevenifset.Ofcourse,anycodethatoverridessys.breakpointhook()couldalsoconsultPYTHONBREAKPOINT will be ignored even if set. Of course, any code that overrides sys.breakpointhook() could also consult PYTHONBREAKPOINTwillbeignoredevenifset.Ofcourse,anycodethatoverridessys.breakpointhook()couldalsoconsultPYTHONBREAKPOINT if they want.
So how do we want it to work? It seems like explicit code should override the environment variable, which should override the default, meaning that PYTHONBREAKPOINTshouldbeconsultedonlyinbreakpoint().Andifyousetsys.breakpointhook()withsomethingelse,thenohwell,PythonjustignoresPYTHONBREAKPOINT should be consulted only in breakpoint(). And if you set sys.breakpointhook() with something else, then oh well, Python just ignores PYTHONBREAKPOINTshouldbeconsultedonlyinbreakpoint().Andifyousetsys.breakpointhook()withsomethingelse,thenohwell,PythonjustignoresPYTHONBREAKPOINT.
Feedback welcome.
\-Barry
\[\*\] Probably not $PYTHONBREAKPOINTHOOK although if we choose to implement that in sys.breakpointhook(), it might still makes sense.
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/ guido%40python.org
--
--Guido van Rossum (python.org/\~guido)