Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a14ff14

Browse files
committed
Combine Py_DEBUG and PYTHON_WITH_PYDEBUG flags
They both refer to the PyDebug builds but were added at different times. Closes pythonnet#362
1 parent 3225465 commit a14ff14

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/runtime/interop.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static ObjectOffset()
7575
{
7676
int size = IntPtr.Size;
7777
var n = 0; // Py_TRACE_REFS add two pointers to PyObject_HEAD
78-
#if Py_DEBUG
78+
#if PYTHON_WITH_PYDEBUG
7979
_ob_next = 0;
8080
_ob_prev = 1 * size;
8181
n = 2;
@@ -113,14 +113,14 @@ public static int Size(IntPtr ob)
113113
{
114114
return ExceptionOffset.Size();
115115
}
116-
#if Py_DEBUG
116+
#if PYTHON_WITH_PYDEBUG
117117
return 6 * IntPtr.Size;
118118
#else
119119
return 4 * IntPtr.Size;
120120
#endif
121121
}
122122

123-
#if Py_DEBUG
123+
#if PYTHON_WITH_PYDEBUG
124124
public static int _ob_next;
125125
public static int _ob_prev;
126126
#endif
@@ -185,7 +185,7 @@ static BytesOffset()
185185

186186
/* The *real* layout of a type object when allocated on the heap */
187187
//typedef struct _heaptypeobject {
188-
#if Py_DEBUG // #ifdef Py_TRACE_REFS
188+
#if PYTHON_WITH_PYDEBUG
189189
/* _PyObject_HEAD_EXTRA defines pointers to support a doubly-linked list of all live heap objects. */
190190
public static int _ob_next = 0;
191191
public static int _ob_prev = 0;

src/runtime/runtime.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects)
508508
/// </summary>
509509
internal static unsafe void XIncref(IntPtr op)
510510
{
511-
#if Py_DEBUG
511+
#if PYTHON_WITH_PYDEBUG
512512
// according to Python doc, Py_IncRef() is Py_XINCREF()
513513
Py_IncRef(op);
514514
return;
@@ -530,7 +530,7 @@ internal static unsafe void XIncref(IntPtr op)
530530

531531
internal static unsafe void XDecref(IntPtr op)
532532
{
533-
#if Py_DEBUG
533+
#if PYTHON_WITH_PYDEBUG
534534
// Py_DecRef calls Python's Py_DECREF
535535
// according to Python doc, Py_DecRef() is Py_XDECREF()
536536
Py_DecRef(op);
@@ -584,7 +584,7 @@ internal static unsafe long Refcount(IntPtr op)
584584
return 0;
585585
}
586586

587-
#if Py_DEBUG
587+
#if PYTHON_WITH_PYDEBUG
588588
// Py_IncRef and Py_DecRef are taking care of the extra payload
589589
// in Py_DEBUG builds of Python like _Py_RefTotal
590590
[DllImport(PythonDll)]
@@ -781,7 +781,7 @@ internal static unsafe IntPtr PyObject_TYPE(IntPtr op)
781781
{
782782
return IntPtr.Zero;
783783
}
784-
#if Py_DEBUG
784+
#if PYTHON_WITH_PYDEBUG
785785
var n = 3;
786786
#else
787787
var n = 1;

0 commit comments

Comments
 (0)