◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
8 changes: 0 additions & 8 deletions Lib/test/test_dataclasses.py
Original file line number Diff line number Diff line change
@@ -1954,8 +1954,6 @@ class R:
self.assertEqual(new_sample.x, another_new_sample.x)
self.assertEqual(sample.y, another_new_sample.y)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_dataclasses_qualnames(self):
@dataclass(order=True, unsafe_hash=True, frozen=True)
class A:
Expand Down Expand Up @@ -3442,8 +3440,6 @@ class C:
self.assertEqual(c1.x, 3)
self.assertEqual(c1.y, 2)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_frozen(self):
@dataclass(frozen=True)
class C:
Expand Down Expand Up @@ -3476,8 +3472,6 @@ class C:
"keyword argument 'a'"):
c1 = replace(c, x=20, a=5)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_invalid_field_name(self):
@dataclass(frozen=True)
class C:
Expand Down @@ -3521,8 +3515,6 @@ class C:
with self.assertRaisesRegex(ValueError, 'init=False'):
replace(c, y=30)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_classvar(self):
@dataclass
class C:
Expand Down
24 changes: 15 additions & 9 deletions vm/src/builtins/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ impl PyFunction {
if nargs > nexpected_args {
return Err(vm.new_type_error(format!(
"{}() takes {} positional arguments but {} were given",
&self.code.obj_name, nexpected_args, nargs
)));
}
}
Expand Down Expand Up @@ -132,25 +134,29 @@ impl PyFunction {
if let Some(pos) = argpos(code.posonlyarg_count..total_args, &name) {
let slot = &mut fastlocals[pos];
if slot.is_some() {
return Err(
vm.new_type_error(format!("Got multiple values for argument '{name}'"))
);
}
*slot = Some(value);
} 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}'"))
);
}
}
if !posonly_passed_as_kwarg.is_empty() {
return Err(vm.new_type_error(format!(
"{}() got some positional-only arguments passed as keyword arguments: '{}'",
&self.code.obj_name,
posonly_passed_as_kwarg.into_iter().format(", "),
)));
}
Expand Down Expand Up @@ -207,7 +213,7 @@ impl PyFunction {

return Err(vm.new_type_error(format!(
"{}() missing {} required positional argument{}: '{}{}{}'",
&self.code.obj_name,
missing_args_len,
if missing_args_len == 1 { "" } else { "s" },
missing.iter().join("', '"),
Expand Down
Toggle all file notes Toggle all file annotations