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
4dbf192f
Commit
4dbf192f
authored
Nov 06, 2002
by
Walter Dörwald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add next() and __iter__() methods to StreamReader, StreamReaderWriter
and StreamRecoder. This closes SF bug #634246.
parent
07e14766
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
Lib/codecs.py
Lib/codecs.py
+27
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/codecs.py
View file @
4dbf192f
...
...
@@ -299,6 +299,17 @@ class StreamReader(Codec):
"""
pass
def
next
(
self
):
""" Return the next decoded line from the input stream."""
line
=
self
.
readline
()
if
line
:
return
line
raise
StopIteration
def
__iter__
(
self
):
return
self
def
__getattr__
(
self
,
name
,
getattr
=
getattr
):
...
...
@@ -351,6 +362,14 @@ class StreamReaderWriter:
return
self
.
reader
.
readlines
(
sizehint
)
def
next
(
self
):
""" Return the next decoded line from the input stream."""
return
self
.
reader
.
next
()
def
__iter__
(
self
):
return
self
def
write
(
self
,
data
):
return
self
.
writer
.
write
(
data
)
...
...
@@ -451,6 +470,14 @@ class StreamRecoder:
data
,
bytesencoded
=
self
.
encode
(
data
,
self
.
errors
)
return
data
.
splitlines
(
1
)
def
next
(
self
):
""" Return the next decoded line from the input stream."""
return
self
.
reader
.
next
()
def
__iter__
(
self
):
return
self
def
write
(
self
,
data
):
data
,
bytesdecoded
=
self
.
decode
(
data
,
self
.
errors
)
...
...
Misc/NEWS
View file @
4dbf192f
...
...
@@ -362,6 +362,9 @@ Extension modules
Library
-------
-
StreamReader
,
StreamReaderWriter
and
StreamRecoder
in
the
codecs
modules
are
iterators
now
.
-
gzip
.
py
now
handles
files
exceeding
2
GB
.
Files
over
4
GB
also
work
now
(
provided
the
OS
supports
it
,
and
Python
is
configured
with
large
file
support
),
but
in
that
case
the
underlying
gzip
file
format
can
...
...
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