File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ def ba(x):
32
32
else :
33
33
return array .array ('B' , str (x ))
34
34
35
+ def array2bytes (a ):
36
+ if hasattr (array .array , 'tostring' ):
37
+ return a .tostring ()
38
+ else :
39
+ return a .tobytes ()
40
+
35
41
class ForthException (Exception ):
36
42
def __init__ (self , value ):
37
43
self .value = value
@@ -122,7 +128,7 @@ def dlit(self, d):
122
128
def pops (self ):
123
129
n = self .d .pop ()
124
130
a = self .d .pop ()
125
- return self .ram [a :a + n ]. tostring ( ).decode ("utf-8" )
131
+ return array2bytes ( self .ram [a :a + n ]).decode ("utf-8" )
126
132
127
133
# Start of Forth words
128
134
#
@@ -411,7 +417,7 @@ def xt(self, c):
411
417
412
418
def SFIND (self ):
413
419
(a , n ) = self .d [- 2 :]
414
- s = self .ram [a :a + n ]. tostring ( ).decode ("utf-8" ).upper ()
420
+ s = array2bytes ( self .ram [a :a + n ]).decode ("utf-8" ).upper ()
415
421
# print('HERE', s.decode("utf-8"), self.dict)
416
422
if s in self .dict :
417
423
x = self .dict [s ]
You can’t perform that action at this time.
0 commit comments