16.04.21 16:07, Victor Stinner пише:
> I propose to change the -W command line option and the PYTHONWARNINGS
> environment variable to use the message as a regular expression in
> Python 3.10. Or does anyone have a reason to keep the current behavior
> as it is?
> 
> I created https://bugs.python.org/issue43862 for this change.

It is known issue, but changing it is would break compatibility. The
warning message can contain characters which have special meaning in
regular expressions (e.g. "(" and "?"). Event if it can be parsed as a
regular expression, it can stop to work.

It would be more safe to add some flag which control whether the message
is a pattern or literal. For example, if it starts with "/" it is a
pattern (no warning message or module name starts with "/").

Module name also should support regular expressions.

Note also that specifying message or module name in the -W option or the
PYTHONWARNINGS environment variable causes importing the re module at
the start of the interpreter, and it nontrivially increases the starting
time.

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/UCFRLK3HCVLJ25VM3OL45XVXC4KMFLTR/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to