8000 fix new exception usage · pythonnet/pythonnet@970a189 · GitHub
[go: up one dir, main page]

Skip to content

Commit 970a189

Browse files
committed
fix new exception usage
1 parent c02d5c6 commit 970a189

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/runtime/importhook.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
{

src/runtime/moduleobject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public void LoadNames()
196196
{
197197
if (Runtime.PyList_Append(new BorrowedReference(__all__), pyname) != 0)
198198
{
199-
throw new PythonException();
199+
throw PythonException.ThrowLastAsClrException();
200200
}
201201
}
202202
finally

0 commit comments

Comments
 (0)
0