Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bad_exception_context.py 765B

123456789101112131415161718192021222324
  1. """Check that raise ... from .. uses a proper exception context """
  2. # pylint: disable=unreachable, import-error, multiple-imports
  3. import socket, unknown
  4. __revision__ = 0
  5. class ExceptionSubclass(Exception):
  6. """ subclass """
  7. def test():
  8. """ docstring """
  9. raise IndexError from 1 # [bad-exception-context]
  10. raise IndexError from None
  11. raise IndexError from ZeroDivisionError
  12. raise IndexError from object() # [bad-exception-context]
  13. raise IndexError from ExceptionSubclass
  14. raise IndexError from socket.error
  15. raise IndexError() from None
  16. raise IndexError() from ZeroDivisionError
  17. raise IndexError() from ZeroDivisionError()
  18. raise IndexError() from object() # [bad-exception-context]
  19. raise IndexError() from unknown