File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ def ba(x):
3232 else :
3333 return array .array ('B' , str (x ))
3434
35+ def array2bytes (a ):
36+ if hasattr (array .array , 'tostring' ):
37+ return a .tostring ()
38+ else :
39+ return a .tobytes ()
40+
3541class ForthException (Exception ):
3642 def __init__ (self , value ):
3743 self .value = value
@@ -122,7 +128,7 @@ def dlit(self, d):
122128 def pops (self ):
123129 n = self .d .pop ()
124130 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" )
126132
127133 # Start of Forth words
128134 #
@@ -411,7 +417,7 @@ def xt(self, c):
411417
412418 def SFIND (self ):
413419 (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 ()
415421 # print('HERE', s.decode("utf-8"), self.dict)
416422 if s in self .dict :
417423 x = self .dict [s ]
You can’t perform that action at this time.
0 commit comments