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

Use static dot declarations for type objects#3067

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

Merged
Starbuck5 merged 3 commits intomainfromankith26-type-stuct
Mar 24, 2022

Conversation

@ankith26
Copy link
Contributor

PR tofix#2176

@dr0id
Copy link
Contributor

Never seen this before on a build agent:

 /io/buildconfig/manylinux-build/build-wheels.sh: line 60:  6067 Segmentation fault      (core dumped) ${PYTHON} -m pygame.tests -vv --exclude opengl,music,timingMakefile:13: recipe for target 'wheels-manylinux2010-x86' failedmake: *** [wheels-manylinux2010-x86] Error 1Error: Process completed with exit code 2.

Copy link
Contributor

@Starbuck5Starbuck5 left a comment

Choose a reason for hiding this comment

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

This looks good to me. I ran tests locally.

The python type objects docs use this style for their examples, so it's good to emulate. And it makes the code nicer too.

One thing I noticed is that some types have explicit tp_flags toPy_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE. But the python type object docs suggest that is just the default value. Some other things do weird things with tp_flags, likecolor uses a value set somewhere else-- I didn't check the rest of the code but it looks weird.

Additionally, I'm not sure this should be merged in 2.1.3, since we've done two test releases already. But it is an unknown situation about when that will be released, as I'm sure you know.

@Starbuck5
Copy link
Contributor

Looking deeper intocolor, it does:

#defineCOLOR_TPFLAGS_COMMON \    (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES)#defineCOLOR_TPFLAGS COLOR_TPFLAGS_COMMON

And then the only place it usesCOLOR_TPFLAGS_COMMON orCOLOR_TPFLAGS is the one place in the tp_flags field.

Additionally,Py_TPFLAGS_CHECKTYPES isn't even in the docs anymore. I could only find it in the 2.7 docs, so it's probably just antiquated and doing nothing now. Although testing would be needed.

Copy link
Contributor

@dr0iddr0id left a comment

Choose a reason for hiding this comment

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

It just a different syntax for the same thing. Not sure I like it. On one hand now the assignments are clearer due to the variable name, on the other hand one has to look up the possible things (where it was documented in the old way). But since this is just preference I approve it too.

@ankith26
Copy link
ContributorAuthor

ankith26 commentedMar 11, 2022
edited
Loading

Yeah I believePy_TPFLAGS_CHECKTYPES can be safely removed now. Because it is defined to0 in a compat header. Also I'll make a commit simplifying alltp_flags everywhere

EDIT: Apparently thosePy_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE flags need to be explicitly passed even though they are the default

Copy link
Contributor

@dr0iddr0id left a comment

Choose a reason for hiding this comment

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

LGTM

ankith26 reacted with hooray emoji
@ankith26
Copy link
ContributorAuthor

ankith26 commentedMar 11, 2022
edited
Loading

The latest commit adds static dot declarations for more structs, mainly for consistency reasons.
The rationale behind this PR is to make these structs easier to maintain in the long run, and make it less error prone, because the current system heavily relies on maintaining the right order of stuff. I believe these new struct declarations will also make it easier for new contributors who are more familiar with the same. It also makes the code more concise and easier to understand IMHO

But we still need to check for whether this can break on any old compiler on any exotic configuration, which we support (I don't think this is the case because this PR seems to pass on CI, the fail ATM is unrelated)

Copy link
Contributor

@dr0iddr0id left a comment

Choose a reason for hiding this comment

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

I start to like the new notation, your argument about the position is the reason for it. Also it is much more compact.

ankith26 reacted with hooray emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

2 more reviewers

@dr0iddr0iddr0id approved these changes

@Starbuck5Starbuck5Starbuck5 approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

C codeInvolves changing C codeCode quality/robustnessCode quality and resilience to changes

Projects

None yet

Milestone

2.1.3

Development

Successfully merging this pull request may close these issues.

PyTypeObject static object dot declarations

4 participants

@ankith26@dr0id@Starbuck5

[8]ページ先頭

©2009-2025 Movatter.jp