[PyQt] Resource leak in uic/objcreator.py

Phil Thompson phil at riverbankcomputing.com
Mon May 18 17:41:48 BST 2015


On 14/05/2015 11:43 am, Dmitry Shachnev wrote:
> Hi,
> 
> In Ubuntu we usually run tests with PYTHONWARNINGS=d, and we get a lot 
> of
> warnings like this for some packages, when running pyuic5:
> 
> /usr/lib/python3/dist-packages/PyQt5/uic/objcreator.py:91:
> DeprecationWarning: 'U' mode is deprecated
>   if load_plugin(open(filename, 'rU'), plugin_globals, plugin_locals):
> /usr/lib/python3/dist-packages/PyQt5/uic/objcreator.py:91:
> ResourceWarning: unclosed file <_io.TextIOWrapper
> name='/usr/lib/python3/dist-packages/PyQt5/uic/widget-plugins/qtprintsupport.py'
> mode='rU' encoding='ANSI_X3.4-1968'>
>   if load_plugin(open(filename, 'rU'), plugin_globals, plugin_locals):
> /usr/lib/python3/dist-packages/PyQt5/uic/objcreator.py:91:
> ResourceWarning: unclosed file <_io.TextIOWrapper
> name='/usr/lib/python3/dist-packages/PyQt5/uic/widget-plugins/qtquickwidgets.py'
> mode='rU' encoding='ANSI_X3.4-1968'>
>   if load_plugin(open(filename, 'rU'), plugin_globals, plugin_locals):
> [...]
> 
> See for example log at [1].
> 
> While the deprecation warning is harmless and unavoidable in a Python 
> 2/3 code,
> the resource warnings can be easily fixed creating a file variable and 
> calling
> close() on it when it is no longer needed. Can you please do that?

Should be fixed in tonight's PyQt4 and PyQt5 snapshots.

Thanks,
Phil


More information about the PyQt mailing list