Skip to content

Commit

Permalink
Fixed some invalid python syntax errors in the pygame builds. Fixes k…
Browse files Browse the repository at this point in the history
…ivy#444

* modified few files to support python 3 syntax.
  • Loading branch information
dvenkatsagar committed Sep 10, 2015
1 parent 21acd88 commit acadb29
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pythonforandroid/bootstraps/pygame/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def select(fn):
tf = tarfile.open(tfn, 'w:gz', format=tarfile.USTAR_FORMAT)
dirs = []
for fn, afn in files:
print '%s: %s' % (tfn, fn)
print('%s: %s' % (tfn, fn))
dn = dirname(afn)
if dn not in dirs:
# create every dirs first if not exist yet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}

try:
exec '(0 if 0 else 0)'
exec('(0 if 0 else 0)')
except SyntaxError:
have_condexpr = False
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

# how does the raise helper look like?
try:
exec "raise TypeError, 'foo'"
exec("raise TypeError, 'foo'")
except SyntaxError:
raise_helper = 'raise __jinja_exception__[1]'
except TypeError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ def compile_templates(self, target, extensions=None, filter_func=None,
def write_file(filename, data, mode):
if zip:
info = ZipInfo(filename)
info.external_attr = 0755 << 16L
info.external_attr = 0o755 << 16L
zip_file.writestr(info, data)
else:
f = open(os.path.join(target, filename), mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def babel_extract(fileobj, keywords, comment_tags, options):
try:
node = environment.parse(source)
tokens = list(environment.lex(environment.preprocess(source)))
except TemplateSyntaxError, e:
except TemplateSyntaxError as e:
# skip templates with syntax errors
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,9 @@ class _GroupTuple(tuple):
grouper = property(itemgetter(0))
list = property(itemgetter(1))

def __new__(cls, (key, value)):
return tuple.__new__(cls, (key, list(value)))
#def __new__(cls, (key, value)):
def __new__(cls, kv):
return tuple.__new__(cls, (kv[0], list(kv[1])))


def do_list(value):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ def wrap(self, stream, name=None, filename=None):
value = self._normalize_newlines(value[1:-1]) \
.encode('ascii', 'backslashreplace') \
.decode('unicode-escape')
except Exception, e:
except Exception as e:
msg = str(e).split(':')[-1].strip()
raise TemplateSyntaxError(msg, lineno, name, filename)
# if we can express it as bytestring (ascii only)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _test_gen_bug():
raise TypeError(_test_gen_bug)
yield None
_concat(_test_gen_bug())
except TypeError, _error:
except TypeError as _error:
if not _error.args or _error.args[0] is not _test_gen_bug:
def concat(gen):
try:
Expand Down Expand Up @@ -370,7 +370,7 @@ class Markup(unicode):
>>> class Foo(object):
... def __html__(self):
... return '<a href="#">foo</a>'
...
...
>>> Markup(Foo())
Markup(u'<a href="#">foo</a>')
Expand Down

0 comments on commit acadb29

Please sign in to comment.