Skip to content

Commit d19d523

Browse files
committed
Move sys.flags thread_inherit_context/context_aware_warnings to getset
1 parent ea8e25c commit d19d523

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

Lib/test/test_compile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ def return_genexp():
10121012
code_lines = self.get_code_lines(genexp_code)
10131013
self.assertEqual(genexp_lines, code_lines)
10141014

1015-
# TODO: RUSTPYTHON
1015+
# TODO: RUSTPYTHON; implicit return line number after async for
10161016
@unittest.expectedFailure
10171017
def test_line_number_implicit_return_after_async_for(self):
10181018

Lib/test/test_sys.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ class SysModuleTest(unittest.TestCase):
209209
def tearDown(self):
210210
test.support.reap_children()
211211

212+
@unittest.expectedFailure # TODO: RUSTPYTHON; latin-1 codec not registered
212213
def test_exit(self):
213214
# call with two arguments
214215
self.assertRaises(TypeError, sys.exit, 42, 42)
@@ -400,7 +401,6 @@ def test_setrecursionlimit_to_depth(self):
400401
finally:
401402
sys.setrecursionlimit(old_limit)
402403

403-
@unittest.expectedFailure # TODO: RUSTPYTHON
404404
def test_getwindowsversion(self):
405405
# Raise SkipTest if sys doesn't have getwindowsversion attribute
406406
test.support.get_attribute(sys, "getwindowsversion")
@@ -850,7 +850,6 @@ def test_subinterp_intern_singleton(self):
850850
'''))
851851
self.assertTrue(sys._is_interned(s))
852852

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

1058+
@unittest.expectedFailure # TODO: RUSTPYTHON; iso8859_1 codec not registered
10591059
@support.requires_subprocess()
10601060
def test_c_locale_surrogateescape(self):
10611061
self.check_locale_surrogateescape('C')
10621062

1063+
@unittest.expectedFailure # TODO: RUSTPYTHON; iso8859_1 codec not registered
10631064
@support.requires_subprocess()
10641065
def test_posix_locale_surrogateescape(self):
10651066
self.check_locale_surrogateescape('POSIX')

crates/codegen/src/snapshots/rustpython_codegen__compile__tests__nested_double_async_with.snap

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/vm/src/stdlib/sys.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,10 +1565,6 @@ mod sys {
15651565
safe_path: bool,
15661566
/// -X warn_default_encoding, PYTHONWARNDEFAULTENCODING
15671567
warn_default_encoding: u8,
1568-
/// -X thread_inherit_context, whether new threads inherit context from parent
1569-
thread_inherit_context: bool,
1570-
/// -X context_aware_warnings, whether warnings are context aware
1571-
context_aware_warnings: bool,
15721568
}
15731569

15741570
impl FlagsData {
@@ -1592,13 +1588,11 @@ mod sys {
15921588
int_max_str_digits: settings.int_max_str_digits,
15931589
safe_path: settings.safe_path,
15941590
warn_default_encoding: settings.warn_default_encoding as u8,
1595-
thread_inherit_context: settings.thread_inherit_context,
1596-
context_aware_warnings: settings.context_aware_warnings,
15971591
}
15981592
}
15991593
}
16001594

1601-
#[pystruct_sequence(name = "flags", module = "sys", data = "FlagsData", no_attr)]
1595+
#[pystruct_sequence(name = "flags", data = "FlagsData", no_attr)]
16021596
pub(super) struct PyFlags;
16031597

16041598
#[pyclass(with(PyStructSequence))]
@@ -1607,6 +1601,16 @@ mod sys {
16071601
fn slot_new(_cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult {
16081602
Err(vm.new_type_error("cannot create 'sys.flags' instances"))
16091603
}
1604+
1605+
#[pygetset]
1606+
fn context_aware_warnings(&self, vm: &VirtualMachine) -> bool {
1607+
vm.state.config.settings.context_aware_warnings
1608+
}
1609+
1610+
#[pygetset]
1611+
fn thread_inherit_context(&self, vm: &VirtualMachine) -> bool {
1612+
vm.state.config.settings.thread_inherit_context
1613+
}
16101614
}
16111615

16121616
#[cfg(feature = "threading")]

0 commit comments

Comments
 (0)