News for hackers. Stuff that matters.
Re:Show HN: Refurb – A tool for refurbishing and modernizing... by rcthompson on Wednesday September 28, 2022 @09:46AM (#33007858)
> it is very clear in this code that a reference to the file isn't leaked

Is it? What if an exception is thrown? See e.g. this SO answer[1]:

> However if an exception is thrown [...] then a reference to the file will be kept as part of the stack trace in the traceback object and the file will not be closed, at least until the next exception is thrown.

So your code, if called from somewhere else inside a try block, leaks a filehandle potentially indefinitely.

[1]: https://stackoverflow.com/a/2404671/125921

There are no comments on this comment yet.