Re: [PATCH] scripts: generate_rust_analyzer.py: avoid FD leak
From: Tamir Duberstein
Date: Tue Jan 27 2026 - 08:44:06 EST
On Tue, Jan 27, 2026 at 8:10 AM Levi Zim <i@xxxxxxxx> wrote:
>
>
> On 1/26/26 10:09 AM, Miguel Ojeda wrote:
> > On Thu, Jan 22, 2026 at 5:44 PM Tamir Duberstein <tamird@xxxxxxxxxx> wrote:
> >>
> >> Use a context manager to avoid leaking file descriptors.
> >
> > This may have been intentionally written like that for simplicity,
> > since I think CPython closes them immediately in practice even if it
> > does not guarantee it (and I think the kernel may be assuming CPython
> > given the version requirement?).
>
> Path.read_text from pathlib would be a better choice for keeping the simplicity
> while ensuring the file is closed.
>
> https://docs.python.org/3/library/pathlib.html#pathlib.Path.read_text
Thanks, I thought this would change semantics because `open` would
default to binary, but it defaults to text. I'll use read_text in v2.
>
> Best regards,
> Levi
>
> > Nevertheless, it is better to be explicit and proper, but it is not
> > urgent, so I would say let's put this in rust-analyzer after the merge
> > window even if you end up considering it a fix.
> >
> > Like in the other one, I don't see the Tested-by from Daniel, so I
> > would suggest taking the chance to double-check that meanwhile too.
> >
> > Thanks!
> >
> > Cheers,
> > Miguel
> >
>