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

Serhiy Storchaka storchaka at gmail.com
Sun Sep 20 08:44:54 CEST 2015


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 code. But rather can fix existing bugs. If stacklevel=1 is 
required (I don't know cases), it can be explicitly specified.



More information about the Python-Dev mailing list