@@ -1128,13 +1128,31 @@ internal static int PyObject_Compare(IntPtr value1, IntPtr value2)
1128
1128
internal static nint PyObject_Hash ( IntPtr op ) => Delegates . PyObject_Hash ( op ) ;
1129
1129
1130
1130
1131
- internal static IntPtr PyObject_Repr ( IntPtr pointer ) => Delegates . PyObject_Repr ( pointer ) ;
1131
+ internal static IntPtr PyObject_Repr ( IntPtr pointer )
1132
+ {
1133
+ AssertNoErorSet ( ) ;
1132
1134
1135
+ return Delegates . PyObject_Repr ( pointer ) ;
1136
+ }
1133
1137
1134
1138
internal static IntPtr PyObject_Str ( IntPtr pointer ) => Delegates . PyObject_Str ( pointer ) ;
1135
1139
1136
1140
1137
- internal static IntPtr PyObject_Unicode ( IntPtr pointer ) => Delegates . PyObject_Unicode ( pointer ) ;
1141
+ internal static IntPtr PyObject_Unicode ( IntPtr pointer )
1142
+ {
1143
+ AssertNoErorSet ( ) ;
1144
+
1145
+ return Delegates . PyObject_Unicode ( pointer ) ;
1146
+ }
1147
+
1148
+ [ Conditional ( "DEBUG" ) ]
1149
+ internal static void AssertNoErorSet ( )
1150
+ {
1151
+ if ( Exceptions . ErrorOccurred ( ) )
1152
+ throw new InvalidOperationException (
1153
+ "Can't call with exception set" ,
1154
+ PythonException . FetchCurrent ( ) ) ;
1155
+ }
1138
1156
1139
1157
1140
1158
internal static IntPtr PyObject_Dir ( IntPtr pointer ) => Delegates . PyObject_Dir ( pointer ) ;