ResourceWarning: unclosed file for pygame_icon.bmp

Lenard Lindstrom avatarLenard Lindstrom created an issue

Python3.3-dbg on Linux Mint 14 Nadia

The surface_test.py unit test raises a ResourceWarning when executing line

screen = pygame.display.set_mode((640, 480))

in SurfaceFillTest.test_fill(). The icon file is not explicitly closed. Since reference counting is not guaranteed for future C Python interpreters this should be fixed.

Comments (3)

  1. illume

    Investigation of display.c for font loading lead me to image.c and pygame.image.load_basic.

    It seems image.c frees the file in the load_basic function "surf = SDL_LoadBMP_RW (rw, 1);" The 1 argument frees the stream when done loading. The the icon file should be closed.

    I tried adding "icon_was_set = 0;" to display.c in commit ee208d8. Which should make it try to set the icon again if it is quit first. Which I think is appropriate.

    That's all I looked into, since I'm not currently on a linux box.

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.