[New-bugs-announce] [issue41641] Add a "message" action to warnings, to trigger for every *unique* message

Xavier Morel report at bugs.python.org
Wed Aug 26 05:11:26 EDT 2020


New submission from Xavier Morel <xavier.morel at masklinn.net>:

Warning actions allow deduplicating warning triggers based on category ("once"), category + file ("module") and category + exact location ("default").

One thing which is missing is support for a single location generating warnings *on behalf* of other pieces of code.

`warnings.warn` provides some support via the "stacklevel" parameter, but it is difficult to compute if the warning is generated from somewhat nested generic code (or even impossible if the warning is generated from completely  generic code checking over e.g. data files or the like, or if the invoker could be invoked from multiple places with different depth difference from the code they're working for).


But in that case, the warning messages will often be unique per functional unit, so it could be a useful base for deduplication, even though the warning could dynamically be invoked multiple times (per functional unit) because e.g. code is reloaded or whatever.

----------
components: Library (Lib)
messages: 375924
nosy: xmorel
priority: normal
severity: normal
status: open
title: Add a "message" action to warnings, to trigger for every *unique* message
type: enhancement
versions: Python 3.9

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


More information about the New-bugs-announce mailing list