-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-142595: add type check for namedtuple call during decimal initialization #142608
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
Conversation
|
Did you consider using a |
|
I'm not sure about issue itself, see #142595 (comment) But as an excuse for refactoring this sounds much better. I'll rework the pr. |
|
Hmm, no. I don't think using PyStructSequence is a good idea. We can't create this type just with PyStructSequence_NewType. The namedtype DecimalType supports three arguments, while new type - only one (a sequence). Probably, I can override tp_new, but at the end - things looks more complex with all this, not simpler. |
encukou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it might be good to add a way to create PyStructSequences that are more namedtuple-like. But, yeah, I agree it's too much work for this issue.
|
Thanks @skirpichev for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
|
Thanks @skirpichev for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…itialization (pythonGH-142608) (cherry picked from commit be5e0dc) Co-authored-by: Sergey B Kirpichev <[email protected]>
…itialization (pythonGH-142608) (cherry picked from commit be5e0dc) Co-authored-by: Sergey B Kirpichev <[email protected]>
|
GH-142622 is a backport of this pull request to the 3.13 branch. |
|
GH-142623 is a backport of this pull request to the 3.14 branch. |
I don't think that the amount of work is the problem: it seems, that interfaces are different. The namedtype has additional class method Perhaps, some PyStructSequence_NewType2(), that creates a type with the right constructor? If not, I think we should just document the difference. I was certainly misguided by sentence:
|
|
Yeah, that should reference the glossary term, not |
Yeah, this, with a new versioned variant of |
_decimal_execvia overridingcollections.namedtuple#142595