This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: replace `io.IncrementalNewlineDecoder` with non incremental newline decoders
Type: Stage: patch review
Components: Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: JelleZijlstra, eric.araujo, guoci
Priority: normal Keywords: patch

Created on 2021-12-27 18:01 by guoci, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 30276 open guoci, 2021-12-27 18:02
Messages (6)
msg409235 - (view) Author: Guo Ci Teo (guoci) * Date: 2021-12-27 18:01
replace unnecessary use of `io.IncrementalNewlineDecoder` in code.
Some uses of the `decode` method were also incorrect without the `final=True` argument.
msg409236 - (view) Author: Guo Ci Teo (guoci) * Date: 2021-12-27 18:04
In any case, the use of an incremental newline decoder is not required
msg409475 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2022-01-01 20:04
Can you describe what the problem is?
Is it incorrect in some cases?  Is it inefficient?

Without a statement of the issue, we can’t discuss a solution :)
msg409476 - (view) Author: Guo Ci Teo (guoci) * Date: 2022-01-01 20:34
Some uses of the `decode` method of `io.IncrementalNewlineDecoder` were incorrect without the `final=True` argument.
One way to fix it would be to add the `final=True` in all cases.
But the incremental decoding feature is not used, so I decided to replace it with stateless non-incremental newline decoders.
msg411443 - (view) Author: Jelle Zijlstra (JelleZijlstra) * (Python committer) Date: 2022-01-24 04:49
If the old code is incorrect, can you give an example where it fails? Is it possible to write a unit test demonstrating that the current behavior is wrong?
msg411922 - (view) Author: Guo Ci Teo (guoci) * Date: 2022-01-27 20:45
The old code has an incorrect usage of `io.IncrementalNewlineDecoder`. Since the `decode` method is called only once, is it the final call and needs the `final=True` argument as documented in https://docs.python.org/dev/library/codecs.html#codecs.IncrementalDecoder.decode

It happens that in those cases, the results are correct in spite of the incorrect usage.
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90344
2022-01-27 20:45:24guocisetmessages: + msg411922
2022-01-24 04:49:41JelleZijlstrasetnosy: + JelleZijlstra
messages: + msg411443
2022-01-01 20:34:08guocisetmessages: + msg409476
2022-01-01 20:04:06eric.araujosetnosy: + eric.araujo

messages: + msg409475
versions: + Python 3.11
2021-12-27 18:04:46guocisetmessages: + msg409236
2021-12-27 18:02:19guocisetkeywords: + patch
stage: patch review
pull_requests: + pull_request28491
2021-12-27 18:01:06guocicreate