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
This repository was archived by the owner on Jul 22, 2023. It is now read-only.
/pythonnetPublic archive
forked frompythonnet/pythonnet

Commitd7777b9

Browse files
committed
Define and document Py_IncRef/Py_DecRef
1 parentde3874c commitd7777b9

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

‎src/runtime/runtime.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,6 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects)
500500
internalstaticunsafevoidXIncref(IntPtrop)
501501
{
502502
#ifPYTHON_WITH_PYDEBUG
503-
// according to Python doc, Py_IncRef() is Py_XINCREF()
504503
Py_IncRef(op);
505504
return;
506505
#else
@@ -522,8 +521,6 @@ internal static unsafe void XIncref(IntPtr op)
522521
internalstaticunsafevoidXDecref(IntPtrop)
523522
{
524523
#ifPYTHON_WITH_PYDEBUG
525-
// Py_DecRef calls Python's Py_DECREF
526-
// according to Python doc, Py_DecRef() is Py_XDECREF()
527524
Py_DecRef(op);
528525
return;
529526
#else
@@ -568,15 +565,21 @@ internal static unsafe long Refcount(IntPtr op)
568565
return Is32Bit?(*(int*)p):(*(long*)p);
569566
}
570567

571-
#ifPYTHON_WITH_PYDEBUG
572-
// Py_IncRef and Py_DecRef are taking care of the extra payload
573-
// in Py_DEBUG builds of Python like _Py_RefTotal
568+
/// <summary>
569+
/// Export of Macro Py_XIncRef. Use XIncref instead.
570+
/// Limit this function usage for Testing and Py_Debug builds
571+
/// </summary>
572+
/// <param name="ob">PyObject Ptr</param>
574573
[DllImport(PythonDll)]
575-
privatestatic externvoid Py_IncRef(IntPtrob);
574+
internalstaticexternvoid Py_IncRef(IntPtrob);
576575

576+
/// <summary>
577+
/// Export of Macro Py_XDecRef. Use XDecref instead.
578+
/// Limit this function usage for Testing and Py_Debug builds
579+
/// </summary>
580+
/// <param name="ob">PyObject Ptr</param>
577581
[DllImport(PythonDll)]
578-
privatestaticexternvoidPy_DecRef(IntPtrob);
579-
#endif
582+
internalstaticexternvoid Py_DecRef(IntPtrob);
580583

581584
[DllImport(PythonDll)]
582585
internalstaticexternvoid Py_Initialize();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp