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
23db935b
Commit
23db935b
authored
Jun 29, 2018
by
Zackery Spytz
Committed by
Serhiy Storchaka
Jun 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918)
parent
bda9c3ea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
0 deletions
+19
-0
Lib/_pyio.py
Lib/_pyio.py
+1
-0
Lib/test/test_io.py
Lib/test/test_io.py
+11
-0
Misc/NEWS.d/next/Core and Builtins/2017-10-07-10-13-15.bpo-25862.FPYBA5.rst
...ore and Builtins/2017-10-07-10-13-15.bpo-25862.FPYBA5.rst
+2
-0
Modules/_io/textio.c
Modules/_io/textio.c
+5
-0
No files found.
Lib/_pyio.py
View file @
23db935b
...
...
@@ -2149,6 +2149,7 @@ class TextIOWrapper(TextIOBase):
self
.
buffer
.
write
(
b
)
if
self
.
_line_buffering
and
(
haslf
or
"
\
r
"
in
s
):
self
.
flush
()
self
.
_set_decoded_chars
(
''
)
self
.
_snapshot
=
None
if
self
.
_decoder
:
self
.
_decoder
.
reset
()
...
...
Lib/test/test_io.py
View file @
23db935b
...
...
@@ -3549,6 +3549,17 @@ class TextIOWrapperTest(unittest.TestCase):
expected
=
'linesep'
+
os
.
linesep
+
'LF
\
n
LF
\
n
CR
\
r
CRLF
\
r
\
n
'
self
.
assertEqual
(
txt
.
detach
().
getvalue
().
decode
(
'ascii'
),
expected
)
def
test_issue25862
(
self
):
# Assertion failures occurred in tell() after read() and write().
t
=
self
.
TextIOWrapper
(
self
.
BytesIO
(
b'test'
),
encoding
=
'ascii'
)
t
.
read
(
1
)
t
.
read
()
t
.
tell
()
t
=
self
.
TextIOWrapper
(
self
.
BytesIO
(
b'test'
),
encoding
=
'ascii'
)
t
.
read
(
1
)
t
.
write
(
'x'
)
t
.
tell
()
class
MemviewBytesIO
(
io
.
BytesIO
):
'''A BytesIO object whose read method returns memoryviews
...
...
Misc/NEWS.d/next/Core and Builtins/2017-10-07-10-13-15.bpo-25862.FPYBA5.rst
0 → 100644
View file @
23db935b
Fix assertion failures in the ``tell()`` method of ``io.TextIOWrapper``.
Patch by Zackery Spytz.
Modules/_io/textio.c
View file @
23db935b
...
...
@@ -694,6 +694,9 @@ typedef struct
PyObject
*
dict
;
}
textio
;
static
void
textiowrapper_set_decoded_chars
(
textio
*
self
,
PyObject
*
chars
);
/* A couple of specialized cases in order to bypass the slow incremental
encoding methods for the most popular encodings. */
...
...
@@ -1606,6 +1609,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text)
Py_DECREF
(
ret
);
}
textiowrapper_set_decoded_chars
(
self
,
NULL
);
Py_CLEAR
(
self
->
snapshot
);
if
(
self
->
decoder
)
{
...
...
@@ -1835,6 +1839,7 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
if
(
result
==
NULL
)
goto
fail
;
textiowrapper_set_decoded_chars
(
self
,
NULL
);
Py_CLEAR
(
self
->
snapshot
);
return
result
;
}
...
...
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