[issue34624] -W option and PYTHONWARNINGS env variable does not accept module regexes

2021-12-20 Thread Thomas Gläßle

Change by Thomas Gläßle :


--
stage: patch review -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue34624>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34624] -W option and PYTHONWARNINGS env variable does not accept module regexes

2021-12-20 Thread Thomas Gläßle

Thomas Gläßle  added the comment:

Ok, it seems at least the incorrect documentation has been fixed in the mean 
time.

I'm going to close this as there seems to be no capacity to deal with this.

--

___
Python tracker 
<https://bugs.python.org/issue34624>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34624] -W option and PYTHONWARNINGS env variable does not accept module regexes

2020-07-11 Thread Thomas Gläßle

Thomas Gläßle  added the comment:

Hi, I have rebased this on master and fixed the minor conflict. Let me know if 
there is anything else I can do.

Best, Thomas

--
versions: +Python 3.10, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue34624>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34624] -W option and PYTHONWARNINGS env variable does not accept module regexes

2018-10-27 Thread Thomas Gläßle

Thomas Gläßle  added the comment:

Hi, thanks for the consideration!

Is there any reason to introduce different behaviour than with filterwarnings 
here? This increases the number of things to remember - and except for the dot 
regex syntax doesn't interfere with module names, so there is no big drawback 
here either.

More importantly, my main use case for filterwarnings would be to select/ignore 
warnings based on module *or package* name. With the current interpretation as 
exact module name, you have to list all submodules in advance, which is quite 
inhibiting.

I have fixed the `[.*]` bogus example in the PR.

Best, Thomas

--

___
Python tracker 
<https://bugs.python.org/issue34624>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34624] -W option does not accept module regexes

2018-09-17 Thread Thomas Gläßle

Thomas Gläßle  added the comment:

Thanks for your response. I have opened a PR at [1] that would remove the 
re.escape such that the implementation matches the documentation if you decide 
that this is fine.

[1]: https://github.com/python/cpython/pull/9358

Personally, I would go even further and always add the `(\..*)?$` suffix 
(instead of only `$`) to make it easier to match all modules in a package which 
is probably the most important use-case for the case of packages. What do you 
think?

--

___
Python tracker 
<https://bugs.python.org/issue34624>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34624] -W option does not accept module regexes

2018-09-17 Thread Thomas Gläßle

Change by Thomas Gläßle :


--
keywords: +patch
pull_requests: +8781
stage:  -> patch review

___
Python tracker 
<https://bugs.python.org/issue34624>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34624] -W option does not accept module regexes

2018-09-10 Thread Thomas Gläßle

Thomas Gläßle  added the comment:

Very sorry, the example command above should read:

  python -Wi -W'default:::.*' -c 'import warnings; warnings.warn("This should 
show up")'

--

___
Python tracker 
<https://bugs.python.org/issue34624>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34624] -W option does not accept module regexes

2018-09-10 Thread Thomas Gläßle

New submission from Thomas Gläßle :

Hi,

This command does not report a warning, while it should:

  python -c 'import warnings; warnings.warn("This should show up")' -Wi 
-W'default:::.*'

If the regex `.*` is replaced by `__main__` it works as expected.

Same applies for regexes in PYTHONWARNINGS and for the `message` part of the 
argument. 

The reason can be found in Lib/warnings.py:144 (def _setoption):

  module = re.escape(module)

This point-blank escape makes me think that it was intended that no regexes can 
be passed to message/module. On the other, the documentation reads as if it 
should be supported.

Specifically, the -W option is documented in [1]. While this page lists only 
basic examples, it refers to [2] and [3] for more details. [2] states that 
message/module are regexes. [3] seems to be written to specifically address the 
syntax of the PYTHONWARNINGS and the -W option and explicitly lists an example 
with a regex.

[1]: https://docs.python.org/3/using/cmdline.html#cmdoption-w
[2]: https://docs.python.org/3/library/warnings.html#warning-filter
[3]: https://docs.python.org/3/library/warnings.html#describing-warning-filters

I would welcome if we could remove `re.escape` to make the implementation fit 
the documentation, or are there any downsides to this?


Best regards, Thomas

--
components: Library (Lib)
messages: 324959
nosy: coldfix
priority: normal
severity: normal
status: open
title: -W option does not accept module regexes
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 
<https://bugs.python.org/issue34624>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com