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
49fd1077
Commit
49fd1077
authored
Apr 13, 2000
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M.-A. Lemburg <mal@lemburg.com>:
Added more documentation. Clarified some existing comments.
parent
4e998bc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
4 deletions
+40
-4
Lib/codecs.py
Lib/codecs.py
+40
-4
No files found.
Lib/codecs.py
View file @
49fd1077
...
...
@@ -231,10 +231,13 @@ class StreamReader(Codec):
""" Read one line from the input stream and return the
decoded data.
Note: Unlike the .readlines() method, line breaking must
be implemented by the underlying stream's .readline()
method -- there is currently no support for line breaking
using the codec decoder due to lack of line buffering.
Note: Unlike the .readlines() method, this method inherits
the line breaking knowledge from the underlying stream's
.readline() method -- there is currently no support for
line breaking using the codec decoder due to lack of line
buffering. Sublcasses should however, if possible, try to
implement this method using their own knowledge of line
breaking.
size, if given, is passed as size argument to the stream's
.readline() method.
...
...
@@ -288,6 +291,14 @@ class StreamReader(Codec):
class
StreamReaderWriter
:
""" StreamReaderWriter instances allow wrapping streams which
work in both read and write modes.
The design is such that one can use the factory functions
returned by the codec.lookup() function to contruct the
instance.
"""
# Optional attributes set by the file wrappers below
encoding
=
'unknown'
...
...
@@ -346,6 +357,21 @@ class StreamReaderWriter:
class
StreamRecoder
:
""" StreamRecoder instances provide a frontend - backend
view of encoding data.
They use the complete set of APIs returned by the
codecs.lookup() function to implement their task.
Data written to the stream is first decoded into an
intermediate format (which is dependent on the given codec
combination) and then written to the stream using an instance
of the provided Writer class.
In the other direction, data is read from the stream using a
Reader instance and then return encoded data to the caller.
"""
# Optional attributes set by the file wrappers below
data_encoding
=
'unknown'
file_encoding
=
'unknown'
...
...
@@ -452,6 +478,11 @@ def open(filename, mode, encoding=None, errors='strict', buffering=1):
buffering has the same meaning as for the builtin open() API.
It defaults to line buffered.
The returned wrapped file object provides an extra attribute
.encoding which allows querying the used encoding. This
attribute is only available if an encoding was specified as
parameter.
"""
if
encoding
is
not
None
and
\
'b'
not
in
mode
:
...
...
@@ -488,6 +519,11 @@ def EncodedFile(file, data_encoding, file_encoding=None, errors='strict'):
data_encoding and file_encoding are added to the wrapped file
object as attributes .data_encoding and .file_encoding resp.
The returned wrapped file object provides two extra attributes
.data_encoding and .file_encoding which reflect the given
parameters of the same name. The attributes can be used for
introspection by Python programs.
"""
if
file_encoding
is
None
:
file_encoding
=
data_encoding
...
...
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