[New-bugs-announce] [issue44296] Should warnings.warn default to stacklevel=2?

Anthony Sottile report at bugs.python.org
Wed Jun 2 19:55:20 EDT 2021


New submission from Anthony Sottile <asottile at umich.edu>:

I have yet to come across a usecase where `stacklevel=1` makes sense -- usually it is more helpful to point at the calling code than the function which is itself warning

my proposal is to update the default for `stacklevel=` from `1` to `2`

an example bpo where this is relevant is bpo-44295

----------
components: Library (Lib)
messages: 394960
nosy: Anthony Sottile
priority: normal
severity: normal
status: open
title: Should warnings.warn default to stacklevel=2?
type: behavior
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44296>
_______________________________________


More information about the New-bugs-announce mailing list