Built-in Exceptions
FutureWarning — exception class
Indicates deprecated behavior when the intended audience is end users of Python applications. Explain the replacement and migration path rather than rely on a default filter. The example explicitly promotes this warning category to an exception to make the result independent of default filters. Catch FutureWarning when this category is the recovery boundary; do not rely on the exact human-readable message.
Formal Syntax & Structure
python syntaxpython
FutureWarningReturn Value
type
The class object FutureWarning; this reference documents the class identity, not a universal constructor signature.
Working Example
Example Snippetpython
import warningstry: with warnings.catch_warnings(): warnings.simplefilter("error", FutureWarning) warnings.warn("demo", FutureWarning)except FutureWarning as error: print(type(error).__name__)