Skip to content

Commit ed7036c

Browse files
committed
fixed extrabacon#109 hardcoded newlines
1 parent 9e5c77a commit ed7036c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var EventEmitter = require('events').EventEmitter;
22
var path = require('path');
33
var util = require('util');
44
var spawn = require('child_process').spawn;
5+
var newline = require('os').EOL;
56

67
function toArray(source) {
78
if (typeof source === 'undefined' || source === null) {
@@ -179,13 +180,13 @@ PythonShell.prototype.parseError = function (data) {
179180

180181
if (/^Traceback/.test(text)) {
181182
// traceback data is available
182-
var lines = (''+data).trim().split(/\n/g);
183+
var lines = (''+data).trim().split(new RegExp(newline, 'g'));
183184
var exception = lines.pop();
184185
error = new Error(exception);
185186
error.traceback = data;
186187
// extend stack trace
187-
error.stack += '\n ----- Python Traceback -----\n ';
188-
error.stack += lines.slice(1).join('\n ');
188+
error.stack += newline+' ----- Python Traceback -----'+newline+' ';
189+
error.stack += lines.slice(1).join(newline+' ');
189190
} else {
190191
// otherwise, create a simpler error with stderr contents
191192
error = new Error(text);
@@ -202,7 +203,7 @@ PythonShell.prototype.parseError = function (data) {
202203
*/
203204
PythonShell.prototype.send = function (message) {
204205
var data = this.formatter ? this.formatter(message) : message;
205-
if (this.mode !== 'binary') data += '\n';
206+
if (this.mode !== 'binary') data += newline;
206207
this.stdin.write(data);
207208
return this;
208209
};
@@ -215,7 +216,7 @@ PythonShell.prototype.send = function (message) {
215216
*/
216217
PythonShell.prototype.receive = function (data) {
217218
var self = this;
218-
var parts = (''+data).split(/\n/g);
219+
var parts = (''+data).split(new RegExp(newline,'g'));
219220

220221
if (parts.length === 1) {
221222
// an incomplete record, keep buffering

0 commit comments

Comments
 (0)