def _isdst(self, dt): try: return super(LocalTimezone, self)._isdst(dt) except (OverflowError, ValueError) as exc: exc_type = type(exc) exc_value = exc_type( "Unsupported value: %r. You should install pytz." % dt) exc_value.__cause__ = exc if not hasattr(exc, '__traceback__'): exc.__traceback__ = sys.exc_info()[2] reraise(exc_type, exc_value, sys.exc_info()[2])
def restore_exception(provider): if provider.local_exceptions.exc_info is not None: try: reraise(*provider.local_exceptions.exc_info) finally: provider.local_exceptions.exc_info = None