Title: codecs.StreamRecoder.writelines is broken
Type: Stage: test needed
Components: Versions: Python 3.8, Python 3.7, Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Jelle Zijlstra, gvanrossum
Priority: normal Keywords: patch

Created on 2018-05-13 14:33 by Jelle Zijlstra, last changed 2018-06-11 21:45 by serhiy.storchaka.

Pull Requests
URL Status Linked Edit
PR 6779 open Jelle Zijlstra, 2018-05-13 14:37
Messages (2)
msg316465 - (view) Author: Jelle Zijlstra (Jelle Zijlstra) * (Python triager) Date: 2018-05-13 14:33
codecs.StreamRecoder.writelines is implemented as:

    def writelines(self, list):

        data = ''.join(list)
        data, bytesdecoded = self.decode(data, self.errors)
        return self.writer.write(data)

It can't take a list of bytes because then the ''.join throws an error, and it can't take a list of str because self.decode takes bytes.

It looks like bytes are intended (self.write takes bytes), so I'll submit a simple PR to fix this.
msg319343 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2018-06-11 20:48
LGTM. Though sad there's no test that caught this. Could you add one.
Date User Action Args
2018-06-11 21:45:14serhiy.storchakasetstage: patch review -> test needed
2018-06-11 20:48:32gvanrossumsetnosy: + gvanrossum
messages: + msg319343
2018-05-13 14:37:56Jelle Zijlstrasetkeywords: + patch
stage: patch review
pull_requests: + pull_request6465
2018-05-13 14:33:47Jelle Zijlstracreate