|
1 | 1 | from __future__ import absolute_import, print_function, unicode_literals |
2 | 2 |
|
3 | | -import ast |
4 | 3 | import logging |
5 | 4 | import os |
6 | 5 | import sys |
|
11 | 10 | from wolframclient.language.side_effects import side_effect_logger |
12 | 11 | from wolframclient.serializers import export |
13 | 12 | from wolframclient.utils import six |
14 | | -from wolframclient.utils.api import zmq |
| 13 | +from wolframclient.utils.api import ast, zmq |
15 | 14 | from wolframclient.utils.datastructures import Settings |
16 | 15 | from wolframclient.utils.encoding import force_text |
17 | 16 | from wolframclient.utils.functional import last |
|
27 | 26 |
|
28 | 27 | EXPORT_KWARGS = {"target_format": "wxf", "allow_external_objects": True} |
29 | 28 |
|
| 29 | +if six.PY_38: |
| 30 | + |
| 31 | + # https://bugs.python.org/issue35766 |
| 32 | + # https://bugs.python.org/issue35894 |
| 33 | + # https://github.com/ipython/ipython/issues/11590 |
| 34 | + # PY_38 requires type_ignores to be a list, other versions are not accepting a second argument |
| 35 | + |
| 36 | + def Module(code, type_ignores = []): |
| 37 | + return ast.Module(code, type_ignores) |
| 38 | + |
| 39 | + |
| 40 | +else: |
| 41 | + |
| 42 | + def Module(code): |
| 43 | + return ast.Module(code) |
| 44 | + |
30 | 45 |
|
31 | 46 | def EvaluationEnvironment(code, session_data={}, constants=None, **extra): |
32 | 47 |
|
@@ -70,7 +85,7 @@ def execute_from_string(code, globals={}, **opts): |
70 | 85 | result = expressions.pop(-1) |
71 | 86 |
|
72 | 87 | if expressions: |
73 | | - exec(compile(ast.Module(expressions), "", "exec"), env) |
| 88 | + exec(compile(Module(expressions), "", "exec"), env) |
74 | 89 |
|
75 | 90 | if result: |
76 | 91 | return eval(compile(ast.Expression(result.value), "", "eval"), env) |
|
0 commit comments