[issue32847] Add DirectoryNotEmptyError subclass of OSError

2018-02-14 Thread Barry A. Warsaw

New submission from Barry A. Warsaw :

I just ran across errno 39 (Directory not empty) when using Path.rename(newdir) 
when newdir already existed and was not empty.  I realized that OSError 
exceptions don't have a DirectoryNotEmptyError subclass.  Maybe we should add 
one?

Probably not important or common enough to add for 3.7 given we're in beta now.

--
messages: 312192
nosy: barry
priority: normal
severity: normal
status: open
title: Add DirectoryNotEmptyError subclass of OSError
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32847] Add DirectoryNotEmptyError subclass of OSError

2019-08-25 Thread Joannah Nanjekye


Change by Joannah Nanjekye :


--
keywords: +patch
pull_requests: +15186
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15496

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32847] Add DirectoryNotEmptyError subclass of OSError

2019-08-26 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +pitrou
versions: +Python 3.9 -Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32847] Add DirectoryNotEmptyError subclass of OSError

2019-08-29 Thread STINNER Victor


STINNER Victor  added the comment:

> Maybe we should add one?

I don't think that we need to add an *builtin* exception for every single 
possible errno. On Linux with Python 3.7, I count 133 different error numbers:

>>> len([name for name in dir(errno) if name.startswith("E")])
133

PEP 3151 explains the rationale for added OSError subclasses.

I think that we should focus on the most common ones, especially the ones which 
are available on all platforms.

I have no opinion about "errno 39 (Directory not empty)". Is it a "common" 
error?

--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32847] Add DirectoryNotEmptyError subclass of OSError

2019-08-29 Thread Eryk Sun


Eryk Sun  added the comment:

> I have no opinion about "errno 39 (Directory not empty)". 
> Is it a "common" error?

Python's code base never specifically handles ENOTEMPTY. On the other hand, in 
terms of basic operations on files and directories, I think implementing 
DirectoryNotEmptyError follows naturally from the existing set: 
FileNotFoundError, FileExistsError, NotADirectoryError, and IsADirectoryError.

--
nosy: +eryksun

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32847] Add DirectoryNotEmptyError subclass of OSError

2019-08-29 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

According to POSIX, the only system calls that can fail with ENOTEMPTY are 
rmdir(), rename() and unlinkat().

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32847] Add DirectoryNotEmptyError subclass of OSError

2019-08-29 Thread Joannah Nanjekye


Change by Joannah Nanjekye :


--
nosy: +nanjekyejoannah

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32847] Add DirectoryNotEmptyError subclass of OSError

2019-09-12 Thread STINNER Victor


STINNER Victor  added the comment:

Copy of my comment on the review:
https://github.com/python/cpython/pull/15496#pullrequestreview-287311626

I'm not excited by adding a new builtin symbol: IMHO this module already exists 
too many symbols.

I'm not convinced that it's worth it. There is exactly 0 line of code in 
CPython code base which expects ENOTEMPTY errno. So it looks like an artifical 
use case.

I recall that when PEP 3151 was implemented, the implementation replaced a lot 
of code using "except OSError as exc: if exc.errno == XXX: ... else: raise" 
with "except : ..." which was neat.

But again, I don't see any usage of ENOTEMPTY in the Python stdlib.

Are you aware of 3rd party code expecting ENOTEMPTY? How many projects?

Adding a builtin symbol is a significant change, it should be well motived.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32847] Add DirectoryNotEmptyError subclass of OSError

2019-09-12 Thread STINNER Victor


STINNER Victor  added the comment:

> Python's code base never specifically handles ENOTEMPTY.

Right, so this use case looks artificial to me.


> On the other hand, in terms of basic operations on files and directories, I 
> think implementing DirectoryNotEmptyError follows naturally from the existing 
> set: FileNotFoundError, FileExistsError, NotADirectoryError, and 
> IsADirectoryError.

Again, I consider that we must not add one exception per errno, since the 
Python errno module contains 133 error codes on Linux. Many are very rare and 
don't deserve to add a new symbol to the builtins module.

I suggest to close this issue.

If later someone wants to get DirectoryNotEmptyError, please open a new issue 
with statistics of how many 3rd party projects use ENOTEMPTY.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com