Skip to content
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

tkFont may reuse font names #39201

Closed
effbot mannequin opened this issue Sep 8, 2003 · 7 comments
Closed

tkFont may reuse font names #39201

effbot mannequin opened this issue Sep 8, 2003 · 7 comments
Assignees
Labels
topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@effbot
Copy link
Mannequin

effbot mannequin commented Sep 8, 2003

BPO 802310
Nosy @asvetlov
Files
  • tkfont_bug.py
  • nonamerepeat.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/asvetlov'
    closed_at = <Date 2012-04-03.06:51:05.975>
    created_at = <Date 2003-09-08.07:52:56.000>
    labels = ['type-bug', 'expert-tkinter']
    title = 'tkFont may reuse font names'
    updated_at = <Date 2012-04-03.06:51:05.973>
    user = 'https://bugs.python.org/effbot'

    bugs.python.org fields:

    activity = <Date 2012-04-03.06:51:05.973>
    actor = 'asvetlov'
    assignee = 'asvetlov'
    closed = True
    closed_date = <Date 2012-04-03.06:51:05.975>
    closer = 'asvetlov'
    components = ['Tkinter']
    creation = <Date 2003-09-08.07:52:56.000>
    creator = 'effbot'
    dependencies = []
    files = ['1024', '14332']
    hgrepos = []
    issue_num = 802310
    keywords = ['patch']
    message_count = 7.0
    messages = ['18102', '18103', '64948', '89581', '114268', '157394', '157395']
    nosy_count = 6.0
    nosy_names = ['effbot', 'lpd', 'gpolo', 'asvetlov', 'BreamoreBoy', 'python-dev']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue802310'
    versions = ['Python 3.3']

    @effbot
    Copy link
    Mannequin Author

    effbot mannequin commented Sep 8, 2003

    (sent to me instead of to the bug manager; note that
    the tkFont naming approach is also used for widgets and
    callbacks /F)

    The class tkFont has a problem name it chooses if no
    name is
    given. The choosen method 'name = "font" + str(id
    (self))' isn't safe
    because the name may exists longer than the Font
    object and so another
    Font object may be created with a different font but the
    same
    id() and so the same name. id() says

    Return the identity of an object.  This is guaranteed 
    

    to be unique
    among simultaneously existing objects.
    ^^^^^^^^^^^^^^^^^^^^^^^

    Note that this bug doesn't strike if you hold a reference
    to the Font
    object and so the GC can't reclaim the space.

    To reproduce run the attached program. It produces
    something like:

    previously: ('Times', 15, 'bold')
    now: ('Times', 18, 'bold')
    iterations: 8
    mapping: {'font136494612': ('Times', 
    14, 'bold'), 'font136499772': ('Times', 
    15, 'bold'), 'font136545468': ('Times', 
    17, 'bold'), 'font136483156': ('Times', 
    11, 'bold'), 'font136502700': ('Times', 
    12, 'bold'), 'font136510460': ('Times', 
    13, 'bold'), 'font136515228': ('Times', 
    16, 'bold'), 'font136365348': ('Times', 10, 'bold')}
    Traceback (most recent call last):
      File "tkfont_bug.py", line 20, in ?
        assert 0
    AssertionError

    Raimar

    @effbot effbot mannequin added topic-tkinter labels Sep 8, 2003
    @lpd
    Copy link
    Mannequin

    lpd mannequin commented Jun 3, 2007

    This bug has bitten me too, in a real program.

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Apr 4, 2008

    This still happens, but around 2000 iterations here on newer Python
    versions (trunk, 3alpha, 2.5.x, 2.4.x). Using Python 1.6 I've got it at
    2 iterations (min), but.. is this going to be fixed or given the amount
    of iterations needed nowadays this is no longer a problem ? If it should
    be fixed, are there any suggestions on how to proceed ?

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Jun 21, 2009

    Uhm, now I'm getting it at around 3 iterations with python-trunk. So,
    can't we just use a simple generator for this ? Patch attached.

    The same could be done for widget and callback naming.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Aug 18, 2010

    Patch is really simple and looks ok to me, can we get this committed please.

    @BreamoreBoy BreamoreBoy mannequin added type-bug An unexpected behavior, bug, or error labels Aug 18, 2010
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 3, 2012

    New changeset a77e23135675 by Andrew Svetlov in branch 'default':
    Issue bpo-802310: Generate always unique tkinter font names if not directly passed
    http://hg.python.org/cpython/rev/a77e23135675

    @asvetlov
    Copy link
    Contributor

    asvetlov commented Apr 3, 2012

    I've pushed fix inspired by Guilherme's suggestion.

    Fix has been applied to 3.3 only because:

    1. It changes font name generation schema
    2. It's definitelly minor issue as exists starting from 2003.

    Thanks.

    @asvetlov asvetlov closed this as completed Apr 3, 2012
    @asvetlov asvetlov closed this as completed Apr 3, 2012
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-tkinter type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant