While upgrading Django, I noted the following error while running pytest with -Wa flags enabled & PYTHONWARNINGS=always in my env:
/usr/local/lib/python3.10/dist-packages/avatar/models.py:201: ResourceWarning: unclosed file <_io.BufferedReader name='/tmp/tmphkurztys/img/avatar/1/29711aa648bad2dca40e2463dc8761cb.gif'>
instance.create_thumbnail(size, size)
Enable tracemalloc to get traceback where the object was allocated.
See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
Hopping into a debugger, I can see that by the bottom of the function both have a closed property of False:
The
File
orig
andContentFile
thumb_file
variables created inAvatar.create_thumbnail
do not appear to be closed before the method returns: https://github.com/jazzband/django-avatar/blob/main/avatar/models.py#L142Django:
4.1.13
django-avatar:8.0.0
Python 3.10While upgrading Django, I noted the following error while running pytest with
-Wa
flags enabled &PYTHONWARNINGS=always
in my env:Hopping into a debugger, I can see that by the bottom of the function both have a
closed
property ofFalse
: