Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-122575: Include sys.flags.gil as a sequence attribute #122576

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

Closed
wants to merge 3 commits into from

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented Aug 1, 2024

Make sure that sys.flags.gil is included when sys.flags is treated as a tuple or named tuple.


📚 Documentation preview 📚: https://cpython-previews--122576.org.readthedocs.build/en/122576/library/sys.html#sys.flags

Make sure that `sys.flags.gil` is included when `sys.flags` is treated
as a tuple or named tuple.
@colesbury colesbury marked this pull request as ready for review August 1, 2024 20:10
@colesbury
Copy link
Contributor Author

@ericsnowcurrently, when you have some time, I'd appreciate your review on this

@@ -587,6 +587,9 @@ always available.
* - .. attribute:: flags.warn_default_encoding
- :option:`-X warn_default_encoding <-X>`

* - .. attribute:: flags.gil
Copy link
Member

Choose a reason for hiding this comment

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

You should explain that the gil takes values 0, 1, or 2 and possibly explain the corresponding values (or a link to them) (and also say that None means the free-threaded build (if I'm not wrong)).

Copy link
Member

Choose a reason for hiding this comment

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

This isn't the right place for that, is it?

Copy link
Member

Choose a reason for hiding this comment

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

Oh actually I don't really know where it would be the right place... I just wanted to point it out since a new variable is being documented (I don't know whether there already exists another place so feel free to ignore this comment!)

attr_types = {
"dev_mode": bool,
"safe_path": bool,
"gil": (int, type(None)),
Copy link
Member

@picnixz picnixz Aug 2, 2024

Choose a reason for hiding this comment

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

Does the None value mean that it's the free-threaded build or is it for something else?

@AA-Turner
Copy link
Member

AA-Turner commented Aug 3, 2024

Potentially,

 .. data:: flags
    The :term:`named tuple` *flags* exposes the status of command line
    flags. The attributes are read only.
+   The number of flags may change in any version of Python,
+   do not unpack ``sys.flags`` or index into it as a tuple.

which would document that we change sys.flags with some regularity.

A

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM if you apply the Py_ARRAY_LENGTH() suggestion.

Co-authored-by: Bénédikt Tran <[email protected]>
@vstinner
Copy link
Member

vstinner commented Sep 2, 2024

Ah, you should now update test_pythontypes() of test_sys.

@colesbury
Copy link
Contributor Author

I'm going to close this for now as @encukou expressed concerns about backwards compatibility on the issue: #122575 (comment)

@colesbury colesbury closed this Oct 15, 2024
@colesbury colesbury removed the needs backport to 3.13 bugs and security fixes label Oct 25, 2024
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.

6 participants