-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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-37346: Use OSError subclasses in os documentation #14262
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,9 +36,9 @@ Notes on the availability of these functions: | |
|
||
.. note:: | ||
|
||
All functions in this module raise :exc:`OSError` in the case of invalid or | ||
inaccessible file names and paths, or other arguments that have the correct | ||
type, but are not accepted by the operating system. | ||
All functions in this module raise :exc:`OSError` (or subclasses thereof) in | ||
the case of invalid or inaccessible file names and paths, or other arguments | ||
that have the correct type, but are not accepted by the operating system. | ||
|
||
.. exception:: error | ||
|
||
|
@@ -1891,8 +1891,8 @@ features: | |
directories you can set the umask before invoking :func:`makedirs`. The | ||
file permission bits of existing parent directories are not changed. | ||
|
||
If *exist_ok* is ``False`` (the default), an :exc:`OSError` is raised if the | ||
target directory already exists. | ||
If *exist_ok* is ``False`` (the default), an :exc:`FileExistsError` is | ||
raised if the target directory already exists. | ||
|
||
.. note:: | ||
|
||
|
@@ -2045,8 +2045,8 @@ features: | |
|
||
.. function:: remove(path, *, dir_fd=None) | ||
|
||
Remove (delete) the file *path*. If *path* is a directory, :exc:`OSError` is | ||
raised. Use :func:`rmdir` to remove directories. | ||
Remove (delete) the file *path*. If *path* is a directory, an | ||
:exc:`IsADirectoryError` is raised. Use :func:`rmdir` to remove directories. | ||
|
||
This function can support :ref:`paths relative to directory descriptors | ||
<dir_fd>`. | ||
|
@@ -2083,13 +2083,19 @@ features: | |
|
||
.. function:: rename(src, dst, *, src_dir_fd=None, dst_dir_fd=None) | ||
|
||
Rename the file or directory *src* to *dst*. If *dst* is a directory, | ||
:exc:`OSError` will be raised. On Unix, if *dst* exists and is a file, it will | ||
be replaced silently if the user has permission. The operation may fail on some | ||
Unix flavors if *src* and *dst* are on different filesystems. If successful, | ||
the renaming will be an atomic operation (this is a POSIX requirement). On | ||
Windows, if *dst* already exists, :exc:`OSError` will be raised even if it is a | ||
file. | ||
Rename the file or directory *src* to *dst*. If *dst* exists, the operation | ||
will fail with an :exc:`OSError` subclass in a number of cases: | ||
|
||
On Windows, if *dst* exists a :exc:`FileExistsError` is always raised. | ||
|
||
On Unix, if *src* is a file and *dst* is a directory or vice-versa, anq:q | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bpo-37554 points out the errant vim exit at the end of this line :) |
||
:exc:`IsADirectoryError` or a :exc:`NotADirectoryError` will be raised | ||
respectively. If both are directories and *dst* is empty, *dst* will be | ||
silently replaced. If *dst* is a non-empty directory, an :exc:`OSError` | ||
is raised. If both are files, *dst* it will be replaced silently if the user | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double space after stop. |
||
has permission. The operation may fail on some Unix flavors if *src* and | ||
*dst* are on different filesystems. If successful, the renaming will be an | ||
atomic operation (this is a POSIX requirement). | ||
|
||
This function can support specifying *src_dir_fd* and/or *dst_dir_fd* to | ||
supply :ref:`paths relative to directory descriptors <dir_fd>`. | ||
|
@@ -2138,9 +2144,10 @@ features: | |
|
||
.. function:: rmdir(path, *, dir_fd=None) | ||
|
||
Remove (delete) the directory *path*. Only works when the directory is | ||
empty, otherwise, :exc:`OSError` is raised. In order to remove whole | ||
directory trees, :func:`shutil.rmtree` can be used. | ||
Remove (delete) the directory *path*. If the directory does not exist or is | ||
not empty, an :exc:`FileNotFoundError` or an :exc:`OSError` is raised | ||
respectively. In order to remove whole directory trees, | ||
:func:`shutil.rmtree` can be used. | ||
|
||
This function can support :ref:`paths relative to directory descriptors | ||
<dir_fd>`. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double space after stop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mangrisano, Thanks for taking the time to review this PR. One or two spaces after a period are both acceptable in Python documentation [devguide reference].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, thank for clarifying me that.