@@ -179,6 +179,40 @@ internal static void Initialize(bool initSigs = false, ShutdownMode mode = Shutd
179179 ClassDerivedObject . Reset ( ) ;
180180 TypeManager . Initialize ( ) ;
181181
182+ InitPyMembers ( ) ;
183+
184+ // Initialize data about the platform we're running on. We need
185+ // this for the type manager and potentially other details. Must
186+ // happen after caching the python types, above.
187+ NativeCodePageHelper . InitializePlatformData ( ) ;
188+
189+ // Initialize modules that depend on the runtime class.
190+ AssemblyManager . Initialize ( ) ;
191+ #if ! NETSTANDARD
192+ if ( mode == ShutdownMode . Reload && RuntimeData . HasStashData ( ) )
193+ {
194+ RuntimeData . StashPop ( ) ;
195+ }
196+ else
197+ #endif
198+ {
199+ PyCLRMetaType = MetaType . Initialize ( ) ; // Steal a reference
200+ }
201+ Exceptions . Initialize ( ) ;
202+ ImportHook . Initialize ( ) ;
203+
204+ // Need to add the runtime directory to sys.path so that we
205+ // can find built-in assemblies like System.Data, et. al.
206+ string rtdir = RuntimeEnvironment . GetRuntimeDirectory ( ) ;
207+ IntPtr path = PySys_GetObject ( "path" ) ;
208+ IntPtr item = PyString_FromString ( rtdir ) ;
209+ PyList_Append ( path , item ) ;
210+ XDecref ( item ) ;
211+ AssemblyManager . UpdatePath ( ) ;
212+ }
213+
214+ private static void InitPyMembers ( )
215+ {
182216 IntPtr op ;
183217 {
184218 var builtins = GetBuiltins ( ) ;
@@ -300,36 +334,6 @@ internal static void Initialize(bool initSigs = false, ShutdownMode mode = Shutd
300334 PyModuleType = PyObject_Type ( sys ) ;
301335 XDecref ( sys ) ;
302336 }
303-
304- // Initialize data about the platform we're running on. We need
305- // this for the type manager and potentially other details. Must
306- // happen after caching the python types, above.
307- NativeCodePageHelper . InitializePlatformData ( ) ;
308-
309- // Initialize modules that depend on the runtime class.
310- AssemblyManager . Initialize ( ) ;
311- #if ! NETSTANDARD
312- if ( mode == ShutdownMode . Reload && RuntimeData . HasStashData ( ) )
313- {
314- RuntimeData . StashPop ( ) ;
315- RuntimeData . ClearStash ( ) ;
316- }
317- else
318- #endif
319- {
320- PyCLRMetaType = MetaType . Initialize ( ) ; // Steal a reference
321- }
322- Exceptions . Initialize ( ) ;
323- ImportHook . Initialize ( ) ;
324-
325- // Need to add the runtime directory to sys.path so that we
326- // can find built-in assemblies like System.Data, et. al.
327- string rtdir = RuntimeEnvironment . GetRuntimeDirectory ( ) ;
328- IntPtr path = PySys_GetObject ( "path" ) ;
329- IntPtr item = PyString_FromString ( rtdir ) ;
330- PyList_Append ( path , item ) ;
331- XDecref ( item ) ;
332- AssemblyManager . UpdatePath ( ) ;
333337 }
334338
335339 private static IntPtr Get_PyObject_NextNotImplemented ( )
0 commit comments