Op 14-07-2026 om 16:05 schreef Random832:
On Tue, Jul 14, 2026, at 04:46, Alan Gauld via Python-list wrote:
Bottom line: I think that having a FileReadOnly exception is a good
idea because it more precisely reports the problem and gives users a
direction for fixing it, whereas reporting permissions error doesn't.
I don't disagree with this however. The more specific an error
the better.
The problem is that if Python wants to provide information that isn't provided
in the error code from the operating system, it has to do a complex and
potentially expensive root cause analysis on its own, checking for all the
possible conditions that could have caused the error. Do you do this every time
there is an error, or only when requested? having it be a subclass rather than
a property makes 'only when requested' more difficult to design.
And what if a secondary error is encounted while doing the analysis [e.g. you
can't stat the file]? And should we also differentiate permission errors on
unix that are caused by a missing 'execute' bit somewhere in the middle of the
directory path, by checking each level of the path?
Even worse is that the circumstances can potentially change during that
root cause analysis. Trying to do such a thing opens up the possibility
to generate flat out wrong information. That's much worse than
information that is maybe a little too vague.
This is not something that can be changed on the Python side. The best
Python can do is report the error from the operating system.
--
"'How to Stop Worrying and Learn to Love the Internet':
1) everything that’s already in the world when you’re born is just
normal;
2) anything that gets invented between then and before you turn
thirty is incredibly exciting and creative and with any luck you can
make a career out of it;
3) anything that gets invented after you’re thirty is against the
natural order of things and the beginning of the end of civilisation
as we know it until it’s been around for about ten years when it
gradually turns out to be alright really.
Apply this list to movies, rock music, word processors and mobile
phones to work out how old you are."
-- Douglas Adams
--
https://mail.python.org/mailman3//lists/python-list.python.org