booglybob / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

ResourceWarning since images opened with pyglet.resource.loader.image(..) isnt closed #695

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Have you tried Pyglet 1.2 alpha1 or the repository code?
The latest repository code as of Dec 15.
python 3.3.3

Paste in the traceback or error message:
The following warning is printed:
/usr/local/lib/python3.3/dist-packages/pyglet/resource.py:523: ResourceWarning: 
unclosed file <_io.BufferedReader name='./preview.png'>

The reason for the problem is that pyglet.resource.loader.image does not close 
the file but instead wait for the GC to fix it. This is considered bad practice 
and is the reason for the warning printed with -Wdefault. -Wdefault is active 
as standard when running the unittest module causing a lot of warning messages 
when running unittests.

Code to reproduce the error and a patch is attached.

Original issue reported on code.google.com by norberg....@gmail.com on 28 Dec 2013 at 5:55

Attachments:

GoogleCodeExporter commented 8 years ago
Missed instruction on how to reproduce the error:
run: python3  -Wdefault  test_pyglet_error.py

Original comment by norberg....@gmail.com on 28 Dec 2013 at 5:59

GoogleCodeExporter commented 8 years ago
I can't reproduce the problem with Python 2.7.5, but I can confirm the problem 
with Python 3.3.2.

Good catch!

Original comment by useboxnet on 3 Jan 2014 at 3:38

GoogleCodeExporter commented 8 years ago
This issue was closed by revision c43bc57c954f.

Original comment by useboxnet on 3 Jan 2014 at 5:11