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.
  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.
Another battery included in the Python kit.
Of course there would be a performance hit.
But only when a PermissionError is raised.
I would think (admittedly without evidence) that in the majority of cases this doesn't matter.
Best wishes
Rob Cliffe.

It might be worthwhile to have a separate error condition for windows *sharing* errors 
i.e. file cannot be opened/deleted/etc because another program has it open - which is a 
separate error code in the OS - but that's maybe a separate discussion. It might also be 
worthwhile to have a "delete harder" option in os.remove to have it take care 
of removing the readonly attribute for you on windows [but it probably should not change 
the directory permissions, only the file permissions, and this may be hard to explain in 
documentation]

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

Reply via email to