[issue35611] open doesn't call IncrementalEncoder with final=True

2019-01-04 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35611] open doesn't call IncrementalEncoder with final=True

2018-12-29 Thread Martin Panter

Martin Panter  added the comment:

FWIW this happens with the built-in IDNA codec, and Amaury gave a demonstration 
under .

I don’t think the “TextIOWrapper.flush” method should use final=True, but 
“close” and “detach” probably should.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35611] open doesn't call IncrementalEncoder with final=True

2018-12-28 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
assignee:  -> lemburg
nosy: +doerwalter, lemburg

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35611] open doesn't call IncrementalEncoder with final=True

2018-12-28 Thread David Haney


New submission from David Haney :

The implementation of open relies on a codecs' IncrementalEncoder, however it 
never calls `encode` with final=True. This appears to violate the documentation 
for IncrementalEncoder.encode which states that the last call to encode _must_ 
set final=True.

The attached test case demonstrates this behavior. A codec "delayed" is 
implemented that holds the last encoded string until the next call to `encode`, 
at which point it returns the encoded string. When final=True, both the 
previous and current string are returned.

When `codecs.iterencode` is used to encode a sequence of strings, the encode 
function is called for each element in the sequence, with final=False. encode 
is then called a final time with an empty string and final=True.

When `open` is used to open a file stream for the encoding, each call to 
`write` calls `encode` with final=False, however it never calls `encode` with 
final=True, and it doesn't appear there's an API for forcing it to occur (for 
instance `flush` and `close` do not).

--
components: IO
files: test.py
messages: 332701
nosy: haney
priority: normal
severity: normal
status: open
title: open doesn't call IncrementalEncoder with final=True
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file48022/test.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com