Skip to content

Commit f721ce2

Browse files
committed
Merge pull request #227 in LCL/wolframclientforpython from bugfix/384478-python-38 to master
* commit 'd6e83c8b6c27a2b6967294309145b902d1744da1': removing unused protected_types removing extra function adding fix for python 3.8
2 parents 5c04783 + d6e83c8 commit f721ce2

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

wolframclient/utils/externalevaluate.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@
2727

2828
EXPORT_KWARGS = {"target_format": "wxf", "allow_external_objects": True}
2929

30+
if six.PY_38:
31+
32+
# https://bugs.python.org/issue35766
33+
# https://bugs.python.org/issue35894
34+
# https://github.com/ipython/ipython/issues/11590
35+
# PY_38 requires type_ignores to be a list, other versions are not accepting a second argument
36+
37+
def Module(code):
38+
return ast.Module(code, [])
39+
40+
41+
else:
42+
43+
Module = ast.Module
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: 2 additions & 17 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"
@@ -60,20 +61,4 @@
6061
itertools.groupby,
6162
]
6263
if not PY2:
63-
iterable_types.extend((map, range))
64-
65-
protected_types = tuple(
66-
itertools.chain(
67-
string_types,
68-
integer_types,
69-
(
70-
float,
71-
decimal.Decimal,
72-
datetime.date,
73-
datetime.datetime,
74-
datetime.time,
75-
bool,
76-
none_type,
77-
),
78-
)
79-
)
64+
iterable_types.extend((map, range))

0 commit comments

Comments
 (0)