File tree 2 files changed +6
-4
lines changed
2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -237,10 +237,10 @@ internal BorrowedReference GetPythonTypeReference()
237
237
/// Returns the Python type of the object. This method is equivalent
238
238
/// to the Python expression: type(object).
239
239
/// </remarks>
240
- public PyObject GetPythonType ( )
240
+ public PyType GetPythonType ( )
241
241
{
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 ) ;
244
244
}
245
245
246
246
Original file line number Diff line number Diff line change @@ -20,8 +20,10 @@ internal PyType(PyType o)
20
20
{
21
21
}
22
22
23
- internal PyType ( BorrowedReference reference ) : base ( reference )
23
+ internal PyType ( BorrowedReference reference , bool prevalidated = false ) : base ( reference )
24
24
{
25
+ if ( prevalidated ) return ;
26
+
25
27
if ( ! Runtime . PyType_Check ( this . Handle ) )
26
28
throw new ArgumentException ( "object is not a type" ) ;
27
29
}
You can’t perform that action at this time.
0 commit comments