Skip to content

Commit cfaa04f

Browse files
committed
pythongh-122575: Include sys.flags.gil as a sequence attribute
Make sure that `sys.flags.gil` is included when `sys.flags` is treated as a tuple or named tuple.
1 parent fda6bd8 commit cfaa04f

4 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎Doc/library/sys.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,9 @@ always available.
587587
* - .. attribute:: flags.warn_default_encoding
588588
- :option:`-X warn_default_encoding <-X>`
589589

590+
* - .. attribute:: flags.gil
591+
- :option:`-X gil <-X>`
592+
590593
.. versionchanged:: 3.2
591594
Added ``quiet`` attribute for the new :option:`-q` flag.
592595

@@ -613,6 +616,9 @@ always available.
613616
.. versionchanged:: 3.11
614617
Added the ``int_max_str_digits`` attribute.
615618

619+
.. versionchanged:: 3.13
620+
Added the ``gil`` attribute.
621+
616622

617623
.. data:: float_info
618624

‎Lib/test/test_sys.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,8 @@ def test_sys_flags(self):
803803
"dont_write_bytecode", "no_user_site", "no_site",
804804
"ignore_environment", "verbose", "bytes_warning", "quiet",
805805
"hash_randomization", "isolated", "dev_mode", "utf8_mode",
806-
"warn_default_encoding", "safe_path", "int_max_str_digits")
806+
"warn_default_encoding", "safe_path", "int_max_str_digits",
807+
"gil")
807808
for attr in attrs:
808809
self.assertTrue(hasattr(sys.flags, attr), attr)
809810
attr_type = bool if attr in ("dev_mode", "safe_path") else int
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Include :attr:`sys.flags.gil` as part of the sequence when :data:`sys.flags`
2+
is treated as a tuple.

‎Python/sysmodule.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3124,7 +3124,7 @@ static PyStructSequence_Desc flags_desc = {
31243124
"sys.flags", /* name */
31253125
flags__doc__, /* doc */
31263126
flags_fields, /* fields */
3127-
18
3127+
sizeof(flags_fields) / sizeof(flags_fields[0]) - 1
31283128
};
31293129

31303130
static int

0 commit comments

Comments
 (0)