Python Glossary Русский

all Python 3Exceptionsexception

FutureWarning

built-in exceptions

Warns end users about behaviour that will change in a future version.

Syntax

raise FutureWarning

This is a warning, not an error: you emit it with warnings.warn(..., FutureWarning) rather than raise, and execution continues afterwards. The split from DeprecationWarning is about audience — FutureWarning is shown by default and speaks to people merely using a library, while DeprecationWarning is hidden outside __main__ by default and speaks to developers. To make such a warning fail a run, say in tests, start Python with -W error::FutureWarning.

Examples

try:
    raise FutureWarning
except FutureWarning as e:
    print(type(e).__name__)   # → FutureWarning

See also

Open in the full glossarydocs.python.orgReport an inaccuracy