What appropriate built-in exception should I raise if your library is used with the wrong version of Python?

I have a simple library distributed as a .py file. I would like to throw an exception if the library is called from Python 2 instead of Python 3:

def _check_version():
    if sys.version_info < (3,):
        raise _____Exception('This library depends on Python 3 strings. Please ensure you are using Python 3 instead of Python 2')

What built-in exception should I raise? (How to fill in the blank above?) The closest exception I can find among builtin Exceptions is NotImplementedError. DeprecationWarning feels close, but an exception is more appropriate in this case.

+4
source share
1 answer
+7

Source: https://habr.com/ru/post/1685491/


All Articles