STINNER Victor <victor.stin...@gmail.com> added the comment:

> If a program calls func() 1000 times in a row, they will show the same 
> warning 1000 times.  What does it bring to have the exact same warning (and 
> line number) displayed 1000 times instead of once? Nothing.  There is a 
> reason the filter "default" isn't the same as "always", and it's that 
> "always" can be completely overwhelming.

I don't know the rationale of the "always" action rather than "default". The 
choice was made 7 years ago, when Georg Brandl implemented the new 
ResourceWarning category: commit 08be72d0aa0112118b79d271479598c218adfd23.

The problem of ResourceWarning is that the warning logs where the last 
reference to the resource was cleared, or where the a garbage collection was 
triggered. Multiple resources can be created from different places, but all 
"die" at the same place.

In Python 3.6, I enhanced ResourceWarning to log also the traceback where the 
leaked resource has been created, if the tracemalloc is tracing memory 
allocations. When tracemalloc is used, it's useful to log ResourceWarning 
multiple times even if the warning itself is logged multipletimes. Well, that's 
an unusual usage of the ResourceWarning, we can also suggest to use -W 
always::ResourceWarning in that case.


> I don't agree with this.  You're comparing "-X dev" with a pydebug build of 
> Python, not with a normal Python.

In general, I would like to offer the same experience in "development mode" (-X 
dev) and with a pydebug build.

For ResourceWarning, your rationale only concerns pydebug build, no?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32089>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to