Message306652
> The best way to fix this is excluding file name from warning message. As a result, the message for every file will be the same and warnings registry will not grow.
Your warning comes from the io module which uses the message: "unclosed file %r" % file.
I dislike the idea of removing the filename from this warning message, since the filename is very useful to identify where the bug comes from.
Different things are discussed here:
* First of all, if an application is correctly written, ResourceWarning is not emitted, and so Python doesn't leak memory
* Using the "always" action, ResourceWarning doesn't leak neither.
* Using a different action like "default", ResourceWarning does leak memory in hidden warning registries.
While I don't see how we can avoid "leaking memory" (growing the registry) for actions like "once", I think that it's ok to don't touch the registry for the "ignore" action. So at least, an application ignoring ResourceWarning will not leak anymore.
But it will still "leak" when you display ResourceWarning warnings with an action different than "always". In this case, IMHO the root issue is more the code which doesn't close the resource, than Python itself. |
|
Date |
User |
Action |
Args |
2017-11-21 15:31:14 | vstinner | set | recipients:
+ vstinner, rhettinger, r.david.murray, serhiy.storchaka, Александр Карпинский, jbfzs |
2017-11-21 15:31:14 | vstinner | set | messageid: <1511278274.93.0.213398074469.issue27535@psf.upfronthosting.co.za> |
2017-11-21 15:31:14 | vstinner | link | issue27535 messages |
2017-11-21 15:31:14 | vstinner | create | |
|