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

@vstinner vstinner 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
Member Author

cc @serhiy-storchaka @johnslavik

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

@johnslavik johnslavik 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 thread Lib/test/test_module/__init__.py Outdated
Comment thread Lib/test/test_unittest/testmock/testmock.py Outdated
Comment thread Lib/test/test_unittest/test_case.py Outdated
Comment thread Lib/test/test_builtin.py Outdated
Comment thread Lib/test/test_decimal.py Outdated
Comment thread Lib/test/test_builtin.py Outdated
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
@vstinner

Copy link
Copy Markdown
Member Author

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.

@johnslavik johnslavik 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 thread Lib/test/test_module/__init__.py Outdated
Comment thread Lib/test/test_unittest/testmock/testmock.py Outdated
Comment thread Lib/test/test_unittest/test_case.py Outdated
Comment thread Lib/test/test_builtin.py Outdated
Comment thread Lib/test/test_decimal.py Outdated
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Sign up for free to 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