On Sep 21, 2015 12:15 AM, "Victor Stinner" <victor.stin...@gmail.com> wrote:
>
> Would it be too verbose to display two frames or more by default?
> Maybe depending on the action (ex: only if the warning is emitted only
> once).

It's not just about how it gets displayed -- the frame that it gets
"attributed" to is also used when comparing against the warnings filters to
determine what action to take. What if stacklevel=1 makes it match a filter
with action "ignore", and stacklevel=2 makes it match a filter with action
"raise"?

(This is a common example I've encountered in the context of wanting to set
up CI tests so that if *my* code uses deprecated functionality then I want
to fail the test so I notice, but if some library I'm using uses deprecated
functionality internally then that's not my problem. This breaks down when
the library makes the common error of issuing DeprecationWarnings with
stacklevel=1, because that makes python think that they are deprecating
themselves, not warning that I did something deprecated.)

-n
_______________________________________________
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

Reply via email to