else:
make_declarations(s, already_declared)
make_declarations(body)
- return declarations.values() + \
+ return list(declarations.values()) + \
[['function', f_name, ['signature', ret_type, ['parameters'], body]]]
-#!/usr/bin/env python2
+#!/usr/bin/env python
# encoding=utf-8
# Copyright © 2018 Intel Corporation
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
- out, err = proc.communicate(source)
+ out, err = proc.communicate(source.encode('utf-8'))
+ out = out.decode('utf-8')
+ err = err.decode('utf-8')
if err:
print('FAIL')
print('Unexpected output on stderr: {}'.format(err),
# as ['constant', 'float', ['1.000000']].
import re
+import sys
+if sys.version_info >= (3, 0, 0):
+ STRING_TYPE = str
+else:
+ STRING_TYPE = unicode
def check_sexp(sexp):
"""Verify that the argument is a proper sexp.
if isinstance(sexp, list):
for s in sexp:
check_sexp(s)
- elif not isinstance(sexp, basestring):
+ elif not isinstance(sexp, (STRING_TYPE, bytes)):
raise Exception('Not a sexp: {0!r}'.format(sexp))
def parse_sexp(sexp):
"""Convert a sexp, represented as nested lists containing strings,
into a single string of the form parseable by mesa.
"""
- if isinstance(sexp, basestring):
+ if isinstance(sexp, STRING_TYPE):
return sexp
+ if isinstance(sexp, bytes):
+ return sexp.encode('utf-8')
assert isinstance(sexp, list)
result = ''
for s in sexp: