[PyQt] Resource leak in uic/objcreator.py

Dmitry Shachnev mitya57 at ubuntu.com
Thu May 14 11:43:46 BST 2015


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?

[1]: https://jenkins.qa.ubuntu.com/job/wily-adt-apport/6/ARCH=i386,label=adt/console

--
Dmitry Shachnev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150514/ef9472af/attachment.sig>


More information about the PyQt mailing list