On 11 November 2017 at 02:02, Random832 <random...@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 | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ 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/archive%40mail-archive.com