File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 103103import com .oracle .graal .python .runtime .sequence .storage .MroSequenceStorage ;
104104import com .oracle .graal .python .util .InlineWeakValueProfile ;
105105import com .oracle .truffle .api .CompilerAsserts ;
106+ import com .oracle .truffle .api .CompilerDirectives ;
106107import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
107108import com .oracle .truffle .api .TruffleLogger ;
108109import com .oracle .truffle .api .dsl .Cached ;
@@ -955,7 +956,19 @@ static TpSlots doManaged(PythonManagedClass klass) {
955956
956957 @ Specialization
957958 static TpSlots doNative (PythonAbstractNativeObject nativeKlass ) {
958- return nativeKlass .getTpSlots ();
959+ TpSlots tpSlots = nativeKlass .getTpSlots ();
960+ if (tpSlots == null ) {
961+ /*
962+ * This happens when we try to get slots of a type that didn't go through
963+ * PyType_Ready yet. Specifically, numpy has a "fortran" type (defined in
964+ * `fortranobject.c`) that they never ready and just expect it to work because it's
965+ * simple. So just do the minimum to make the slots available.
966+ */
967+ CompilerDirectives .transferToInterpreterAndInvalidate ();
968+ tpSlots = TpSlots .fromNative (nativeKlass , PythonContext .get (null ));
969+ nativeKlass .setTpSlots (tpSlots );
970+ }
971+ return tpSlots ;
959972 }
960973 }
961974
You can’t perform that action at this time.
0 commit comments