[Firm] [PATCH 3/3] gen: Support python3 as well
Luca Barbato
lu_zero at gentoo.org
Thu Oct 24 11:38:31 CEST 2013
---
scripts/gen_ir.py | 6 +++---
scripts/gen_ir_io.py | 2 +-
scripts/spec_util.py | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/scripts/gen_ir.py b/scripts/gen_ir.py
index 2d73480..2389660 100755
--- a/scripts/gen_ir.py
+++ b/scripts/gen_ir.py
@@ -129,8 +129,8 @@ def format_pinned(node):
return ""
def format_flags(node):
- flags = map(lambda x : "irop_flag_" + x, node.flags)
- if flags == []:
+ flags = list(map(lambda x : "irop_flag_" + x, node.flags))
+ if not flags:
flags = [ "irop_flag_none" ]
return " | ".join(flags)
@@ -287,7 +287,7 @@ def main(argv):
env.globals['warning'] = "/* Warning: automatically generated file */"
template = env.get_template(templatefile)
- result = template.render().encode("utf-8")
+ result = template.render()
if result[-1] != "\n":
result += "\n"
sys.stdout.write(result)
diff --git a/scripts/gen_ir_io.py b/scripts/gen_ir_io.py
index 8df9a70..fefbd6f 100755
--- a/scripts/gen_ir_io.py
+++ b/scripts/gen_ir_io.py
@@ -159,7 +159,7 @@ def main(argv):
env.globals['hasattr'] = hasattr
template = env.get_template(templatefile)
- sys.stdout.write(template.render().encode("utf-8"))
+ sys.stdout.write(template.render())
if __name__ == "__main__":
main(sys.argv)
diff --git a/scripts/spec_util.py b/scripts/spec_util.py
index 5bc5748..9dac972 100644
--- a/scripts/spec_util.py
+++ b/scripts/spec_util.py
@@ -110,14 +110,14 @@ def trim_docstring(docstring):
# and split into a list of lines:
lines = docstring.expandtabs().splitlines()
# Determine minimum indentation (first line doesn't count):
- indent = sys.maxint
+ indent = sys.maxsize
for line in lines[1:]:
stripped = line.lstrip()
if stripped:
indent = min(indent, len(line) - len(stripped))
# Remove indentation (first line is special):
trimmed = [lines[0].strip()]
- if indent < sys.maxint:
+ if indent < sys.maxsize:
for line in lines[1:]:
trimmed.append(line[indent:].rstrip())
# Strip off trailing and leading blank lines:
--
1.8.3.2
More information about the Firm
mailing list