Skip to content

gh-136300: Modify C tests to conform to PEP-737 #136301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wsfulton
Copy link
Contributor

@wsfulton wsfulton commented Jul 4, 2025

  • Use %T format specifier instead of %s and Py_TYPE(x)->tp_name.
  • Remove legacy %.200s format specifier for truncating type names.

- Use %T format specifier instead of %s and Py_TYPE(x)->tp_name.
- Remove legacy %.200s format specifier for truncating type names.
@ZeroIntensity ZeroIntensity added the tests Tests in the Lib/test dir label Jul 4, 2025
Comment on lines +1858 to +1859
"cannot index memory using \"%T\"",
key);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"cannot index memory using \"%T\"",
key);
"cannot index memory using \"%T\"", key);

Comment on lines +8 to +9
PyErr_Format(PyExc_TypeError, "expect int, got %T",
obj);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
PyErr_Format(PyExc_TypeError, "expect int, got %T",
obj);
PyErr_Format(PyExc_TypeError, "expect int, got %T", obj);

Comment on lines +518 to +519
PyErr_Format(PyExc_TypeError, "'%T' object is not callable",
fn);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
PyErr_Format(PyExc_TypeError, "'%T' object is not callable",
fn);
PyErr_Format(PyExc_TypeError, "'%T' object is not callable", fn);

Comment on lines +2210 to +2211
PyExc_TypeError, "expected function or code object, got %T",
obj);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
PyExc_TypeError, "expected function or code object, got %T",
obj);
PyExc_TypeError, "expected function or code object, got %T", obj);

@vstinner vstinner changed the title gh-136300 Modify C tests to conform to PEP-737 gh-136300: Modify C tests to conform to PEP-737 Jul 8, 2025
@vstinner
Copy link
Member

vstinner commented Jul 8, 2025

Modify C tests to conform to PEP-737

The PEP is clear that it only affects new code:

Recommend using the type fully qualified name in error messages and in repr() methods in new C code. Recommend not truncating type names in new C code.

But I'm fine with this very specific change which only changes C tests. There is no risk of backward compatibility issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants