Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-128014: fix handling of a default empty string passed to tkinter.Wm.wm_iconbitmap #128015

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 10 commits into from
Jan 2, 2025

Conversation

Xiaokang2022
Copy link
Contributor

@Xiaokang2022 Xiaokang2022 commented Dec 17, 2024

…ap` could not take effect when passing an empty string
@Xiaokang2022 Xiaokang2022 changed the title gh-128014: Fix the bug that the parameter default of tkinter.Wm.wm_iconbitmap could not take effect when passing an empty string gh-128014: Fix the bug that the parameter default of tkinter.Wm.wm_iconbitmap could not take effect when passing an empty string Dec 17, 2024
@Xiaokang2022
Copy link
Contributor Author

I think this might need a "skip news" label.

@tomasr8
Copy link
Member

tomasr8 commented Dec 17, 2024

This is a user-visible change, right? If so, this will need a news entry.

@terryjreedy
Copy link
Member

Currently, widget.wm_iconbitmap treats default='' the same as default=None. This seems like a bug.

A possible blurb: When passing default='' to tkinter's widget.wm_iconbitmap, treat '' as an icon path instead of as None.

@serhiy-storchaka This seems liike a trivial fix. Apply? Backport?

@serhiy-storchaka
Copy link
Member

It is not the only site where all empty values are treated the same way as None. There was even a discussion about this somewhere. We should fix this issue all at once (if this is an issue) instead of one line per PR.

@serhiy-storchaka
Copy link
Member

On other hand, this looks like a bug that blocks a useful use case. So we can fix only this bug in this PR. But we need a test for this.

@Xiaokang2022
Copy link
Contributor Author

Sorry, I don't know how to test this.

@serhiy-storchaka
Copy link
Member

No problem, I added a test.

@serhiy-storchaka serhiy-storchaka added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Dec 18, 2024
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) December 19, 2024 09:20
@picnixz picnixz changed the title gh-128014: Fix the bug that the parameter default of tkinter.Wm.wm_iconbitmap could not take effect when passing an empty string gh-128014: fix handling of a falsey default passed to tkinter.Wm.wm_iconbitmap Dec 22, 2024
@picnixz picnixz changed the title gh-128014: fix handling of a falsey default passed to tkinter.Wm.wm_iconbitmap gh-128014: fix handling of a default empty string passed to tkinter.Wm.wm_iconbitmap Dec 22, 2024
@terryjreedy
Copy link
Member

Macos-13 had 2 failures.

Seem like should be spurious, in test_multiprocessing, but failed on retest, along with test_tkinter.

2024-12-22T13:24:41.7713420Z FAIL: test_repr_rlock (test.test_multiprocessing_spawn.test_processes.WithProcessesTestLock.test_repr_rlock)
2024-12-22T13:24:41.7714380Z ----------------------------------------------------------------------
2024-12-22T13:24:41.7714900Z Traceback (most recent call last):
2024-12-22T13:24:41.7715760Z   File "/Users/runner/work/cpython/cpython/Lib/test/_test_multiprocessing.py", line 1530, in test_repr_rlock
2024-12-22T13:24:41.7717320Z     self.assertEqual('<RLock(SomeOtherThread, nonzero)>', repr(lock))
2024-12-22T13:24:41.7717990Z     ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-12-22T13:24:41.7718650Z AssertionError: '<RLock(SomeOtherThread, nonzero)>' != '<RLock(None, 0)>'
2024-12-22T13:24:41.7719310Z - <RLock(SomeOtherThread, nonzero)>
2024-12-22T13:24:41.7719850Z + <RLock(None, 0)>

Real, in new test iconbitmap in test_tkinter.
2024-12-22T13:27:50.6347190Z FAIL: test_wm_iconbitmap (test.test_tkinter.test_misc.WmTest.test_wm_iconbitmap)
2024-12-22T13:27:50.6347930Z ----------------------------------------------------------------------
2024-12-22T13:27:50.6348460Z Traceback (most recent call last):
2024-12-22T13:27:50.6349360Z File "/Users/runner/work/cpython/cpython/Lib/test/test_tkinter/test_misc.py", line 561, in test_wm_iconbitmap
2024-12-22T13:27:50.6350360Z self.assertEqual(t.wm_iconbitmap(), 'hourglass')
2024-12-22T13:27:50.6350860Z ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-12-22T13:27:50.6351350Z AssertionError: '' != 'hourglass'
2024-12-22T13:27:50.6351730Z + hourglass

@Xiaokang2022
Copy link
Contributor Author

Even before this PR change, tkinter would have produced such results on macOS. This doesn't seem to be related to this PR, and a separate issue may need to be opened to discuss it.

@serhiy-storchaka
Copy link
Member

Oh, there is a bug in Tk (https://core.tcl-lang.org/tk/tktview/13ac26b35dc55f7c37f70b39d59d7ef3e63017c8).

@serhiy-storchaka
Copy link
Member

It is better to wait until this bug was fixed in Tk, so we could skip the check conditionally.

@serhiy-storchaka serhiy-storchaka merged commit 58e9f95 into python:main Jan 2, 2025
38 checks passed
@miss-islington-app
Copy link

Thanks @Xiaokang2022 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 2, 2025
…bitmap() (pythonGH-128015)

(cherry picked from commit 58e9f95)

Co-authored-by: Zhikang Yan <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
@miss-islington-app
Copy link

Sorry, @Xiaokang2022 and @serhiy-storchaka, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 58e9f95c4aa970db32a94b9152b51ede22f823bd 3.12

@bedevere-app
Copy link

bedevere-app bot commented Jan 2, 2025

GH-128418 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jan 2, 2025
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Jan 2, 2025
…wm_iconbitmap() (pythonGH-128015)

(cherry picked from commit 58e9f95)

Co-authored-by: Zhikang Yan <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Jan 2, 2025

GH-128420 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Jan 2, 2025
serhiy-storchaka added a commit that referenced this pull request Jan 2, 2025
…nbitmap() (GH-128015) (GH-128418)

(cherry picked from commit 58e9f95)

Co-authored-by: Zhikang Yan <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Jan 2, 2025
…nbitmap() (GH-128015) (GH-128420)

(cherry picked from commit 58e9f95)

Co-authored-by: Zhikang Yan <[email protected]>
@Xiaokang2022 Xiaokang2022 deleted the fix-tk-iconbitmap branch January 6, 2025 04:38
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants