Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PEP 737: gh-111696: Add %T format to PyUnicode_FromFormat()#111703

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
vstinner wants to merge1 commit intopython:mainfromvstinner:fromformat_typename

Conversation

vstinner
Copy link
Member

@vstinnervstinner commentedNov 3, 2023
edited
Loading

@vstinner
Copy link
MemberAuthor

I updated my PR:

  • Remove the change: AddT and "#T" formats totype.__format__().
  • Exchange%T and%#T format:%T is now the short type name, and%#T is the long type name.

@vstinner
Copy link
MemberAuthor

I reduced this PR to the bare minimum, non controversial and most important: only add %T format just to add a type name (type.__name__).

Later, we can extend the API:

  • Add a%#T format toPyUnicode_FromFormat() if needed.
  • Add atype.__fullyqualname__ attribute.
  • AddT and#T formats totype.__format__().

Extended the API later is not incompatible with this change: they would be additions.

@vstinner
Copy link
MemberAuthor

@serhiy-storchaka: Are you ok with this minor addition to PyUnicode_FromFormat()?

My work on the limited C API is blocked by this missing feature. As I wrote previously, the formatcan be extended later if someone wants to cover most cases, add an alternative format, etc.

@serhiy-storchaka
Copy link
Member

I would prefer to make the size modifier mandatory and use it as the format specifier intype.__format__. So you can write
PyUnicode_FromFormat("%zT", Py_TYPE(obj)) in C andf"{type(obj):z}" in Python.

It is also less ambiguous.

@vstinner
Copy link
MemberAuthor

My previous attempt in 2018:#9122

@vstinner
Copy link
MemberAuthor

Previous attempt, merged commit886483e, which was reverted a few days later.

@vstinner
Copy link
MemberAuthor

I wrotePEP 737 – Unify type name formatting for these changes: seethe PEP discussion.

@vstinnervstinner changed the titlegh-111696: Add %T format to PyUnicode_FromFormat()PEP 737: gh-111696: Add %T format to PyUnicode_FromFormat()Dec 1, 2023
@vstinner
Copy link
MemberAuthor

PEP 737 changed the API since this PR was created. I close this PR for now and will create a new one (or maybe reopen this PR) since PEP 737 will be approved.

@vstinnervstinner deleted the fromformat_typename branchDecember 20, 2023 10:56
@vstinnervstinner restored the fromformat_typename branchMarch 14, 2024 14:03
@vstinnervstinner deleted the fromformat_typename branchJanuary 14, 2025 08:20
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@markshannonmarkshannonAwaiting requested review from markshannon

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@vstinner@serhiy-storchaka

[8]ページ先頭

©2009-2025 Movatter.jp