This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Should warnings.warn default to stacklevel=2?
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Anthony Sottile
Priority: normal Keywords:

Created on 2021-06-02 23:55 by Anthony Sottile, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg394960 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2021-06-02 23:55
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
History
Date User Action Args
2022-04-11 14:59:46adminsetgithub: 88462
2021-06-02 23:55:20Anthony Sottilecreate