File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -1136,11 +1136,21 @@ def safe_eval(source):
1136
1136
SyntaxError: Unsupported source construct: compiler.ast.CallFunc
1137
1137
1138
1138
"""
1139
- # Local import to speed up numpy's import time.
1139
+ # Local imports to speed up numpy's import time.
1140
+ import warnings
1141
+ from numpy .testing .utils import WarningManager
1142
+ warn_ctx = WarningManager ()
1143
+ warn_ctx .__enter__ ()
1140
1144
try :
1141
- import compiler
1142
- except ImportError :
1143
- import ast as compiler
1145
+ # compiler package is deprecated for 3.x, which is already solved here
1146
+ warnings .simplefilter ('ignore' , DeprecationWarning )
1147
+ try :
1148
+ import compiler
1149
+ except ImportError :
1150
+ import ast as compiler
1151
+ finally :
1152
+ warn_ctx .__exit__ ()
1153
+
1144
1154
walker = SafeEval ()
1145
1155
try :
1146
1156
ast = compiler .parse (source , mode = "eval" )
You can’t perform that action at this time.
0 commit comments