Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't remove traceback on rethrow #737

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Src/IronPython/Compiler/Ast/AstMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ internal static class AstMethods {
public static readonly MethodInfo RemoveModule = GetMethod((Action<CodeContext, string, object>)PythonOps.RemoveModule);
public static readonly MethodInfo ModuleStarted = GetMethod((Action<CodeContext, ModuleOptions>)PythonOps.ModuleStarted);
public static readonly MethodInfo MakeRethrownException = GetMethod((Func<CodeContext, Exception>)PythonOps.MakeRethrownException);
public static readonly MethodInfo MakeRethrowExceptionWorker = GetMethod((Func<Exception, Exception>)PythonOps.MakeRethrowExceptionWorker);
public static readonly MethodInfo MakeException = GetMethod((Func<CodeContext, object, Exception>)PythonOps.MakeException);
public static readonly MethodInfo MakeExceptionWithCause = GetMethod((Func<CodeContext, object, object, Exception>)PythonOps.MakeExceptionWithCause);
public static readonly MethodInfo MakeSlice = GetMethod((Func<object, object, object, Slice>)PythonOps.MakeSlice);
Expand Down
4 changes: 2 additions & 2 deletions Src/IronPython/Compiler/Ast/WithStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ public override MSAst.Expression Reduce() {
UpdateLineUpdated(true),
Ast.Throw(
Ast.Call(
AstMethods.MakeRethrowExceptionWorker,
exception
AstMethods.MakeRethrownException,
Parent.LocalContext
)
)
)
Expand Down
15 changes: 1 addition & 14 deletions Src/IronPython/Runtime/Operations/PythonOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2351,20 +2351,7 @@ public static PythonTuple GetExceptionInfo(CodeContext/*!*/ context) {
public static Exception MakeRethrownException(CodeContext/*!*/ context) {
PythonTuple t = GetExceptionInfo(context);
Debug.Assert(t[1] == GetRawContextException());
Exception e = MakeExceptionWorker(context, t[0], t[1], t[2], null, suppressContext: false, forRethrow: true);
return MakeRethrowExceptionWorker(e);
}

/// <summary>
/// helper function for re-raised exception.
/// This entry point is used by 'raise' inside 'with' statement
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
public static Exception MakeRethrowExceptionWorker(Exception e) {
e.RemoveTraceBack();
ExceptionHelpers.UpdateForRethrow(e);
return e;
return MakeExceptionWorker(context, t[0], t[1], t[2], null, suppressContext: false, forRethrow: true);
}

public static Exception MakeException(CodeContext/*!*/ context, object exception) {
Expand Down