Skip to content

tkinter: setvar() passes AsObj's NULL to Tcl when the value's __str__ raises #161388

Closed

Description

@theosotr

Bug report

Summary

setvar() with three arguments crashes the interpreter with SIGSEGV if the value's __str__ raises.

Expected: the exception from __str__ should propagate, as it does from setvar(name, value).

Reproducer

import tkinter

class StrRaises:
    def __str__(self):
        raise RuntimeError("boom")

tkinter.Tcl().tk.setvar("name1", "name2", StrRaises())
Segmentation fault (core dumped)

CPython versions tested on:

3.15

Operating systems tested on:

No response

Linked PRs

Activity

  1. changed the title [-]`setvar()` passes `AsObj`'s NULL to Tcl when the value's `__str__` raises[/-] [+]tkinter: `setvar()` passes `AsObj`'s NULL to Tcl when the value's `__str__` raises[/+] on Nov 5, 2026
  2. added
    type-crashA hard crash of the interpreter, possibly with a core dump
    and removed
    type-bugAn unexpected behavior, bug, or error
    on Nov 5, 2026
  3. self-assigned this
    on Nov 5, 2026
  4. added 3 commits that reference this issue on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

extension-modulesC modules in the Modules dirtopic-tkintertype-crashA hard crash of the interpreter, possibly with a core dump

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions