Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Move sys.flags thread_inherit_context/context_aware_warnings to getset
  • Loading branch information
youknowone committed Feb 21, 2026
commit d19d523c8de7235826c3bf8ee1e9585f46e29d40
2 changes: 1 addition & 1 deletion Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ def return_genexp():
code_lines = self.get_code_lines(genexp_code)
self.assertEqual(genexp_lines, code_lines)

# TODO: RUSTPYTHON
# TODO: RUSTPYTHON; implicit return line number after async for
@unittest.expectedFailure
def test_line_number_implicit_return_after_async_for(self):

Expand Down
5 changes: 3 additions & 2 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ class SysModuleTest(unittest.TestCase):
def tearDown(self):
test.support.reap_children()

@unittest.expectedFailure # TODO: RUSTPYTHON; latin-1 codec not registered
def test_exit(self):
# call with two arguments
self.assertRaises(TypeError, sys.exit, 42, 42)
Expand Down Expand Up @@ -400,7 +401,6 @@ def test_setrecursionlimit_to_depth(self):
finally:
sys.setrecursionlimit(old_limit)

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_getwindowsversion(self):
# Raise SkipTest if sys doesn't have getwindowsversion attribute
test.support.get_attribute(sys, "getwindowsversion")
Expand Down Expand Up @@ -850,7 +850,6 @@ def test_subinterp_intern_singleton(self):
'''))
self.assertTrue(sys._is_interned(s))

@unittest.expectedFailure # TODO: RUSTPYTHON; needs update for context_aware_warnings
def test_sys_flags(self):
self.assertTrue(sys.flags)
attrs = ("debug",
Expand Down Expand Up @@ -1056,10 +1055,12 @@ def check_locale_surrogateescape(self, locale):
'stdout: surrogateescape\n'
'stderr: backslashreplace\n')

@unittest.expectedFailure # TODO: RUSTPYTHON; iso8859_1 codec not registered
@support.requires_subprocess()
def test_c_locale_surrogateescape(self):
self.check_locale_surrogateescape('C')

@unittest.expectedFailure # TODO: RUSTPYTHON; iso8859_1 codec not registered
@support.requires_subprocess()
def test_posix_locale_surrogateescape(self):
self.check_locale_surrogateescape('POSIX')
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions crates/vm/src/stdlib/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,10 +1565,6 @@ mod sys {
safe_path: bool,
/// -X warn_default_encoding, PYTHONWARNDEFAULTENCODING
warn_default_encoding: u8,
/// -X thread_inherit_context, whether new threads inherit context from parent
thread_inherit_context: bool,
/// -X context_aware_warnings, whether warnings are context aware
context_aware_warnings: bool,
}

impl FlagsData {
Expand All @@ -1592,13 +1588,11 @@ mod sys {
int_max_str_digits: settings.int_max_str_digits,
safe_path: settings.safe_path,
warn_default_encoding: settings.warn_default_encoding as u8,
thread_inherit_context: settings.thread_inherit_context,
context_aware_warnings: settings.context_aware_warnings,
}
}
}

#[pystruct_sequence(name = "flags", module = "sys", data = "FlagsData", no_attr)]
#[pystruct_sequence(name = "flags", data = "FlagsData", no_attr)]
pub(super) struct PyFlags;

#[pyclass(with(PyStructSequence))]
Expand All @@ -1607,6 +1601,16 @@ mod sys {
fn slot_new(_cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult {
Err(vm.new_type_error("cannot create 'sys.flags' instances"))
}

#[pygetset]
fn context_aware_warnings(&self, vm: &VirtualMachine) -> bool {
vm.state.config.settings.context_aware_warnings
}

#[pygetset]
fn thread_inherit_context(&self, vm: &VirtualMachine) -> bool {
vm.state.config.settings.thread_inherit_context
}
}

#[cfg(feature = "threading")]
Expand Down
Loading