Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Victor Stinner
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). Victor 2015-09-20 8:44 GMT+02:00 Serhiy Storchaka : > For now the default value of the stacklevel parameter in warnings.warn() is >

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Nathaniel Smith
On Sep 21, 2015 12:15 AM, "Victor Stinner" 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

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Victor Stinner
2015-09-20 8:44 GMT+02:00 Serhiy Storchaka : > I propose to make the default value of stacklevel to be 2. > I think that unlikely this will break existing code. Consider this simple script: --- import warnings warnings.warn("here") --- Currrent output: --- x.py:3:

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Nathaniel Smith
On Mon, Sep 21, 2015 at 10:14 AM, Serhiy Storchaka wrote: > stacklevel=2 is correct argument for module level warnings, but as Nathaniel > noted not all packages use it. When your run correctly written module as > script you get the same "sys:1:". And this issue can be solved

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Nick Coghlan
On 22 Sep 2015 03:16, "Serhiy Storchaka" wrote: > > On 21.09.15 12:05, Nick Coghlan wrote: >> >> As Victor notes, though, that's not the right default for *scripts* >> that are issuing deprecation warnings to end users - there, they >> really are deprecating themselves. It's

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Serhiy Storchaka
On 21.09.15 12:05, Nick Coghlan wrote: As Victor notes, though, that's not the right default for *scripts* that are issuing deprecation warnings to end users - there, they really are deprecating themselves. It's also not the right default for pretty much any warning other than DeprecationWarning

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Brett Cannon
On Mon, 21 Sep 2015 at 10:15 Serhiy Storchaka wrote: > On 21.09.15 12:05, Nick Coghlan wrote: > > As Victor notes, though, that's not the right default for *scripts* > > that are issuing deprecation warnings to end users - there, they > > really are deprecating themselves.

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Serhiy Storchaka
On 21.09.15 10:18, Victor Stinner wrote: 2015-09-20 8:44 GMT+02:00 Serhiy Storchaka : I propose to make the default value of stacklevel to be 2. I think that unlikely this will break existing code. Consider this simple script: --- import warnings warnings.warn("here") ---

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Guido van Rossum
I think it's been conclusively shown that we should not change the default. Instead I recommend updating the docs with an example showing when stacklevel=2 is appropriate. On Mon, Sep 21, 2015 at 2:05 AM, Nick Coghlan wrote: > On 21 September 2015 at 17:21, Nathaniel Smith

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Walter Dörwald
On 21 Sep 2015, at 9:18, Victor Stinner wrote: 2015-09-20 8:44 GMT+02:00 Serhiy Storchaka : I propose to make the default value of stacklevel to be 2. I think that unlikely this will break existing code. Consider this simple script: --- import warnings

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Serhiy Storchaka
On 21.09.15 20:00, Serhiy Storchaka wrote: On 21.09.15 10:18, Victor Stinner wrote: --- sys:1: UserWarning: here --- "sys:1" is not really useful :-/ This is not new. The same output we get when run a module that correctly emits a warning at module level (with explicit stacklevel=2). $

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Serhiy Storchaka
On 21.09.15 20:32, Brett Cannon wrote: On Mon, 21 Sep 2015 at 10:15 Serhiy Storchaka > wrote: On 21.09.15 12:05, Nick Coghlan wrote: > Passing "stacklevel=2" for API deprecations is by no means obvious > though, so perhaps it

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Brett Cannon
On Mon, 21 Sep 2015 at 11:29 Serhiy Storchaka wrote: > On 21.09.15 20:32, Brett Cannon wrote: > > > > > > On Mon, 21 Sep 2015 at 10:15 Serhiy Storchaka > > wrote: > > > > On 21.09.15 12:05, Nick Coghlan wrote: > > >

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-21 Thread Nick Coghlan
On 21 September 2015 at 17:21, Nathaniel Smith wrote: > On Sep 21, 2015 12:15 AM, "Victor Stinner" 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 >>

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-20 Thread Nathaniel Smith
On Sat, Sep 19, 2015 at 11:44 PM, Serhiy Storchaka wrote: > For now the default value of the stacklevel parameter in warnings.warn() is > 1. But in most cases stacklevel=2 is required, sometimes >2, and I don't > know cases that need stacklevel=1. I propose to make the

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-20 Thread Gustavo Carneiro
On 20 September 2015 at 07:55, Nathaniel Smith wrote: > On Sat, Sep 19, 2015 at 11:44 PM, Serhiy Storchaka > wrote: > > For now the default value of the stacklevel parameter in warnings.warn() > is > > 1. But in most cases stacklevel=2 is required, sometimes

[Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-20 Thread Serhiy Storchaka
For now the default value of the stacklevel parameter in warnings.warn() is 1. But in most cases stacklevel=2 is required, sometimes >2, and I don't know cases that need stacklevel=1. I propose to make the default value of stacklevel to be 2. I think that unlikely this will break existing

Re: [Python-Dev] Make stacklevel=2 by default in warnings.warn()

2015-09-20 Thread Serhiy Storchaka
субота, 19-вер-2015 23:55:44 Nathaniel Smith написано: > OTOH I guess if there is anyone out there who's intentionally using > stacklevel=1 they might be reasonably surprised at this change. That is why I ask on Python-Dev instead of just open an issue. But I doubt that there is such case.