This is because TypeErrors aren't properly caught. See Python 2 docs:
Note that the parentheses around this tuple are required, because except ValueError, e: was the syntax used for what is normally written as except ValueError as e: in modern Python (described below). The old syntax is still supported for backwards compatibility. This means except RuntimeError, TypeError is not equivalent to except (RuntimeError, TypeError): but to except RuntimeError as TypeError: which is not what you want.
A 500 error occurs when querying a redirect URL without all date components (
year
,month
,day
), e.g.http://www.consumerfinance.gov/eregulations/regulation_redirect/1004-4
This is because
TypeError
s aren't properly caught. See Python 2 docs: