From 2d2691710c6c2d0ceb50733dd636a8a915487ff4 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sun, 3 Jul 2022 19:37:46 +0900 Subject: [PATCH] Exceptions with no argument should not set it to 'None' --- src/exceptions.c | 4 +++- test/testBareFinally.krk.expect | 2 +- test/testContextManagerException.krk.expect | 2 +- test/testContextManagerRaisesInExit.krk.expect | 2 +- test/testMultipleExcept.krk.expect | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/exceptions.c b/src/exceptions.c index 1c83461..30d0845 100644 --- a/src/exceptions.c +++ b/src/exceptions.c @@ -28,7 +28,9 @@ */ static KrkValue krk_initException(int argc, const KrkValue argv[], int hasKw) { KrkInstance * self = AS_INSTANCE(argv[0]); - krk_attachNamedValue(&self->fields, "arg", argc > 1 ? argv[1] : NONE_VAL()); + if (argc > 1) { + krk_attachNamedValue(&self->fields, "arg", argv[1]); + } return argv[0]; } diff --git a/test/testBareFinally.krk.expect b/test/testBareFinally.krk.expect index 87b3e92..e307e43 100644 --- a/test/testBareFinally.krk.expect +++ b/test/testBareFinally.krk.expect @@ -1,4 +1,4 @@ -ValueError(None) +ValueError() Done? try finally diff --git a/test/testContextManagerException.krk.expect b/test/testContextManagerException.krk.expect index 701ba71..5e82577 100644 --- a/test/testContextManagerException.krk.expect +++ b/test/testContextManagerException.krk.expect @@ -12,4 +12,4 @@ Before Entering Raising Exiting with [, , ] -ValueError(None) +ValueError() diff --git a/test/testContextManagerRaisesInExit.krk.expect b/test/testContextManagerRaisesInExit.krk.expect index d43d526..913fe1e 100644 --- a/test/testContextManagerRaisesInExit.krk.expect +++ b/test/testContextManagerRaisesInExit.krk.expect @@ -2,4 +2,4 @@ Before Entering Raising Exiting with [, , ] -TypeError(None) +TypeError() diff --git a/test/testMultipleExcept.krk.expect b/test/testMultipleExcept.krk.expect index 1535ea3..594829a 100644 --- a/test/testMultipleExcept.krk.expect +++ b/test/testMultipleExcept.krk.expect @@ -16,4 +16,4 @@ Running finally Function exit with Running finally -NameError was not caught: NameError(None) +NameError was not caught: NameError()