From c334626f3ca993d5b26501d666e5849849ba6729 Mon Sep 17 00:00:00 2001 From: Karatus Date: Sat, 20 Aug 2022 22:58:58 +0900 Subject: [PATCH] Feature: sys.orig_argv (#4048) --- Lib/test/test_sys.py | 4 ---- vm/src/stdlib/sys.rs | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 2bbbe39c2..46332c654 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -484,8 +484,6 @@ class SysModuleTest(unittest.TestCase): leave_g.set() t.join() - # TODO: RUSTPYTHON, AttributeError: module 'sys' has no attribute 'orig_argv' - @unittest.expectedFailure def test_attributes(self): self.assertIsInstance(sys.api_version, int) self.assertIsInstance(sys.argv, list) @@ -1006,8 +1004,6 @@ class SysModuleTest(unittest.TestCase): out = out.decode('ascii', 'replace').rstrip() self.assertEqual(out, 'mbcs replace') - # TODO: RUSTPYTHON, subprocess.CalledProcessError: Command ... returned non-zero exit status 1. - @unittest.expectedFailure def test_orig_argv(self): code = textwrap.dedent(''' import sys diff --git a/vm/src/stdlib/sys.rs b/vm/src/stdlib/sys.rs index d297417ba..ec56ec926 100644 --- a/vm/src/stdlib/sys.rs +++ b/vm/src/stdlib/sys.rs @@ -217,6 +217,11 @@ mod sys { Vec::new() } + #[pyattr] + fn orig_argv(vm: &VirtualMachine) -> Vec { + env::args().map(|arg| vm.ctx.new_str(arg).into()).collect() + } + #[pyattr] fn path(vm: &VirtualMachine) -> Vec { vm.state