python / python/cpython

Confusing traceback: Incorrect error line shown when `@property` is mistakenly applied to `__str__` method

Open
#140,311 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

interpreter-core type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

The error message is TypeError: 'str' object is not callable, but the highlighted error line has no calls.

class MyClass:
    @property
    def __str__(self):
        return "MyClass"

obj = MyClass()

print(f"Hello, {obj}")
Traceback (most recent call last):
  File "<string>", line 9, in <module>
    print(f"Hello, {obj}")
                   ^^^^^
TypeError: 'str' object is not callable
CPython versions tested on:

3.14

Operating systems tested on:

Windows

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by reproducing the supplied class and f-string on CPython 3.14, then trace the traceback-generation path for the highlighted line. Done means the diagnostic points to an accurate location for the TypeError or otherwise presents the failing operation clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.