Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit eb855e9

Browse files
Fix Python3.5 calls, test that version on travis too
1 parent 39189ca commit eb855e9

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

‎.travis.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: python
22
python:
33
- "3.4"
4+
- "3.5"
45
script: python -m unittest discover tests

‎pseudo_python/ast_translator.py‎

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -323,25 +323,34 @@ def _translate_name(self, id, ctx, location):
323323
z = {'type': 'local', 'name': '_old_%s' % id, 'pseudo_type': id_type}
324324
return z
325325

326-
def _translate_call(self, func, args, keywords, starargs, kwargs, location):
326+
def _translate_call(self, func, args, keywords, starargs=None, kwargs=None, location=None):
327327
self.assert_translatable('call', keywords=([], keywords), kwargs=(None, kwargs))
328-
if starargs:
329-
many_arg = self._translate_node(starargs)
330-
if isinstance(many_arg['pseudo_type'], list) and many_arg['pseudo_type'][0] == 'Tuple':
331-
args += [{
332-
'type': 'index',
333-
'sequence': many_arg,
334-
'index': {'type': 'int', 'value': j, 'pseudo_type': 'Int'},
335-
'pseudo_type': t
336-
}
337-
for j, t
338-
in enumerate(many_arg['pseudo_type'][1:])]
328+
#Python3.5
329+
# apparently you can't do e(*a, *a) in Python3.4 wtf
330+
initial_args = args[:]
331+
args = []
332+
if starargs: # python3.4
333+
initial_args.append(ast.Started(ast.starargs))
334+
335+
for arg in initial_args:
336+
if isinstance(arg, ast.Starred):
337+
many_arg = self._translate_node(arg)
338+
if isinstance(many_arg['pseudo_type'], list) and many_arg['pseudo_type'][0] == 'Tuple':
339+
args += [{
340+
'type': 'index',
341+
'sequence': many_arg,
342+
'index': {'type': 'int', 'value': j, 'pseudo_type': 'Int'},
343+
'pseudo_type': t
344+
}
345+
for j, t
346+
in enumerate(many_arg['pseudo_type'][1:])]
339347

348+
else:
349+
raise translation_error("pseudo-python supports <call>(..*args) only for Tuple *args, because otherwise it doesn't know the exact arg count at compile time",
350+
location, self.lines[location[0]],
351+
wrong_type=many_arg['pseudo_type'])
340352
else:
341-
raise translation_error("pseudo-python supports <call>(..*args) only for Tuple *args, because otherwise it doesn't know the exact arg count at compile time",
342-
location, self.lines[location[0]],
343-
wrong_type=many_arg['pseudo_type'])
344-
353+
args.append(arg)
345354

346355

347356
if isinstance(func, ast.Name) and func.id in BUILTIN_FUNCTIONS:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /