@@ -127,7 +127,7 @@ static void SetupImportHook()
127127 if ( Runtime . PyModule_AddObject ( ClrModuleReference , "loader" , import_hook_module ) != 0 )
128128 {
129129 Runtime . XDecref ( import_hook_module . DangerousGetAddress ( ) ) ;
130- throw new PythonException ( ) ;
130+ throw PythonException . ThrowLastAsClrException ( ) ;
131131 }
132132
133133 // Finally, add the hook to the meta path
@@ -157,7 +157,7 @@ static void SetupNamespaceTracking()
157157 {
158158 if ( Runtime . PySet_Add ( newset , new BorrowedReference ( pyNs ) ) != 0 )
159159 {
160- throw new PythonException ( ) ;
160+ throw PythonException . ThrowLastAsClrException ( ) ;
161161 }
162162 }
163163 finally
@@ -168,7 +168,7 @@ static void SetupNamespaceTracking()
168168
169169 if ( Runtime . PyDict_SetItemString ( root . dict , availableNsKey , newset . DangerousGetAddress ( ) ) != 0 )
170170 {
171- throw new PythonException ( ) ;
171+ throw PythonException . ThrowLastAsClrException ( ) ;
172172 }
173173 }
174174 finally
@@ -208,7 +208,7 @@ public static void OnNamespaceAdded(string name)
208208 {
209209 if ( Runtime . PySet_Add ( nsSet , new BorrowedReference ( pyNs ) ) != 0 )
210210 {
211- throw new PythonException ( ) ;
211+ throw PythonException . ThrowLastAsClrException ( ) ;
212212 }
213213 }
214214 }
@@ -275,7 +275,7 @@ public static ModuleObject Import(string modname)
275275 if ( ! ( mt is ModuleObject ) )
276276 {
277277 Exceptions . SetError ( Exceptions . ImportError , $ "'{ name } ' Is not a ModuleObject.") ;
278- throw new PythonException ( ) ;
278+ throw PythonException . ThrowLastAsClrException ( ) ;
279279 }
280280 if ( head == null )
281281 {
0 commit comments