|
77 | 77 | import com.oracle.graal.python.nodes.ErrorMessages;
|
78 | 78 | import com.oracle.graal.python.nodes.SpecialMethodNames;
|
79 | 79 | import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode;
|
| 80 | +import com.oracle.graal.python.nodes.attributes.SetAttributeNode; |
80 | 81 | import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
|
81 | 82 | import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
|
82 | 83 | import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
|
@@ -507,11 +508,19 @@ public abstract static class CreateBuiltin extends PythonBuiltinNode {
|
507 | 508 | @Specialization(limit = "getCallSiteInlineCacheMaxDepth()")
|
508 | 509 | public Object run(VirtualFrame frame, PythonObject moduleSpec,
|
509 | 510 | @Cached CastToJavaStringNode toJavaStringNode,
|
| 511 | + @Cached("create(__LOADER__)") SetAttributeNode setAttributeNode, |
510 | 512 | @CachedLibrary(value = "moduleSpec") PythonObjectLibrary pol) {
|
511 | 513 | Object name = pol.lookupAttribute(moduleSpec, frame, "name");
|
512 | 514 | PythonModule builtinModule = getBuiltinModule(toJavaStringNode.execute(name));
|
513 | 515 | if (builtinModule != null) {
|
514 |
| - // TODO: builtin modules cannot be re-initialized (see is_builtin) |
| 516 | + // TODO: GR-26411 builtin modules cannot be re-initialized (see is_builtin) |
| 517 | + // We are setting the loader to the spec loader (since this is the loader that is |
| 518 | + // set during bootstrap); this, however, should be handled be the builtin module |
| 519 | + // reinitialization (if reinit is possible) |
| 520 | + Object loader = pol.lookupAttribute(moduleSpec, frame, "loader"); |
| 521 | + if (loader != PNone.NO_VALUE) { |
| 522 | + setAttributeNode.executeVoid(frame, builtinModule, loader); |
| 523 | + } |
515 | 524 | return builtinModule;
|
516 | 525 | }
|
517 | 526 | throw raise(NotImplementedError, "_imp.create_builtin");
|
|
0 commit comments