This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: tkFont.__eq__ gives type error
Type: behavior Stage: commit review
Components: Tkinter Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: amaury.forgeotdarc Nosy List: BreamoreBoy, amaury.forgeotdarc, gpolo, loewis, lpd, pitrou, python-dev, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2007-06-03 05:20 by lpd, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tkFont.Font.__eq__.diff gpolo, 2008-06-03 17:46
Messages (10)
msg32193 - (view) Author: L. Peter Deutsch (lpd) Date: 2007-06-03 05:20
The current definition is:

    def __eq__(self, other):
        return self.name == other.name and isinstance(other, Font)

This can get an AttributeError if other isn't a Font. The code should be:

    def __eq__(self, other):
        return isinstance(other, Font) and self.name == other.name
msg67661 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-06-03 17:46
Patch added
msg107429 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-06-09 22:29
I agree that this change is sensible and verified that it is needed for 3.1 as well. I think it should be applied.
msg116683 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-17 17:11
I think this one line patch still needs applying.
msg116738 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-09-17 23:27
Fixed in r84865.
msg116919 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-20 09:09
The new test case fails on (FreeBSD, OS X) buildbots:

======================================================================
ERROR: test_font_eq (tkinter.test.test_tkinter.test_font.FontTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/tkinter/test/test_tkinter/test_font.py", line 10, in test_font_eq
    font1 = font.nametofont("system")
  File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/tkinter/font.py", line 22, in nametofont
    return Font(name=name, exists=True)
  File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/tkinter/font.py", line 83, in __init__
    "named font %s does not already exist" % (self.name,))
_tkinter.TclError: named font system does not already exist

----------------------------------------------------------------------
msg116931 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2010-09-20 13:30
Closing this again in favor of issue9899.
msg223839 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-07-24 14:41
The patch was not committed to 2.7 and now this bug causes an error on buildbot.

http://buildbot.python.org/all/builders/AMD64%20Debian%20root%202.7/builds/303/steps/test/logs/stdio

======================================================================
ERROR: test_finalizer (test.test_gc.GCTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/buildarea/2.7.angelico-debian-amd64/build/Lib/test/test_gc.py", line 149, in test_finalizer
    gc.garbage.remove(obj)
  File "/root/buildarea/2.7.angelico-debian-amd64/build/Lib/lib-tk/tkFont.py", line 100, in __eq__
    return self.name == other.name and isinstance(other, Font)
AttributeError: A instance has no attribute 'name'
msg223844 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-07-24 14:48
New changeset 841cdb6145e9 by Serhiy Storchaka in branch '2.7':
Issue #1730136: Fix comparison between a tk Font object and an object of a
http://hg.python.org/cpython/rev/841cdb6145e9
msg225598 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-21 06:00
New changeset 2b379c092253 by Ned Deily in branch '2.7':
Issue #1730136: Fix backported exception name.
http://hg.python.org/cpython/rev/2b379c092253
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 45027
2014-08-21 06:00:26python-devsetmessages: + msg225598
2014-07-24 14:48:33python-devsetnosy: + python-dev
messages: + msg223844
2014-07-24 14:41:24serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg223839
2010-09-20 13:30:23gpolosetstatus: open -> closed

messages: + msg116931
2010-09-20 09:09:31pitrousetstatus: closed -> open

nosy: + pitrou
messages: + msg116919

assignee: loewis -> amaury.forgeotdarc
2010-09-17 23:27:53amaury.forgeotdarcsetstatus: open -> closed

nosy: + amaury.forgeotdarc
messages: + msg116738

resolution: fixed
2010-09-17 17:11:18BreamoreBoysetversions: - Python 2.6
nosy: + BreamoreBoy

messages: + msg116683

type: behavior
2010-06-09 22:29:36terry.reedysetversions: + Python 2.6, Python 3.1, Python 2.7, Python 3.2, - Python 2.5
nosy: + terry.reedy

messages: + msg107429

stage: commit review
2008-06-03 17:46:29gpolosetkeywords: + patch
nosy: + gpolo
messages: + msg67661
files: + tkFont.Font.__eq__.diff
2007-06-03 05:20:25lpdcreate