luigi icon indicating copy to clipboard operation
luigi copied to clipboard

`UnboundLocalError` in `NewLineWrapper.read`

Open bwo opened this issue 3 years ago • 0 comments

In this code, if newline was provided to __init__ with a non-None value, newline = b'\n' will not be executed, so an UnboundLocalError will be raised in the final line.

    def read(self, n=-1):
        b = self._stream.read(n)

        if self.newline == b'':
            return b

        if self.newline is None:
            newline = b'\n'

        return re.sub(b'(\n|\r\n|\r)', newline, b)

bwo avatar Jan 20 '22 15:01 bwo