Skip to content

gh-154610: Use repr() to format the attribute name in AttributeError - #154614

Open
vstinner wants to merge 3 commits into
python:mainfrom
vstinner:attr_error_repr
Open

gh-154610: Use repr() to format the attribute name in AttributeError#154614
vstinner wants to merge 3 commits into
python:mainfrom
vstinner:attr_error_repr

Conversation

@vstinner

@vstinnervstinner commented Jul 24, 2026

Copy link
Copy Markdown
Member
  • In Python code, replace %s with f-string {name!r}.
  • In C code, replace '%U' with %R.
  • In C code, no longer truncate long type names: replace %.50s or %.100s with %s (PEP 737).

…Error
* In Python code, replace `%s` with f-string `{name!r}`.
* In C code, replace `'%U'` with `%R`.
* In C code, no longer truncate long type names:
replace `%.50s` or `%.100s` with `%s` (PEP 737).
@vstinner

Copy link
Copy Markdown
MemberAuthor

cc @serhiy-storchaka@johnslavik

@johnslavik
johnslavik self-requested a review July 24, 2026 13:59

@johnslavikjohnslavik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I added suggestions that remove escaping. I think new strings are easier to read, but feel free to ignore them.

Comment threadLib/test/test_module/__init__.py Outdated
Comment threadLib/test/test_unittest/testmock/testmock.py Outdated
Comment threadLib/test/test_unittest/test_case.py Outdated
Comment threadLib/test/test_builtin.py Outdated
Comment threadLib/test/test_decimal.py Outdated
Comment threadLib/test/test_builtin.py Outdated
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
@vstinner

Copy link
Copy Markdown
MemberAuthor

Nit: I added suggestions that remove escaping. I think new strings are easier to read, but feel free to ignore them.

I wasn't sure about triple quote. Anyway, I just applied your suggestions.

@johnslavikjohnslavik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that was tricky :-) It was a syntax error. Single-quote triple will work. I'll fix it so you don't have to.

Comment threadLib/test/test_module/__init__.py Outdated
Comment threadLib/test/test_unittest/testmock/testmock.py Outdated
Comment threadLib/test/test_unittest/test_case.py Outdated
Comment threadLib/test/test_builtin.py Outdated
Comment threadLib/test/test_decimal.py Outdated
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@vstinner@johnslavik