The code you're attached to has another additional exception handler:
try: yield safe_join(template_dir, template_name) except UnicodeDecodeError:
Since UnicodeDecodeError is a subclass of ValueError , the second exception handler will ignore any UnicodeDecodeError . This does not seem to be the intended effect, and to avoid this, the UnicodeDecodeError handler UnicodeDecodeError explicitly handled by the first handler. Thus, together with both handlers, a ValueError ignored if it is not a UnicodeDecodeError .
source share