File tree 2 files changed +22
-13
lines changed 2 files changed +22
-13
lines changed Original file line number Diff line number Diff line change @@ -168,16 +168,19 @@ internal static void Initialize() {
168
168
//===================================================================
169
169
170
170
internal static void Shutdown ( ) {
171
- Type type = typeof ( Exceptions ) ;
172
- foreach ( FieldInfo fi in type . GetFields ( BindingFlags . Public |
173
- BindingFlags . Static ) ) {
174
- IntPtr op = ( IntPtr ) fi . GetValue ( type ) ;
175
- if ( op != IntPtr . Zero ) {
176
- Runtime . Decref ( op ) ;
171
+ if ( 0 != Runtime . Py_IsInitialized ( ) ) {
172
+ Type type = typeof ( Exceptions ) ;
173
+ foreach ( FieldInfo fi in type . GetFields ( BindingFlags . Public |
174
+ BindingFlags . Static ) ) {
175
+ IntPtr op = ( IntPtr ) fi . GetValue ( type ) ;
176
+ if ( op != IntPtr . Zero ) {
177
+ Runtime . Decref ( op ) ;
178
+ }
177
179
}
180
+ Runtime . Decref ( exceptions_module ) ;
181
+ Runtime . PyObject_HasAttrString ( warnings_module , "xx" ) ;
182
+ Runtime . Decref ( warnings_module ) ;
178
183
}
179
- Runtime . Decref ( exceptions_module ) ;
180
- Runtime . Decref ( warnings_module ) ;
181
184
}
182
185
183
186
/// <summary>
Original file line number Diff line number Diff line change @@ -79,14 +79,20 @@ internal static void Initialize() {
79
79
80
80
internal static void Shutdown ( ) {
81
81
#if ( PYTHON32 || PYTHON33 || PYTHON34 )
82
- Runtime . Decref ( py_clr_module ) ;
83
- Runtime . Decref ( root . pyHandle ) ;
82
+ if ( 0 != Runtime . Py_IsInitialized ( ) ) {
83
+ Runtime . Decref ( py_clr_module ) ;
84
+ Runtime . Decref ( root . pyHandle ) ;
85
+ }
84
86
ModuleDefOffset . FreeModuleDef ( module_def ) ;
85
87
#else
86
- Runtime . Decref ( root . pyHandle ) ;
87
- Runtime . Decref ( root . pyHandle ) ;
88
+ if ( 0 != Runtime . Py_IsInitialized ( ) ) {
89
+ Runtime . Decref ( root . pyHandle ) ;
90
+ Runtime . Decref ( root . pyHandle ) ;
91
+ }
88
92
#endif
89
- Runtime . Decref ( py_import ) ;
93
+ if ( 0 != Runtime . Py_IsInitialized ( ) ) {
94
+ Runtime . Decref ( py_import ) ;
95
+ }
90
96
}
91
97
92
98
//===================================================================
You can’t perform that action at this time.
0 commit comments