[issue22543] -W option cannot use non-standard categories

2022-03-11 Thread Michael Merickel


Michael Merickel  added the comment:

Updated affected versions as I ran into this on 3.9.7.

--
nosy: +mmerickel
versions: +Python 3.9

___
Python tracker 

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



[issue22543] -W option cannot use non-standard categories

2021-06-24 Thread Omer Ozarslan


Change by Omer Ozarslan :


--
nosy: +ozars

___
Python tracker 

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



[issue22543] -W option cannot use non-standard categories

2020-03-18 Thread Brett Cannon


Change by Brett Cannon :


--
nosy:  -brett.cannon

___
Python tracker 

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



[issue22543] -W option cannot use non-standard categories

2020-01-04 Thread Feng Yu


Feng Yu  added the comment:

Coming here from 
https://github.com/astropy/astropy/issues/9832#issuecomment-570751353

Importing the named module during warning initialization is somewhat like code 
injection. And it may introduce unintended side-effects -- for example if this 
causes some 3rd party libraries to initialize too early?

String matching on the class name of every class in the hierarchy is safer, as 
there is no 'expected' code execution.

--
nosy: +Feng Yu

___
Python tracker 

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



[issue22543] -W option cannot use non-standard categories

2018-11-29 Thread kernc


Change by kernc :


--
nosy: +kernc

___
Python tracker 

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



[issue22543] -W option cannot use non-standard categories

2018-11-29 Thread Gerrit Holl


Gerrit Holl  added the comment:

There is a thread on StackOverflow related to this problem:

https://stackoverflow.com/q/42495641/974555

The (currently only and accepted) answer proposes as a workaround to set the 
PYTHONPATH variable, as the contents of those apparently *are* already in 
sys.path at the time warnings._processoptions is called, unlike site-packages.  
So manually adding site-packages to the PYTHONPATH variable does circumvent 
this problem (tested in Python 3.7.1).

--
nosy: +Gerrit.Holl
versions: +Python 3.6, Python 3.7

___
Python tracker 

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



[issue22543] -W option cannot use non-standard categories

2018-11-12 Thread Dmitry Shachnev


Change by Dmitry Shachnev :


--
nosy: +mitya57

___
Python tracker 

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



[issue22543] -W option cannot use non-standard categories

2018-09-07 Thread Thrlwiti


Change by Thrlwiti :


--
nosy: +THRlWiTi

___
Python tracker 

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



[issue22543] -W option cannot use non-standard categories

2016-09-14 Thread Torsten Landschoff

Torsten Landschoff added the comment:

Wow, this was news to me and I just ran into it in python 2.7. Checked in 
Python 3 and it's still there:

```
(py3)->torsten.landschoff@horatio:~$ python3 --version
Python 3.6.0a3+
(py3)->torsten.landschoff@horatio:~$ python3 -W error::sqlalchemy.exc.SAWarning 
-c "print()"
Invalid -W option ignored: invalid module name: 'sqlalchemy.exc'

```

I see no easy way to fix this. One way I thought about is to have hooks for 
importing of modules (called when a module is put into ``sys.modules``, not 
sure if there is something like this already) and have the warning system 
trigger on that.

There is no way to raise an exception before it is imported anyway...

--
nosy: +torsten

___
Python tracker 

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



[issue22543] -W option cannot use non-standard categories

2014-10-03 Thread Brett Cannon

Brett Cannon added the comment:

Doing the initialization later is not really an option as there can be warnings 
in the parser so it has to be resolved very early on.

I guess some form could be a possibility, but that's also tricky as subclass 
matching also still needs to work. I think we would need to see a patch on the 
proposed solution before considering its acceptance.

Another option would to parse it twice: once early on for Python internals and 
then again later once site-packages and various other things have been set up. 
Once again I would need to look at a patch before making a decision on whether 
it's an acceptable solution.

--
versions:  -Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22543
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22543] -W option cannot use non-standard categories

2014-10-02 Thread Rémi Rampin

New submission from Rémi Rampin:

warnings._processoptions is called very early, before site-packages are 
enabled. Because of this, using a non-standard 'category' will almost certainly 
fail with the message:

Invalid -W option ignored: invalid module name: '...'

The -W option would be a lot more useful if it could actually match 
non-standard categories (it does, after all, pretend to support 
modulename.classname).

I don't see any easy way of fixing this, other than initializing the warnings 
module later or matching category names with the given string (and getting rid 
of the import).

--
components: Library (Lib)
messages: 228261
nosy: remram
priority: normal
severity: normal
status: open
title: -W option cannot use non-standard categories
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22543
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22543] -W option cannot use non-standard categories

2014-10-02 Thread Antoine Pitrou

Antoine Pitrou added the comment:

How would this work? Would it auto-import the module?

--
nosy: +brett.cannon, pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22543
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22543] -W option cannot use non-standard categories

2014-10-02 Thread Rémi Rampin

Rémi Rampin added the comment:

It already does auto-import, but it does it before site-packages are set up, 
meaning that it fails in any practical setup.

See _getcategory(), called by _processoptions(): 
https://hg.python.org/cpython/file/b15c5a66213f/Lib/warnings.py#l148

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22543
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com