diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index ae4c744ead7b..479dcbfd289d 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -394,8 +394,9 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags; expectedType: PType = nil) elif a.len == 1: # count number of ``except: body`` blocks inc catchAllExcepts - message(c.config, a.info, warnBareExcept, - "The bare except clause is deprecated; use `except CatchableError:` instead") + if noPanicOnExcept in c.graph.config.legacyFeatures: + message(c.config, a.info, warnBareExcept, + "The bare except clause is deprecated; use `except CatchableError:` instead") else: # support ``except KeyError, ValueError, ... : body`` if catchAllExcepts > 0: diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index 38890b0d4f14..f1e6138e45b1 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -547,14 +547,11 @@ template test*(name, body) {.dirty.} = for formatter in formatters: formatter.testStarted(name) - {.push warning[BareExcept]:off.} try: when declared(testSetupIMPLFlag): testSetupIMPL() when declared(testTeardownIMPLFlag): defer: testTeardownIMPL() - {.push warning[BareExcept]:on.} body - {.pop.} except Exception: let e = getCurrentException() @@ -577,7 +574,6 @@ template test*(name, body) {.dirty.} = ) testEnded(testResult) checkpoints = @[] - {.pop.} proc checkpoint*(msg: string) = ## Set a checkpoint identified by `msg`. Upon test failure all @@ -801,11 +797,8 @@ macro expect*(exceptions: varargs[typed], body: untyped): untyped = discard template expectBody(errorTypes, lineInfoLit, body): NimNode {.dirty.} = - {.push warning[BareExcept]:off.} try: - {.push warning[BareExcept]:on.} body - {.pop.} checkpoint(lineInfoLit & ": Expect Failed, no exception was thrown.") fail() except errorTypes: @@ -814,8 +807,6 @@ macro expect*(exceptions: varargs[typed], body: untyped): untyped = let err = getCurrentException() checkpoint(lineInfoLit & ": Expect Failed, " & $err.name & " was thrown.") fail() - {.pop.} - var errorTypes = newNimNode(nnkBracket) var hasException = false for exp in exceptions: