Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit79e34bc

Browse files
committed
PyObject.GetPythonType returns PyType
1 parentd48f512 commit79e34bc

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

‎src/runtime/pyobject.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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-
publicPyObjectGetPythonType()
240+
publicPyTypeGetPythonType()
241241
{
242-
IntPtrtp=Runtime.PyObject_Type(obj);
243-
returnnewPyObject(tp);
242+
vartp=Runtime.PyObject_TYPE(Reference);
243+
returnnewPyType(tp,prevalidated:true);
244244
}
245245

246246

‎src/runtime/pytype.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ internal PyType(PyType o)
2020
{
2121
}
2222

23-
internalPyType(BorrowedReferencereference):base(reference)
23+
internalPyType(BorrowedReferencereference,boolprevalidated=false):base(reference)
2424
{
25+
if(prevalidated)return;
26+
2527
if(!Runtime.PyType_Check(this.Handle))
2628
thrownewArgumentException("object is not a type");
2729
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp