PyObject.GetPythonType returns PyType
This commit is contained in:
Родитель
d48f512aad
Коммит
79e34bcdc2
|
@ -237,10 +237,10 @@ namespace Python.Runtime
|
|||
/// Returns the Python type of the object. This method is equivalent
|
||||
/// to the Python expression: type(object).
|
||||
/// </remarks>
|
||||
public PyObject GetPythonType()
|
||||
public PyType GetPythonType()
|
||||
{
|
||||
IntPtr tp = Runtime.PyObject_Type(obj);
|
||||
return new PyObject(tp);
|
||||
var tp = Runtime.PyObject_TYPE(Reference);
|
||||
return new PyType(tp, prevalidated: true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,8 +20,10 @@ namespace Python.Runtime
|
|||
{
|
||||
}
|
||||
|
||||
internal PyType(BorrowedReference reference) : base(reference)
|
||||
internal PyType(BorrowedReference reference, bool prevalidated = false) : base(reference)
|
||||
{
|
||||
if (prevalidated) return;
|
||||
|
||||
if (!Runtime.PyType_Check(this.Handle))
|
||||
throw new ArgumentException("object is not a type");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче