Skip to content

Commit d2bfa49

Browse files
committed
Fix Python 2 compatibility.
1 parent 82fdc39 commit d2bfa49

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/runtime/interop.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,41 +89,35 @@ static ObjectOffset()
8989

9090
public static int magic(IntPtr ob)
9191
{
92-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
9392
if ((Runtime.PyObject_TypeCheck(ob, Exceptions.BaseException) ||
9493
(Runtime.PyType_Check(ob) && Runtime.PyType_IsSubtype(ob, Exceptions.BaseException))))
9594
{
9695
return ExceptionOffset.ob_data;
9796
}
98-
#endif
9997
return ob_data;
10098
}
10199

102100
public static int DictOffset(IntPtr ob)
103101
{
104-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
105102
if ((Runtime.PyObject_TypeCheck(ob, Exceptions.BaseException) ||
106103
(Runtime.PyType_Check(ob) && Runtime.PyType_IsSubtype(ob, Exceptions.BaseException))))
107104
{
108105
return ExceptionOffset.ob_dict;
109106
}
110-
#endif
111107
return ob_dict;
112108
}
113109

114110
public static int Size(IntPtr ob)
115111
{
116-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
117112
if ((Runtime.PyObject_TypeCheck(ob, Exceptions.BaseException) ||
118113
(Runtime.PyType_Check(ob) && Runtime.PyType_IsSubtype(ob, Exceptions.BaseException))))
119114
{
120115
return ExceptionOffset.Size();
121116
}
122-
#endif
123117
#if (Py_DEBUG)
124118
return 6 * IntPtr.Size;
125119
#else
126-
return 4*IntPtr.Size;
120+
return 4 * IntPtr.Size;
127121
#endif
128122
}
129123

@@ -137,7 +131,6 @@ public static int Size(IntPtr ob)
137131
private static int ob_data;
138132
}
139133

140-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
141134
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
142135
internal class ExceptionOffset
143136
{
@@ -161,15 +154,21 @@ public static int Size()
161154
// (start after PyObject_HEAD)
162155
public static int dict = 0;
163156
public static int args = 0;
157+
#if (PYTHON25 || PYTHON26 || PYTHON27)
158+
public static int message = 0;
159+
#elif (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
164160
public static int traceback = 0;
165161
public static int context = 0;
166162
public static int cause = 0;
163+
#if !PYTHON32
164+
public static int suppress_context = 0;
165+
#endif
166+
#endif
167167

168168
// extra c# data
169169
public static int ob_dict;
170170
public static int ob_data;
171171
}
172-
#endif
173172

174173

175174
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)

0 commit comments

Comments
 (0)