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

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions 6 Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@ always available.
* - .. attribute:: flags.warn_default_encoding
- :option:`-X warn_default_encoding <-X>`

* - .. attribute:: flags.gil

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!)

- :option:`-X gil <-X>`

.. versionchanged:: 3.2
Added ``quiet`` attribute for the new :option:`-q` flag.

Expand All @@ -613,6 +616,9 @@ always available.
.. versionchanged:: 3.11
Added the ``int_max_str_digits`` attribute.

.. versionchanged:: 3.13
Added the ``gil`` attribute.


.. data:: float_info

Expand Down
12 changes: 9 additions & 3 deletions 12 Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,11 +803,17 @@ def test_sys_flags(self):
"dont_write_bytecode", "no_user_site", "no_site",
"ignore_environment", "verbose", "bytes_warning", "quiet",
"hash_randomization", "isolated", "dev_mode", "utf8_mode",
"warn_default_encoding", "safe_path", "int_max_str_digits")
"warn_default_encoding", "safe_path", "int_max_str_digits",
"gil")
attr_types = {
"dev_mode": bool,
"safe_path": bool,
"gil": (int, type(None)),

@picnixz picnixz Aug 2, 2024

Copy link
Copy Markdown
Member

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?

}
for attr in attrs:
self.assertTrue(hasattr(sys.flags, attr), attr)
attr_type = bool if attr in ("dev_mode", "safe_path") else int
self.assertEqual(type(getattr(sys.flags, attr)), attr_type, attr)
expected_type = attr_types.get(attr, int)
self.assertIsInstance(getattr(sys.flags, attr), expected_type, attr)
self.assertTrue(repr(sys.flags))
self.assertEqual(len(sys.flags), len(attrs))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Include :attr:`sys.flags.gil` as part of the sequence when :data:`sys.flags`
is treated as a tuple.
2 changes: 1 addition & 1 deletion 2 Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3124,7 +3124,7 @@ static PyStructSequence_Desc flags_desc = {
"sys.flags", /* name */
flags__doc__, /* doc */
flags_fields, /* fields */
18
Py_ARRAY_LENGTH(flags_fields) - 1
};

static int
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.