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 103
103
import com .oracle .graal .python .runtime .sequence .storage .MroSequenceStorage ;
104
104
import com .oracle .graal .python .util .InlineWeakValueProfile ;
105
105
import com .oracle .truffle .api .CompilerAsserts ;
106
+ import com .oracle .truffle .api .CompilerDirectives ;
106
107
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
107
108
import com .oracle .truffle .api .TruffleLogger ;
108
109
import com .oracle .truffle .api .dsl .Cached ;
@@ -955,7 +956,19 @@ static TpSlots doManaged(PythonManagedClass klass) {
955
956
956
957
@ Specialization
957
958
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 ;
959
972
}
960
973
}
961
974
You can’t perform that action at this time.
0 commit comments