You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Output using bare \n line endings is dropped on Windows #331
On Windows os.EOL is \r\n. Any Python output that uses bare \n line endings is never split into lines: the chunk is held in _lastLineData and only emitted on _flush, which runs after the stream's end handler has already resolved the run()/end() callback. The result is that the output is silently lost.
Normal print() happens to work because Python's text-mode stdout translates \n to \r\n on Windows, but bare \n (for example sys.stdout.buffer.write(b'...\n'), reconfigured stdout, or messages with embedded newlines) is dropped.
Reproduction (Windows):
const{ NewlineTransformer }=require('python-shell');constt=newNewlineTransformer();t.setEncoding('utf8');constout=[];t.on('data',c=>out.push(c.toString()));t.on('end',()=>console.log(out));// ['hello\nworld\n'] instead of ['hello', 'world']t.write(Buffer.from('hello\nworld\n'));t.end();
Fix: split on /\r?\n/ so both \n and \r\n are handled. PR follows.
Activity