>> Therefore it's not redundant to subclass *Warning for namespacing alone.
>
> Not redundant? You mean you must subclass? In that case my concern stands.
An unfortunate typo, meant "it's redundant".
> And what does that match against? The module name of the exception type right?
It matches agains a location where warn is called after taking stacklevel into
account.
Consider the following example:
test.py:
import warnings
warnings.warn("test")
warnings.warn("__main__ from test", stacklevel=2)
$ python -c "import warnings, test; warnings.warn('__main__')"
test.py:2: UserWarning: test
warnings.warn("test")
-c:1: UserWarning: __main__ from test
-c:1: UserWarning: __main__
$ python -W "ignore:::test:" -c "import warnings, test;
warnings.warn('__main__')"
-c:1: UserWarning: __main__ from test
-c:1: UserWarning: __main__
$ python -W "ignore:::__main__:" -c "import warnings, test;
warnings.warn('__main__')"
test.py:2: UserWarning: test
warnings.warn("test")
End-user can distinguish warnings of the same category by specifying their
origin (where warning is issued in runtime).
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/