@@ -149,6 +149,16 @@ def arguments_parse():
149
149
return args
150
150
151
151
152
+ if sys .version_info .major >= 3 :
153
+ _ord_orig = ord
154
+ def _ord_compat (c ):
155
+ if isinstance (c , int ):
156
+ return c
157
+ return _ord_orig (c )
158
+ # pylint: disable=redefined-builtin
159
+ ord = _ord_compat
160
+
161
+
152
162
class JerryBreakpoint (object ):
153
163
154
164
def __init__ (self , line , offset , function ):
@@ -561,6 +571,7 @@ def memstats(self):
561
571
self ._exec_command (JERRY_DEBUGGER_MEMSTATS )
562
572
563
573
def _send_string (self , args , message_type , index = 0 ):
574
+ args = args .encode ("utf8" )
564
575
565
576
# 1: length of type byte
566
577
# 4: length of an uint32 value
@@ -808,7 +819,7 @@ def process_messages(self):
808
819
return DebuggerAction (DebuggerAction .TEXT , result )
809
820
810
821
elif buffer_type in [JERRY_DEBUGGER_SCOPE_VARIABLES , JERRY_DEBUGGER_SCOPE_VARIABLES_END ]:
811
- self .scope_vars += "" .join (data [1 :])
822
+ self .scope_vars += "" .join (data [1 :]. decode ( "utf8" ) )
812
823
813
824
if buffer_type == JERRY_DEBUGGER_SCOPE_VARIABLES_END :
814
825
result = self ._process_scope_variables ()
@@ -864,9 +875,9 @@ def print_source(self, line_num, offset):
864
875
865
876
# pylint: disable=too-many-branches,too-many-locals,too-many-statements
866
877
def _parse_source (self , data ):
867
- source_code = ""
868
- source_code_name = ""
869
- function_name = ""
878
+ source_code = b ""
879
+ source_code_name = b ""
880
+ function_name = b ""
870
881
stack = [{"line" : 1 ,
871
882
"column" : 1 ,
872
883
"name" : "" ,
@@ -903,11 +914,11 @@ def _parse_source(self, data):
903
914
position = struct .unpack (self .byte_order + self .idx_format + self .idx_format ,
904
915
data [1 : 1 + 4 + 4 ])
905
916
906
- stack .append ({"source" : source_code ,
907
- "source_name" : source_code_name ,
917
+ stack .append ({"source" : source_code . decode ( "utf8" ) ,
918
+ "source_name" : source_code_name . decode ( "utf8" ) ,
908
919
"line" : position [0 ],
909
920
"column" : position [1 ],
910
- "name" : function_name ,
921
+ "name" : function_name . decode ( "utf8" ) ,
911
922
"lines" : [],
912
923
"offsets" : []})
913
924
function_name = ""
@@ -937,8 +948,8 @@ def _parse_source(self, data):
937
948
938
949
# We know the last item in the list is the general byte code.
939
950
if not stack :
940
- func_desc ["source" ] = source_code
941
- func_desc ["source_name" ] = source_code_name
951
+ func_desc ["source" ] = source_code . decode ( "utf8" )
952
+ func_desc ["source_name" ] = source_code_name . decode ( "utf8" )
942
953
943
954
function = JerryFunction (stack ,
944
955
byte_code_cp ,
@@ -1151,7 +1162,7 @@ def _process_incoming_text(self, buffer_type, data):
1151
1162
log_type = "%sout:%s " % (self .blue , self .nocolor )
1152
1163
1153
1164
message = self .current_out + message
1154
- lines = message .split ("\n " )
1165
+ lines = message .decode ( "utf8" ). split ("\n " )
1155
1166
self .current_out = lines .pop ()
1156
1167
1157
1168
return "" .join (["%s%s\n " % (log_type , line ) for line in lines ])
@@ -1160,7 +1171,7 @@ def _process_incoming_text(self, buffer_type, data):
1160
1171
log_type = "%slog:%s " % (self .yellow , self .nocolor )
1161
1172
1162
1173
message = self .current_log + message
1163
- lines = message .split ("\n " )
1174
+ lines = message .decode ( "utf8" ). split ("\n " )
1164
1175
self .current_log = lines .pop ()
1165
1176
1166
1177
return "" .join (["%s%s\n " % (log_type , line ) for line in lines ])
@@ -1169,15 +1180,16 @@ def _process_incoming_text(self, buffer_type, data):
1169
1180
message += "\n "
1170
1181
1171
1182
if subtype == JERRY_DEBUGGER_OUTPUT_WARNING :
1172
- return "%swarning: %s%s" % (self .yellow , self .nocolor , message )
1183
+ return "%swarning: %s%s" % (self .yellow , self .nocolor , message . decode ( "utf8" ) )
1173
1184
elif subtype == JERRY_DEBUGGER_OUTPUT_ERROR :
1174
- return "%serr: %s%s" % (self .red , self .nocolor , message )
1185
+ return "%serr: %s%s" % (self .red , self .nocolor , message . decode ( "utf8" ) )
1175
1186
elif subtype == JERRY_DEBUGGER_OUTPUT_TRACE :
1176
- return "%strace: %s%s" % (self .blue , self .nocolor , message )
1187
+ return "%strace: %s%s" % (self .blue , self .nocolor , message . decode ( "utf8" ) )
1177
1188
1178
1189
# Subtypes of eval
1179
1190
self .prompt = True
1180
1191
1192
+ message = message .decode ("utf8" )
1181
1193
if not message .endswith ("\n " ):
1182
1194
message += "\n "
1183
1195
0 commit comments