luigi
luigi copied to clipboard
`UnboundLocalError` in `NewLineWrapper.read`
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)