Message237050
The issue occurs only if C implementation of _warnings is available. It is caused by re-use of global filters variable from _warnings when warnings is being re-imported.
So warnings modifies _warnings.filters on first import. Then, when you import warnings again it uses already modified version of _warnings.filters and adds same filter for the second time.
I attach a simple patch that prevents duplicates in filters. I'm not sure if this is a best way to fix the problem, but it works. It certainly affects performance of filterwarnings(), but there shouldn't be a lot of filters anyway.
Making filters a set() will solve the problem also, but will require API changes. Although I didn't find anywhere in documentation that warnings.filters should be a list, someone might rely on its .append() method. |
|
Date |
User |
Action |
Args |
2015-03-02 15:24:04 | ashkop | set | recipients:
+ ashkop, ezio.melotti, flox, serhiy.storchaka |
2015-03-02 15:24:04 | ashkop | set | messageid: <1425309844.51.0.837899954192.issue18383@psf.upfronthosting.co.za> |
2015-03-02 15:24:04 | ashkop | link | issue18383 messages |
2015-03-02 15:24:04 | ashkop | create | |
|