Re: Read-only error

2026-07-13 Thread Rob Cliffe via Python-list
Further thoughts:     I get the impression (though no-one has quite explicitly stated it) that the developers of Python think it is undesirable for Python to look for further information than that provided by the OS error code. Which makes sense. In which case my suggestion would be better direc

Re: Read-only error

2026-07-13 Thread Chris Angelico via Python-list
On Tue, 14 Jul 2026 at 02:18, Left Right wrote: > > > 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 s

Re: Read-only error

2026-07-13 Thread Chris Angelico via Python-list
On Tue, 14 Jul 2026 at 02:25, Rob Cliffe via Python-list wrote: > It seems to me to be useful to distinguish between > cases where the attempt fails because the file is owned by someone else > the case where the attempt only fails because the file is read-only. > We already have a FileEx

Re: Read-only error

2026-07-13 Thread Rob Cliffe via Python-list
On 13/07/2026 16:29, Chris Angelico via Python-list wrote: On Tue, 14 Jul 2026 at 01:18, Rob Cliffe via Python-list 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

Re: Read-only error

2026-07-13 Thread Mats Wichmann
On 7/13/26 08:59, Rob Cliffe via Python-list 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

Re: Read-only error

2026-07-13 Thread Left Right via Python-list
> 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. > [...] > The error says, yo

Re: Read-only error

2026-07-13 Thread Left Right via Python-list
Oh, fair enough. I made the directory write-only. My bad. So, here's the actual behavior: * Cannot create files in a read-only directory. * Can modify files (as in, file metadata s.a. ownership) in the read-only directory. * Can mount volumes in the read-only directory (as well as unmount). * Can

Re: Read-only error

2026-07-13 Thread Chris Angelico via Python-list
On Tue, 14 Jul 2026 at 03:40, Left Right wrote: > To comment on how read-only directory behaves on Linux: it doesn't > work the way you suggest it should. At least not on Ext4 (I didn't try > other filesystems). Here's what actually happens: > > * You can create files in a read-only directory. Er

Re: Read-only error

2026-07-13 Thread Chris Angelico via Python-list
On Tue, 14 Jul 2026 at 04:20, Left Right wrote: > > Oh, fair enough. I made the directory write-only. My bad. So, here's > the actual behavior: > > * Cannot create files in a read-only directory. > * Can modify files (as in, file metadata s.a. ownership) in the > read-only directory. > * Can mount

Re: Read-only error

2026-07-13 Thread Random832
On Sun, Jul 12, 2026, at 21:13, Rob Cliffe via Python-list wrote: >                     if st.st_mode & 0x92 == 0: >                         errStr = 'File is read-only' I feel like it should probably be mentioned that the st_mode value returned on windows is mostly synthetic, and while it does

Re: Read-only error

2026-07-13 Thread Random832
On Mon, Jul 13, 2026, at 12:36, Chris Angelico via Python-list wrote: >> In the same way, surely it is useful to have more information >> about why trying to delete a file failed. > > Only if the OS provides it. this is why I suggested it might be worthwhile to add an exception type for "file cou

Re: Read-only error

2026-07-13 Thread Rob Cliffe via Python-list
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

Re: Read-only error

2026-07-13 Thread Chris Angelico via Python-list
On Tue, 14 Jul 2026 at 01:18, Rob Cliffe via Python-list 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. > >> Currentl