[Python-Dev] Proposal: go back to enabling DeprecationWarning by default
Nick Coghlan
ncoghlan at gmail.com
Sat Nov 11 02:00:36 EST 2017
On 11 November 2017 at 02:02, Random832 <random832 at fastmail.com> wrote:
> On Tue, Nov 7, 2017, at 07:22, Nick Coghlan wrote:
>> My suggestion for that definition is to have the *default* meaning of
>> "third party code" be "everything that isn't __main__".
>
> What is __main__? Or, rather, how do you determine when it is to blame?
> For syntax it's easy, but any deprecated function necessarily belongs to
> its own module and not to main. Main may have called it, which can be
> detected from the stack trace, or it may have used it in some other way
> (pass to some builtin or e.g. itertools function that takes a callable
> argument, for example).
The warnings machinery already defines how this works (look for
"stacklevel"). For callbacks defined as Python code, the deprecated
call will be attributed to whichever module defined the callback, not
the machinery that called the callback.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev
mailing list