Empty Catch Block (ARCH2150)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key python.logging.empty-except-block · Severity error · Category logging
An except block with an empty body (or only comments) silently swallows the exception. This hides real failures and makes problems almost impossible to diagnose.
Incorrect
Section titled “Incorrect”try: value = int(user_input)except ValueError: passCorrect
Section titled “Correct”import logging
logger = logging.getLogger(__name__)
try: value = int(user_input)except ValueError: logger.warning("Invalid integer input: %r", user_input) value = 0Log the exception at minimum; produce a meaningful default or re-raise where possible.