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
c06634ac
Commit
c06634ac
authored
Feb 02, 2014
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #20435: Fix _pyio.StringIO.getvalue() to take into account newline translation settings.
parent
1964d5bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
Lib/_pyio.py
Lib/_pyio.py
+7
-1
Lib/test/test_memoryio.py
Lib/test/test_memoryio.py
+9
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/_pyio.py
View file @
c06634ac
...
...
@@ -1997,7 +1997,13 @@ class StringIO(TextIOWrapper):
def
getvalue
(
self
):
self
.
flush
()
return
self
.
buffer
.
getvalue
().
decode
(
self
.
_encoding
,
self
.
_errors
)
decoder
=
self
.
_decoder
or
self
.
_get_decoder
()
old_state
=
decoder
.
getstate
()
decoder
.
reset
()
try
:
return
decoder
.
decode
(
self
.
buffer
.
getvalue
(),
final
=
True
)
finally
:
decoder
.
setstate
(
old_state
)
def
__repr__
(
self
):
# TextIOWrapper tells the encoding in its repr. In StringIO,
...
...
Lib/test/test_memoryio.py
View file @
c06634ac
...
...
@@ -537,6 +537,7 @@ class TextIOTestMixin:
self
.
assertEqual
(
3
,
memio
.
write
(
"c
\
r
d"
))
memio
.
seek
(
0
)
self
.
assertEqual
(
memio
.
read
(),
"a
\
n
b
\
n
c
\
n
d"
)
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
n
b
\
n
c
\
n
d"
)
memio
=
self
.
ioclass
(
"a
\
r
\
n
b"
,
newline
=
None
)
self
.
assertEqual
(
memio
.
read
(
3
),
"a
\
n
b"
)
...
...
@@ -548,6 +549,7 @@ class TextIOTestMixin:
self
.
assertEqual
(
memio
.
read
(
4
),
"a
\
n
b
\
r
"
)
self
.
assertEqual
(
memio
.
read
(
2
),
"
\
n
c"
)
self
.
assertEqual
(
memio
.
read
(
1
),
"
\
r
"
)
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
n
b
\
r
\
n
c
\
r
d"
)
memio
=
self
.
ioclass
(
newline
=
""
)
self
.
assertEqual
(
2
,
memio
.
write
(
"a
\
n
"
))
self
.
assertEqual
(
2
,
memio
.
write
(
"b
\
r
"
))
...
...
@@ -567,6 +569,9 @@ class TextIOTestMixin:
self
.
assertEqual
(
memio
.
read
(),
"a
\
r
b
\
r
\
r
c
\
r
d"
)
memio
.
seek
(
0
)
self
.
assertEqual
(
list
(
memio
),
[
"a
\
r
"
,
"b
\
r
"
,
"
\
r
"
,
"c
\
r
"
,
"d"
])
memio
.
seek
(
0
)
self
.
assertEqual
(
memio
.
readlines
(),
[
"a
\
r
"
,
"b
\
r
"
,
"
\
r
"
,
"c
\
r
"
,
"d"
])
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
r
b
\
r
\
r
c
\
r
d"
)
def
test_newline_crlf
(
self
):
# newline="\r\n"
...
...
@@ -574,11 +579,15 @@ class TextIOTestMixin:
self
.
assertEqual
(
memio
.
read
(),
"a
\
r
\
n
b
\
r
\
r
\
n
c
\
r
d"
)
memio
.
seek
(
0
)
self
.
assertEqual
(
list
(
memio
),
[
"a
\
r
\
n
"
,
"b
\
r
\
r
\
n
"
,
"c
\
r
d"
])
memio
.
seek
(
0
)
self
.
assertEqual
(
memio
.
readlines
(),
[
"a
\
r
\
n
"
,
"b
\
r
\
r
\
n
"
,
"c
\
r
d"
])
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
r
\
n
b
\
r
\
r
\
n
c
\
r
d"
)
def
test_issue5265
(
self
):
# StringIO can duplicate newlines in universal newlines mode
memio
=
self
.
ioclass
(
"a
\
r
\
n
b
\
r
\
n
"
,
newline
=
None
)
self
.
assertEqual
(
memio
.
read
(
5
),
"a
\
n
b
\
n
"
)
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
n
b
\
n
"
)
class
PyStringIOTest
(
MemoryTestMixin
,
MemorySeekTestMixin
,
...
...
Misc/NEWS
View file @
c06634ac
...
...
@@ -38,6 +38,9 @@ Core and Builtins
Library
-------
- Issue #20435: Fix _pyio.StringIO.getvalue() to take into account newline
translation settings.
- Issue #20288: fix handling of invalid numeric charrefs in HTMLParser.
- Issue #19456: ntpath.join() now joins relative paths correctly when a drive
...
...
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