Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
87c0bebe
Commit
87c0bebe
authored
13 years ago
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Plain Diff
merge heads.
parents
44795773
512d54fe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
12 deletions
+13
-12
Doc/library/io.rst
Doc/library/io.rst
+6
-6
Doc/whatsnew/3.3.rst
Doc/whatsnew/3.3.rst
+3
-2
Lib/_pyio.py
Lib/_pyio.py
+1
-1
Modules/_io/fileio.c
Modules/_io/fileio.c
+3
-3
No files found.
Doc/library/io.rst
View file @
87c0bebe
...
...
@@ -472,12 +472,12 @@ Raw File I/O
to which the resulting :class:`FileIO` object will give access.
The *mode* can be ``'r'``, ``'w'``, ``'x'`` or ``'a'`` for reading
(default), writing,
creating or appending. The file will be created if it
doesn't exist when opened for writing or appending; it will be truncated
when opened for writing. :exc:`FileExistsError` will be raised if it already
exists when opened for creating. Opening a file for creating implies
writing, so this mode behaves in a similar way to ``'w'``. Add a ``'+'`` to
the mode to allow simultaneous reading and writing.
(default), writing,
exclusive creation or appending. The file will be
created if it doesn't exist when opened for writing or appending; it will be
truncated when opened for writing. :exc:`FileExistsError` will be raised if
it already exists when opened for creating. Opening a file for creating
implies writing, so this mode behaves in a similar way to ``'w'``. Add a
``'+'`` to
the mode to allow simultaneous reading and writing.
The :meth:`read` (when called with a positive argument), :meth:`readinto`
and :meth:`write` methods on this class will only make one system call.
...
...
This diff is collapsed.
Click to expand it.
Doc/whatsnew/3.3.rst
View file @
87c0bebe
...
...
@@ -427,8 +427,9 @@ parameter to control parameters of the secure channel.
io
--
The :func:`~io.open` function has a new ``'x'`` mode that can be used to create
a new file, and raise a :exc:`FileExistsError` if the file already exists.
The :func:`~io.open` function has a new ``'x'`` mode that can be used to
exclusively create a new file, and raise a :exc:`FileExistsError` if the file
already exists. It is based on the C11 'x' mode to fopen().
(Contributed by David Townshend in :issue:`12760`)
...
...
This diff is collapsed.
Click to expand it.
Lib/_pyio.py
View file @
87c0bebe
...
...
@@ -41,7 +41,7 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
mode is an optional string that specifies the mode in which the file is
opened. It defaults to 'r' which means open for reading in text mode. Other
common values are 'w' for writing (truncating the file if it already
exists), 'x' for
creating and writing to
a new file, and 'a' for appending
exists), 'x' for
exclusive creation of
a new file, and 'a' for appending
(which on some Unix systems, means that all writes append to the end of the
file regardless of the current seek position). In text mode, if encoding is
not specified the encoding used is platform dependent. (For reading and
...
...
This diff is collapsed.
Click to expand it.
Modules/_io/fileio.c
View file @
87c0bebe
...
...
@@ -1066,9 +1066,9 @@ PyDoc_STRVAR(fileio_doc,
"file(name: str[, mode: str][, opener: None]) -> file IO object
\n
"
"
\n
"
"Open a file. The mode can be 'r', 'w', 'x' or 'a' for reading (default),
\n
"
"writing,
creating or appending. The file will be created if it doesn'
t
\n
"
"
exist when opened for writing or appending; it will be truncated when
\n
"
"opened for writing. A `FileExistsError` will be raised if it already
\n
"
"writing,
exclusive creation or appending. The file will be created if i
t
\n
"
"
doesn't exist when opened for writing or appending; it will be truncated
\n
"
"
when
opened for writing. A `FileExistsError` will be raised if it already
\n
"
"exists when opened for creating. Opening a file for creating implies
\n
"
"writing so this mode behaves in a similar way to 'w'.Add a '+' to the mode
\n
"
"to allow simultaneous reading and writing. A custom opener can be used by
\n
"
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment