mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-29 17:33:08 +03:00
Merge pull request #3061 from kathryndavies/master
Fix a resource leak: close fp before return
This commit is contained in:
commit
8cc9713bd5
|
@ -112,7 +112,6 @@ class TestImage(PillowTestCase):
|
||||||
self.assertRaises(ValueError, im.save, temp_file)
|
self.assertRaises(ValueError, im.save, temp_file)
|
||||||
|
|
||||||
def test_internals(self):
|
def test_internals(self):
|
||||||
|
|
||||||
im = Image.new("L", (100, 100))
|
im = Image.new("L", (100, 100))
|
||||||
im.readonly = 1
|
im.readonly = 1
|
||||||
im._copy()
|
im._copy()
|
||||||
|
@ -122,8 +121,15 @@ class TestImage(PillowTestCase):
|
||||||
im.paste(0, (0, 0, 100, 100))
|
im.paste(0, (0, 0, 100, 100))
|
||||||
self.assertFalse(im.readonly)
|
self.assertFalse(im.readonly)
|
||||||
|
|
||||||
test_file = self.tempfile("temp.ppm")
|
def test_dump(self):
|
||||||
im._dump(test_file)
|
im = Image.new("L", (10, 10))
|
||||||
|
im._dump(self.tempfile("temp_L.ppm"))
|
||||||
|
|
||||||
|
im = Image.new("RGB", (10, 10))
|
||||||
|
im._dump(self.tempfile("temp_RGB.ppm"))
|
||||||
|
|
||||||
|
im = Image.new("HSV", (10, 10))
|
||||||
|
self.assertRaises(ValueError, im._dump, self.tempfile("temp_HSV.ppm"))
|
||||||
|
|
||||||
def test_comparison_with_other_type(self):
|
def test_comparison_with_other_type(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
|
|
|
@ -70,6 +70,7 @@ ImagingSavePPM(Imaging im, const char* outfile)
|
||||||
/* Write "PPM" */
|
/* Write "PPM" */
|
||||||
fprintf(fp, "P6\n%d %d\n255\n", im->xsize, im->ysize);
|
fprintf(fp, "P6\n%d %d\n255\n", im->xsize, im->ysize);
|
||||||
} else {
|
} else {
|
||||||
|
fclose(fp);
|
||||||
(void) ImagingError_ModeError();
|
(void) ImagingError_ModeError();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user