Skip to content

Commit 2d50a90

Browse files
committed
Python2+3: flash_algo
1 parent 95c7d4d commit 2d50a90

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tools/flash_algo/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
import binascii
2323
import argparse
2424
import logging
25-
import StringIO
25+
try:
26+
from StringIO import StringIO
27+
except ImportError:
28+
from io import StringIO
2629
import jinja2
2730
from collections import namedtuple
2831
from itertools import count
@@ -124,7 +127,7 @@ def format_algo_data(self, spaces, group_size, fmt):
124127
if fmt == "hex":
125128
blob = binascii.b2a_hex(self.algo_data)
126129
line_list = []
127-
for i in xrange(0, len(blob), group_size):
130+
for i in range(0, len(blob), group_size):
128131
line_list.append('"' + blob[i:i + group_size] + '"')
129132
return ("\n" + padding).join(line_list)
130133
elif fmt == "c":
@@ -311,7 +314,7 @@ class ElfFileSimple(ELFFile):
311314

312315
def __init__(self, data):
313316
"""Construct a ElfFileSimple from bytes or a bytearray"""
314-
super(ElfFileSimple, self).__init__(StringIO.StringIO(data))
317+
super(ElfFileSimple, self).__init__(StringIO(data))
315318
self.symbols = self._read_symbol_table()
316319

317320
def _read_symbol_table(self):

0 commit comments

Comments
 (0)