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

Delta Between Two Patch Sets: Lib/io.py

Issue 3055: combined patches from http://bugs.python.org/issue3187 (Closed) SVN Base: http://svn.python.org/view/*checkout*/python/branches/py3k/
Left Patch Set: Number 3 from Victor Created 1 year, 1 month ago , Downloaded from: http://bugs.python.org/file11680/python3_bytes_filename-3.patch
Right Patch Set: One more tweak (fold some long lines) Created 1 year, 1 month 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 """The io module provides the Python interfaces to stream handling. The 1 """The io module provides the Python interfaces to stream handling. The
2 builtin open function is defined in this module. 2 builtin open function is defined in this module.
3 3
4 At the top of the I/O hierarchy is the abstract base class IOBase. It 4 At the top of the I/O hierarchy is the abstract base class IOBase. It
5 defines the basic interface to a stream. Note, however, that there is no 5 defines the basic interface to a stream. Note, however, that there is no
6 seperation between reading and writing to streams; implementations are 6 seperation between reading and writing to streams; implementations are
7 allowed to throw an IOError if they do not support a given operation. 7 allowed to throw an IOError if they do not support a given operation.
8 8
9 Extending IOBase is RawIOBase which deals simply with the reading and 9 Extending IOBase is RawIOBase which deals simply with the reading and
10 writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide 10 writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 """Exception raised when I/O would block on a non-blocking I/O stream.""" 75 """Exception raised when I/O would block on a non-blocking I/O stream."""
76 76
77 def __init__(self, errno, strerror, characters_written=0): 77 def __init__(self, errno, strerror, characters_written=0):
78 IOError.__init__(self, errno, strerror) 78 IOError.__init__(self, errno, strerror)
79 self.characters_written = characters_written 79 self.characters_written = characters_written
80 80
81 81
82 def open(file, mode="r", buffering=None, encoding=None, errors=None, 82 def open(file, mode="r", buffering=None, encoding=None, errors=None,
83 newline=None, closefd=True): 83 newline=None, closefd=True):
84 84
85 r"""Open file and return a stream. If the file cannot be opened, an IOError is 85 r"""Open file and return a stream. Raise IOError upon failure.
86 raised. 86
87 87 file is either a text or byte string giving the name (and the path
88 file is either a string giving the name (and the path if the file 88 if the file isn't in the current working directory) of the file to
89 isn't in the current working directory) of the file to be opened or an 89 be opened or an integer file descriptor of the file to be
90 integer file descriptor of the file to be wrapped. (If a file 90 wrapped. (If a file descriptor is given, it is closed when the
91 descriptor is given, it is closed when the returned I/O object is 91 returned I/O object is closed, unless closefd is set to False.)
92 closed, unless closefd is set to False.)
93 92
94 mode is an optional string that specifies the mode in which the file 93 mode is an optional string that specifies the mode in which the file
95 is opened. It defaults to 'r' which means open for reading in text 94 is opened. It defaults to 'r' which means open for reading in text
96 mode. Other common values are 'w' for writing (truncating the file if 95 mode. Other common values are 'w' for writing (truncating the file if
97 it already exists), and 'a' for appending (which on some Unix systems, 96 it already exists), and 'a' for appending (which on some Unix systems,
98 means that all writes append to the end of the file regardless of the 97 means that all writes append to the end of the file regardless of the
99 current seek position). In text mode, if encoding is not specified the 98 current seek position). In text mode, if encoding is not specified the
100 encoding used is platform dependent. (For reading and writing raw 99 encoding used is platform dependent. (For reading and writing raw
101 bytes use binary mode and leave encoding unspecified.) The available 100 bytes use binary mode and leave encoding unspecified.) The available
102 modes are: 101 modes are:
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 ("\r", "\n"), 2126 ("\r", "\n"),
2128 "\r\n", 2127 "\r\n",
2129 ("\n", "\r\n"), 2128 ("\n", "\r\n"),
2130 ("\r", "\r\n"), 2129 ("\r", "\r\n"),
2131 ("\r", "\n", "\r\n") 2130 ("\r", "\n", "\r\n")
2132 )[self._seennl] 2131 )[self._seennl]
2133 2132
2134 2133
2135 except ImportError: 2134 except ImportError:
2136 StringIO = _StringIO 2135 StringIO = _StringIO
LEFTRIGHT

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