Files
codeql/python/ql/test/2/query-tests/Exceptions/general/exceptions_test.py
Owen Mansel-Chan 8e07690049 Python
2026-06-10 22:57:42 +02:00

18 lines
540 B
Python

def fail_batch_and_raise(exception):
if exception is None:
raise Exception()
elif exc_info is not None:
#This failed due to incorrect inference of the class of type(exception) as type.
raise type(exception), exception, exc_info[2]
#Weird Python2 nonsense.
def raise_tuple(cond):
if cond:
# This is OK. Honestly. Thankfully it's fixed in Python 3.
raise (Exception, "bananas", 17)
else:
#This is an error
raise (17, "bananas", Exception) # $ Alert[py/illegal-raise]