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] PEP 495 accepted

2015-09-21 Thread Nick Coghlan
On 22 September 2015 at 08:03, Guido van Rossum wrote: > Just so people know, over at the datetime-sig I've accepted PEP 495, which > adds a fold flag to datetime objects to distinguish ambiguous times. This > enables roundripping of conversions for those times where the local

Re: [Python-Dev] PEP 495 accepted

2015-09-21 Thread Victor Stinner
More context ;-) PEP 0495 -- Local Time Disambiguation Abstract This PEP adds a new attribute fold to instances of the datetime.time and datetime.datetime classes that can be used to differentiate between two moments in time for which local times are the same. The allowed values for the fold

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

[Python-Dev] PEP 495 accepted

2015-09-21 Thread Guido van Rossum
Just so people know, over at the datetime-sig I've accepted PEP 495, which adds a fold flag to datetime objects to distinguish ambiguous times. This enables roundripping of conversions for those times where the local clock is moved backward (creating ambiguous times that could not be distinguished

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] PEP 498 (interpolated f-string) tweak

2015-09-21 Thread Nick Coghlan
On 21 September 2015 at 05:22, Eric V. Smith wrote: > >> On Sep 20, 2015, at 11:15 AM, Serhiy Storchaka wrote: >> >>> On 20.09.15 16:51, Eric V. Smith wrote: On 9/20/2015 8:37 AM, Nick Coghlan wrote: > On 19 September 2015 at 21:03, Eric V. Smith

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