8000 [3.11] gh-107705: Fix file leak in test_tkinter in the C locale (GH-110507) by miss-islington · Pull Request #110858 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.11] gh-107705: Fix file leak in test_tkinter in the C locale (GH-110507) #110858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-107705: Fix file leak in test_tkinter in the C locale (GH-110507)
(cherry picked from commit ca0f3d8)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
  • Loading branch information
serhiy-storchaka authored and miss-islington committed Oct 14, 2023
commit ce5808b38f4cd4107595dbcdfb3dcec99a2298ce
15 changes: 10 additions & 5 deletions Lib/tkinter/test/test_tkinter/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,24 +357,29 @@ def test_get(self):
self.assertRaises(tkinter.TclError, image.get, 15, 16)

def test_write(self):
filename = os_helper.TESTFN
import locale
if locale.getlocale()[0] is None:
# Tcl uses Latin1 in the C locale
filename = os_helper.TESTFN_ASCII
image = self.create()
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
self.addCleanup(os_helper.unlink, filename)

image.write(os_helper.TESTFN)
image.write(filename)
image2 = tkinter.PhotoImage('::img::test2', master=self.root,
format='ppm',
file=os_helper.TESTFN)
file=filename)
self.assertEqual(str(image2), '::img::test2')
self.assertEqual(image2.type(), 'photo')
self.assertEqual(image2.width(), 16)
self.assertEqual(image2.height(), 16)
self.assertEqual(image2.get(0, 0), image.get(0, 0))
self.assertEqual(image2.get(15, 8), image.get(15, 8))

image.write(os_helper.TESTFN, format='gif', from_coords=(4, 6, 6, 9))
image.write(filename, format='gif', from_coords=(4, 6, 6, 9))
image3 = tkinter.PhotoImage('::img::test3', master=self.root,
format='gif',
file=os_helper.TESTFN)
file=filename)
self.assertEqual(str(image3), '::img::test3')
self.assertEqual(image3.type(), 'photo')
self.assertEqual(image3.width(), 2)
Expand Down
0