|
77 | 77 | import com.oracle.truffle.api.nodes.Node;
|
78 | 78 | import com.oracle.truffle.api.nodes.RootNode;
|
79 | 79 | import com.oracle.truffle.api.source.Source;
|
| 80 | +import com.oracle.truffle.api.source.Source.SourceBuilder; |
80 | 81 | import com.oracle.truffle.api.source.SourceSection;
|
81 | 82 |
|
82 | 83 | public final class PythonParserImpl implements PythonParser, PythonCodeSerializer, FStringExprParser {
|
@@ -206,11 +207,16 @@ public RootNode deserialize(ParserErrorCallback errorCallback, byte[] data, Stri
|
206 | 207 | globalScope = ScopeInfo.read(dis, null);
|
207 | 208 | int offset = dis.readInt();
|
208 | 209 |
|
| 210 | + SourceBuilder sb; |
209 | 211 | if (path.isEmpty() || offset != 0) {
|
210 |
| - source = Source.newBuilder(PythonLanguage.ID, contents, name).build(); |
| 212 | + sb = Source.newBuilder(PythonLanguage.ID, contents, name); |
211 | 213 | } else {
|
212 |
| - source = Source.newBuilder(PythonLanguage.ID, PythonContext.get(null).getEnv().getPublicTruffleFile(path)).content(contents).name(name).build(); |
| 214 | + sb = Source.newBuilder(PythonLanguage.ID, PythonContext.get(null).getEnv().getPublicTruffleFile(path)).content(contents).name(name); |
213 | 215 | }
|
| 216 | + if (!errorCallback.getContext().getCore().isCoreInitialized()) { |
| 217 | + sb = sb.internal(true).cached(false); |
| 218 | + } |
| 219 | + source = sb.build(); |
214 | 220 | sstNode = new SSTDeserializer(dis, globalScope, offset).readNode();
|
215 | 221 | } catch (IOException e) {
|
216 | 222 | throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.ValueError, "Is not possible get correct bytecode data %s, %s", e.getClass().getSimpleName(), e.getMessage());
|
|
0 commit comments