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

Torsten Landschoff report at bugs.python.org
Wed Sep 14 07:18:12 EDT 2016


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 at horatio:~$ python3 --version
Python 3.6.0a3+
(py3)->torsten.landschoff at 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 <report at bugs.python.org>
<http://bugs.python.org/issue22543>
_______________________________________


More information about the Python-bugs-list mailing list