blob: 0e876a073d19e0c0396e3f6bec38a04fd84e5a67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
"""Check that raise ... from .. uses a proper exception cause """
# pylint: disable=unreachable, import-error, multiple-imports
import socket, unknown
__revision__ = 0
class ExceptionSubclass(Exception):
""" subclass """
def test():
""" docstring """
raise IndexError from 1 # [bad-exception-cause]
raise IndexError from None
raise IndexError from ZeroDivisionError
raise IndexError from object() # [bad-exception-cause]
raise IndexError from ExceptionSubclass
raise IndexError from socket.error
raise IndexError() from None
raise IndexError() from ZeroDivisionError
raise IndexError() from ZeroDivisionError()
raise IndexError() from object() # [bad-exception-cause]
raise IndexError() from unknown
def function():
"""Function to be passed as exception"""
try:
pass
except function as exc: # [catching-non-exception]
raise Exception from exc # [bad-exception-cause]
|