Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-32847: Add DirectoryNotEmptyError subclass of OSError #15496

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

nanjekyejoannah
Copy link
Contributor

@nanjekyejoannah nanjekyejoannah commented Aug 26, 2019

Add DirectoryNotEmptyError subclass of OSError .

https://bugs.python.org/issue32847

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, Error should be added by alphabetic order!

Include/pyerrors.h Outdated Show resolved Hide resolved
Lib/test/test_exception_hierarchy.py Outdated Show resolved Hide resolved
@nanjekyejoannah
Copy link
Contributor Author

@corona10 , I will fix that and other things on this PR. Thanks.

Doc/library/exceptions.rst Outdated Show resolved Hide resolved
Lib/test/test_exceptions.py Outdated Show resolved Hide resolved
Lib/test/test_exceptions.py Outdated Show resolved Hide resolved
@@ -1170,6 +1170,12 @@ def inner():
self.fail("RecursionError not raised")
self.assertEqual(wr(), None)

def test_errno_ENOTEMPTY(self):
with self.assertRaises(OSError) as cm:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, why not expecting DirectoryNotEmptyError?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried but I can't assert DirectoryNotEmptyError here. Am I missing something? I will pick it later as a subclass of OSError.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the test fails, it sounds like there is a bug in your PR. Moreover, "with self.assertRaises(OSError) as cm:" should only surround "os.rmdir(dirname)".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will investigate.

@nanjekyejoannah
Copy link
Contributor Author

I have done requested changes @vstinner PTAL.

@vstinner
Copy link
Member

vstinner commented Sep 6, 2019

@pitrou: So, do you think that it's worth it to add DirectoryNotEmptyError for ENOTEMPTY?

@nanjekyejoannah: Is ENOTEMPTY available on Windows, Linux, FreeBSD and macOS at least?

@pitrou
Copy link
Member

pitrou commented Sep 9, 2019

@nanjekyejoannah: Is ENOTEMPTY available on Windows, Linux, FreeBSD and macOS at least?

I would like to echo this question. If ENOTEMPTY isn't available, or isn't actually returned in any non-exotic situation, then there's no need adding an Exception subclass for it.

@matrixise matrixise self-assigned this Sep 11, 2019
@nanjekyejoannah
Copy link
Contributor Author

@pitrou: So, do you think that it's worth it to add DirectoryNotEmptyError for ENOTEMPTY?

@nanjekyejoannah: Is ENOTEMPTY available on Windows, Linux, FreeBSD and macOS at least?

@vstinner @pitrou So AFAIK, ENOTEMPTY is available on Linux and MacOS (I confirmed with @ned-deily ). On windows am told by @zooba that they updated the exceptions mapping table in light of this issue to return this in Cpython. I think it is worth implementing this Exception subclass IMHO. Happy to hear any contrary opinions.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be put in the comfy chair!

@csabella
Copy link
Contributor

csabella commented Feb 4, 2020

@vstinner made a comment on the bug tracker suggesting to the close this issue. Were there any additional opinions or should it be closed?

@ned-deily
Copy link
Member

@vstinner made a comment on the bug tracker suggesting to the close this issue. Were there any additional opinions or should it be closed?

@warsaw opened the issue. Barry?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.