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.

Author vstinner
Recipients jbfzs, r.david.murray, rhettinger, serhiy.storchaka, vstinner, Александр Карпинский
Date 2017-11-21.15:31:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1511278274.93.0.213398074469.issue27535@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2017-11-21 15:31:14vstinnersetrecipients: + vstinner, rhettinger, r.david.murray, serhiy.storchaka, Александр Карпинский, jbfzs
2017-11-21 15:31:14vstinnersetmessageid: <1511278274.93.0.213398074469.issue27535@psf.upfronthosting.co.za>
2017-11-21 15:31:14vstinnerlinkissue27535 messages
2017-11-21 15:31:14vstinnercreate