def deprecation(message): warnings.warn(message, DeprecationWarning, level=2)
This makes the warning refer to deprecation()'s caller, rather than to the source of deprecation() itself (since the latter would defeat the purpose of the warning message).
showwarning(message, category, filename,
lineno)
and writes the resulting string to file, which
defaults to sys.stderr
. You may replace this function with an
alternative implementation by assigning to
warnings.showwarning
.