Skip to content

Commit ab86040

Browse files
author
Arnau Orriols
committed
Fix python3 support
1 parent 3b9b0e6 commit ab86040

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/python-function.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ module.exports = function (RED) {
8686
code: `
8787
import os
8888
import json
89+
import sys
8990
90-
channel = os.fdopen(3, "r+")
91-
91+
if sys.version_info[0]<3:
92+
channel = os.fdopen(3, "r+")
93+
else:
94+
channel = os.fdopen(3, "r+b", buffering=0)
9295
9396
class Msg(object):
9497
SEND = 'send'
@@ -136,7 +139,7 @@ class Node(object):
136139
self.send_to_node(msg)
137140
138141
def send_to_node(self, msg):
139-
self.__channel.write(msg.dumps())
142+
self.__channel.write(msg.dumps().encode('utf-8'))
140143
141144
142145
def python_function(msg):

0 commit comments

Comments
 (0)