9191import com .oracle .graal .python .builtins .objects .object .PythonObject ;
9292import com .oracle .graal .python .builtins .objects .str .PString ;
9393import com .oracle .graal .python .compiler .Compiler ;
94+ import com .oracle .graal .python .lib .PyObjectGetAttr ;
9495import com .oracle .graal .python .lib .PyObjectLookupAttr ;
9596import com .oracle .graal .python .lib .PyObjectSetAttr ;
9697import com .oracle .graal .python .lib .PyObjectStrAsTruffleStringNode ;
9798import com .oracle .graal .python .nodes .ErrorMessages ;
9899import com .oracle .graal .python .nodes .PConstructAndRaiseNode ;
99100import com .oracle .graal .python .nodes .PGuards ;
100101import com .oracle .graal .python .nodes .PRaiseNode ;
101- import com .oracle .graal .python .nodes .attributes .ReadAttributeFromPythonObjectNode ;
102102import com .oracle .graal .python .nodes .attributes .WriteAttributeToPythonObjectNode ;
103103import com .oracle .graal .python .nodes .call .CallDispatchers ;
104104import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
@@ -274,9 +274,7 @@ protected PBytes getMagicNumberPBytes() {
274274 }
275275 }
276276
277- @ Builtin (name = "__create_dynamic__" , minNumOfPositionalArgs = 2 )
278- @ GenerateNodeFactory
279- public abstract static class CreateDynamic extends PythonBinaryBuiltinNode {
277+ public abstract static class CreateDynamic extends Node {
280278
281279 @ Child private CheckFunctionResultNode checkResultNode ;
282280
@@ -287,13 +285,18 @@ Object run(VirtualFrame frame, PythonObject moduleSpec, @SuppressWarnings("unuse
287285 @ Bind Node inliningTarget ,
288286 @ Bind PythonContext context ,
289287 @ Cached ("createFor($node)" ) IndirectCallData indirectCallData ,
290- @ Cached ReadAttributeFromPythonObjectNode readNameNode ,
291- @ Cached ReadAttributeFromPythonObjectNode readOriginNode ,
288+ @ Cached PyObjectGetAttr getAttr ,
292289 @ Cached CastToTruffleStringNode castToTruffleStringNode ,
293290 @ Cached TruffleString .EqualNode eqNode ,
294- @ Cached PConstructAndRaiseNode .Lazy constructAndRaiseNode ) {
295- TruffleString name = castToTruffleStringNode .execute (inliningTarget , readNameNode .execute (moduleSpec , T_NAME ));
296- TruffleString path = castToTruffleStringNode .execute (inliningTarget , readOriginNode .execute (moduleSpec , T_ORIGIN ));
291+ @ Cached PConstructAndRaiseNode .Lazy constructAndRaiseNode ,
292+ @ Cached PRaiseNode raiseNode ) {
293+ TruffleString name , path ;
294+ try {
295+ name = castToTruffleStringNode .execute (inliningTarget , getAttr .execute (inliningTarget , moduleSpec , T_NAME ));
296+ path = castToTruffleStringNode .execute (inliningTarget , getAttr .execute (inliningTarget , moduleSpec , T_ORIGIN ));
297+ } catch (CannotCastException e ) {
298+ throw raiseNode .raise (inliningTarget , TypeError , ErrorMessages .BAD_ARG_TYPE_FOR_BUILTIN_OP );
299+ }
297300
298301 PythonLanguage language = context .getLanguage (inliningTarget );
299302 Object state = IndirectCallContext .enter (frame , language , context , indirectCallData );
0 commit comments