On Tue, 14 Jul 2026 at 01:18, Rob Cliffe via Python-list
<[email protected]> wrote:
>
> Thanks for your reply, Random.
>
> On 13/07/2026 06:44, Random832 wrote:
> > On Sun, Jul 12, 2026, at 21:13, Rob Cliffe via Python-list wrote:
> >> It seems to be that it would be useful to have a FileReadOnly error.
> >> Currently trying to delete a read-only file raises a PermissionError,
> >> which not especially informative, and arguably even misleading.
> > First of all, how is it misleading?
> It is "arguably misleading" in that it suggests - at least to me - that
> the caller does not have the required permissions to delete the file.
> Which is likely not the case.

If it's raising an error, then yes, at the moment, the caller does not
have the required permissions to delete the file. If you *do* have
permission to delete the file, even if it's read only, then you won't
get the error. I'm not sure what the conflict is here.

Maybe you have permission to change the permissions, but that's not
the same thing. You might also have permission to use "sudo", or to
pop up an authentication prompt, or something, but again, that's
outside the scope of a simple error.

The error says, you don't have permission to do that. Which is a fact.

> >   Second, there's no underlying difference in the error reported by the OS, 
> > so all of the same checking logic you describe below would have to be done 
> > internally.
> Exactly.  And it could be done (by someone more knowledgeable than I) in
> a manner independent of the OS or the filing system.
> Removing the need to reinvent - and debug - the wheel.

Why though? How often is it fundamentally relevant that the particular
permissions error is "the directory is read-only but owned by you",
and how often is something ELSE relevant instead? Python is not HQ9+
and does not give you primitives to do the exact thing you personally
happen to want to do; it gives you tools that you can build into
whatever you need.

Of course, you're welcome to submit a PR and wait for a response. Even
if it gets accepted, you then have to wait until the next release to
get it added to the language. Or you could build your own Python from
source with whatever features you feel like adding. I'm sure both of
those options are far easier than, yaknow, just writing the logic you
need.

ChrisA
-- 
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to