Skip to content

Commit b0ad6f0

Browse files
committed
Merge branch 'release/B12_1_0' into bugfix/380061-removing-dependencies
2 parents 2757fb7 + 37c45ea commit b0ad6f0

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

wolframclient/utils/api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
from wolframclient.utils.importutils import API
44

5+
ast = API(
6+
Module = 'ast.Module',
7+
PyCF_ONLY_AST = 'ast.PyCF_ONLY_AST',
8+
Expr = 'ast.Expr',
9+
Expression = 'ast.Expression',
10+
FunctionDef = 'ast.FunctionDef',
11+
ClassDef = 'ast.ClassDef',
12+
)
13+
514
pytz = API(
615
FixedOffset="pytz.FixedOffset",
716
timezone="pytz.timezone",

wolframclient/utils/externalevaluate.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import absolute_import, print_function, unicode_literals
22

3-
import ast
43
import logging
54
import os
65
import sys
@@ -11,7 +10,7 @@
1110
from wolframclient.language.side_effects import side_effect_logger
1211
from wolframclient.serializers import export
1312
from wolframclient.utils import six
14-
from wolframclient.utils.api import zmq
13+
from wolframclient.utils.api import ast, zmq
1514
from wolframclient.utils.datastructures import Settings
1615
from wolframclient.utils.encoding import force_text
1716
from wolframclient.utils.functional import last
@@ -27,6 +26,22 @@
2726

2827
EXPORT_KWARGS = {"target_format": "wxf", "allow_external_objects": True}
2928

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+
3045

3146
def EvaluationEnvironment(code, session_data={}, constants=None, **extra):
3247

@@ -70,7 +85,7 @@ def execute_from_string(code, globals={}, **opts):
7085
result = expressions.pop(-1)
7186

7287
if expressions:
73-
exec(compile(ast.Module(expressions), "", "exec"), env)
88+
exec(compile(Module(expressions), "", "exec"), env)
7489

7590
if result:
7691
return eval(compile(ast.Expression(result.value), "", "eval"), env)

wolframclient/utils/six.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
PY_35 = sys.version_info >= (3, 5)
1515
PY_36 = sys.version_info >= (3, 6)
1616
PY_37 = sys.version_info >= (3, 7)
17+
PY_38 = sys.version_info >= (3, 8)
1718

1819
WINDOWS = platform.system() == "Windows"
1920
LINUX = platform.system() == "Linux"

0 commit comments

Comments
 (0)