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

GH-95815: Document less specific error for os.remove #99571

Merged
merged 1 commit into from
Nov 21, 2022

Conversation

ronaldoussoren
Copy link
Contributor

@ronaldoussoren ronaldoussoren commented Nov 18, 2022

os.remove can raise PermissionError instead of IsADirectoryError, when the object to be removed is a directory (in particular on macOS).

This reverts a change done in #14262.

os.remove can raise PermissionError instead of IsADirectoryError,
when the object to be removed is a directory (in particular on
macOS).

This reverts a change done in python#14262.
@ronaldoussoren
Copy link
Contributor Author

This PR is the minimal change that makes the documentation reflect reality. An alternative would be to document that the function might raise either IsADirectoryError or PermissionError. I'm not sure which option would be the best fix.

Copy link
Contributor

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

This looks good to me. Documenting the specific subclasses in this case doesn't seem particularly helpful and probably would just lead to people writing less portable code e.g. if they stop reading after seeing IsADirectoryError.

@ronaldoussoren ronaldoussoren merged commit 1cae31d into python:main Nov 21, 2022
@miss-islington
Copy link
Contributor

Thanks @ronaldoussoren for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry @ronaldoussoren, I had trouble checking out the 3.11 backport branch.
Please retry by removing and re-adding the "needs backport to 3.11" label.
Alternatively, you can backport using cherry_picker on the command line.
cherry_picker 1cae31d26ba621f6b1f0656ad3d69a0236338bad 3.11

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 21, 2022
…99571)

os.remove can raise PermissionError instead of IsADirectoryError,
when the object to be removed is a directory (in particular on
macOS).

This reverts a change done in pythonGH-14262.
(cherry picked from commit 1cae31d)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
@bedevere-bot
Copy link

GH-99639 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Nov 21, 2022
@ronaldoussoren ronaldoussoren added 3.11 only security fixes needs backport to 3.11 only security fixes and removed needs backport to 3.11 only security fixes 3.11 only security fixes labels Nov 21, 2022
@miss-islington
Copy link
Contributor

Thanks @ronaldoussoren for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 21, 2022
…99571)

os.remove can raise PermissionError instead of IsADirectoryError,
when the object to be removed is a directory (in particular on
macOS).

This reverts a change done in pythonGH-14262.
(cherry picked from commit 1cae31d)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
@bedevere-bot
Copy link

GH-99641 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Nov 21, 2022
ronaldoussoren added a commit that referenced this pull request Nov 21, 2022
#99641)

GH-95815: Document less specific error for os.remove (GH-99571)

os.remove can raise PermissionError instead of IsADirectoryError,
when the object to be removed is a directory (in particular on
macOS).

This reverts a change done in GH-14262.
(cherry picked from commit 1cae31d)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
ronaldoussoren added a commit that referenced this pull request Nov 21, 2022
#99639)

GH-95815: Document less specific error for os.remove (GH-99571)

os.remove can raise PermissionError instead of IsADirectoryError,
when the object to be removed is a directory (in particular on
macOS).

This reverts a change done in GH-14262.
(cherry picked from commit 1cae31d)


Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants