From 78f3ef27f00e57476ffbe84d11ccaa4e393a8b04 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 21 Nov 2021 05:25:27 +0900 Subject: [PATCH 1/2] allow passing a named argument to varkwargs function --- vm/src/builtins/function.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/src/builtins/function.rs b/vm/src/builtins/function.rs index 766bf5b36..d12421bd4 100644 --- a/vm/src/builtins/function.rs +++ b/vm/src/builtins/function.rs @@ -136,10 +136,10 @@ impl PyFunction { ); } *slot = Some(value); - } else if argpos(0..code.posonlyarg_count, &name).is_some() { - posonly_passed_as_kwarg.push(name); } else if let Some(kwargs) = kwargs.as_ref() { kwargs.set_item(name, value, vm)?; + } else if argpos(0..code.posonlyarg_count, &name).is_some() { + posonly_passed_as_kwarg.push(name); } else { return Err( vm.new_type_error(format!("got an unexpected keyword argument '{}'", name)) From a0450aa6567d5b8e96db5d1cbb4be9934f527d0e Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 21 Nov 2021 09:36:16 +0900 Subject: [PATCH 2/2] unmark unexpectedFailures related to posonly args tests --- Lib/test/test_functools.py | 2 -- Lib/test/test_positional_only_arg.py | 2 -- Lib/test/test_typing.py | 2 -- 3 files changed, 6 deletions(-) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index df6894947..18609f4e5 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -500,8 +500,6 @@ class TestPartialMethod(unittest.TestCase): a = A() - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_arg_combinations(self): self.assertEqual(self.a.nothing(), ((self.a,), {})) self.assertEqual(self.a.nothing(5), ((self.a, 5), {})) diff --git a/Lib/test/test_positional_only_arg.py b/Lib/test/test_positional_only_arg.py index ba1810c24..690009fde 100644 --- a/Lib/test/test_positional_only_arg.py +++ b/Lib/test/test_positional_only_arg.py @@ -318,8 +318,6 @@ class PositionalOnlyTestCase(unittest.TestCase): with self.assertRaisesRegex(TypeError, r"g\(\) takes 2 positional arguments but 3 were given"): f(1,2)(3,4,5) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_same_keyword_as_positional_with_kwargs(self): def f(something,/,**kwargs): return (something, kwargs) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index f2f651214..9f53edc04 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -3739,8 +3739,6 @@ class TypedDictTests(BaseTestCase): self.assertEqual(Emp.__annotations__, {'name': str, 'id': int}) self.assertEqual(Emp.__total__, True) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_typeddict_special_keyword_names(self): TD = TypedDict("TD", cls=type, self=object, typename=str, _typename=int, fields=list, _fields=dict) self.assertEqual(TD.__name__, 'TD')