Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(210)

Unified Diff: Lib/io.py

Issue 3055: combined patches from http://bugs.python.org/issue3187 (Closed) Base URL: http://svn.python.org/view/*checkout*/python/branches/py3k/
Patch Set: One more tweak (fold some long lines) Created 15 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/glob.py ('k') | Lib/posixpath.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Lib/io.py
===================================================================
--- Lib/io.py (revision 66736)
+++ Lib/io.py (working copy)
@@ -82,14 +82,13 @@
def open(file, mode="r", buffering=None, encoding=None, errors=None,
newline=None, closefd=True):
- r"""Open file and return a stream. If the file cannot be opened, an IOError is
- raised.
+ r"""Open file and return a stream. Raise IOError upon failure.
- file is either a string giving the name (and the path if the file
- isn't in the current working directory) of the file to be opened or an
- integer file descriptor of the file to be wrapped. (If a file
- descriptor is given, it is closed when the returned I/O object is
- closed, unless closefd is set to False.)
+ file is either a text or byte string giving the name (and the path
+ if the file isn't in the current working directory) of the file to
+ be opened or an integer file descriptor of the file to be
+ wrapped. (If a file descriptor is given, it is closed when the
+ returned I/O object is closed, unless closefd is set to False.)
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
@@ -180,7 +179,7 @@
opened in a text mode, and for bytes a BytesIO can be used like a file
opened in a binary mode.
"""
- if not isinstance(file, (str, int)):
+ if not isinstance(file, (str, bytes, int)):
raise TypeError("invalid file: %r" % file)
if not isinstance(mode, str):
raise TypeError("invalid mode: %r" % mode)
« no previous file with comments | « Lib/glob.py ('k') | Lib/posixpath.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b