Skip to content

Commit

Permalink
fixed building using scons with python3
Browse files Browse the repository at this point in the history
I broke python 3 builds by using py2 specific dict functions in
commit 98846b3
Fixed with functions in compat.py
  • Loading branch information
ibrahn committed May 28, 2018
1 parent 38284bc commit 2731097
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions compat.py
Expand Up @@ -16,6 +16,8 @@ def decode_utf8(x):
return x
def iteritems(d):
return d.iteritems()
def itervalues(d):
return d.itervalues()
def escape_string(s):
if isinstance(s, unicode):
s = s.encode('ascii')
Expand Down Expand Up @@ -44,6 +46,8 @@ def decode_utf8(x):
return codecs.utf_8_decode(x)[0]
def iteritems(d):
return iter(d.items())
def itervalues(d):
return iter(d.values())
def charcode_to_c_escapes(c):
rev_result = []
while c >= 256:
Expand Down
8 changes: 4 additions & 4 deletions methods.py
@@ -1,5 +1,5 @@
import os
from compat import iteritems, open_utf8, escape_string
from compat import iteritems, itervalues, open_utf8, escape_string


def add_source_files(self, sources, filetype, lib_env=None, shared=False):
Expand Down Expand Up @@ -661,7 +661,7 @@ def next_tag(self):
reader.next_line()

data_list = []
for project in projects.itervalues():
for project in itervalues(projects):
for part in project:
part["file_index"] = len(data_list)
data_list += part["Files"]
Expand Down Expand Up @@ -703,7 +703,7 @@ def next_tag(self):
f.write("const ComponentCopyrightPart COPYRIGHT_PROJECT_PARTS[] = {\n")
part_index = 0
part_indexes = {}
for project_name, project in projects.iteritems():
for project_name, project in iteritems(projects):
part_indexes[project_name] = part_index
for part in project:
f.write("\t{ \"" + escape_string(part["License"][0]) + "\", "
Expand All @@ -717,7 +717,7 @@ def next_tag(self):
f.write("const int COPYRIGHT_INFO_COUNT = " + str(len(projects)) + ";\n")

f.write("const ComponentCopyright COPYRIGHT_INFO[] = {\n")
for project_name, project in projects.iteritems():
for project_name, project in iteritems(projects):
f.write("\t{ \"" + escape_string(project_name) + "\", "
+ "&COPYRIGHT_PROJECT_PARTS[" + str(part_indexes[project_name]) + "], "
+ str(len(project)) + " },\n")
Expand Down

0 comments on commit 2731097

Please sign in to comment.