File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -237,10 +237,10 @@ internal BorrowedReference GetPythonTypeReference()
237237 /// Returns the Python type of the object. This method is equivalent
238238 /// to the Python expression: type(object).
239239 /// </remarks>
240- public PyObject GetPythonType ( )
240+ public PyType GetPythonType ( )
241241 {
242- IntPtr tp = Runtime . PyObject_Type ( obj ) ;
243- return new PyObject ( tp ) ;
242+ var tp = Runtime . PyObject_TYPE ( Reference ) ;
243+ return new PyType ( tp , prevalidated : true ) ;
244244 }
245245
246246
Original file line number Diff line number Diff line change @@ -20,8 +20,10 @@ internal PyType(PyType o)
2020 {
2121 }
2222
23- internal PyType ( BorrowedReference reference ) : base ( reference )
23+ internal PyType ( BorrowedReference reference , bool prevalidated = false ) : base ( reference )
2424 {
25+ if ( prevalidated ) return ;
26+
2527 if ( ! Runtime . PyType_Check ( this . Handle ) )
2628 throw new ArgumentException ( "object is not a type" ) ;
2729 }
You can’t perform that action at this time.
0 commit comments