Checking if exceptions module can be imported as it's removed from Python3

Fixes #18068