Skip to content

Crash on launch: TypeError 'tuple' object does not support item assignment (Python 3.10+) #46

@Focing123

Description

@Focing123

Crash on Launch with Python 3.10+ (Tuple Immutability Error)

Description

When launching Mentalist v2.0.0 using modern Python versions (tested on Python 3.11 on Kali Linux), the application crashes immediately at startup with a TypeError.

The issue occurs because the code attempts to modify a tuple that stores the window size.


Error Traceback

TypeError: 'tuple' object does not support item assignment
File ".../mentalist/view/main.py", line 172, in __init__
    size[1] = h - 10

Cause

In mentalist/view/main.py:

size = tuple(int(_) for _ in self.master.geometry().split('+')[0].split('x'))

Later in the code:

if h < size[1]:
    size[1] = h - 10

size is defined as a tuple, which is immutable in Python. Attempting to assign a new value to size[1] results in a crash.

This behavior likely worked in older environments if a list was returned, but with modern Python/Tkinter behavior, the result is now consistently a tuple.


Proposed Fix

Convert size to a list before modifying it, and back to a tuple when passing it to geometry():

size = list(int(_) for _ in self.master.geometry().split('+')[0].split('x'))

And later:

self.master.geometry("%dx%d+%d+%d" % (tuple(size) + (x, y)))

Environment

  • OS: Kali Linux (Debian-based)
  • Python: 3.11
  • Mentalist version: 2.0.0

This change resolves the crash and allows the GUI to launch normally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions