Skip to content

Commit bd7947e

Browse files
authored
Fix test_typing.test_args_kwargs (#6012)
1 parent a1ee7f5 commit bd7947e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Lib/test/test_typing.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8546,8 +8546,6 @@ def test_valid_uses(self):
85468546
self.assertEqual(C4.__args__, (P, T))
85478547
self.assertEqual(C4.__parameters__, (P, T))
85488548

8549-
# TODO: RUSTPYTHON
8550-
@unittest.expectedFailure
85518549
def test_args_kwargs(self):
85528550
P = ParamSpec('P')
85538551
P_2 = ParamSpec('P_2')

vm/src/stdlib/typevar.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,12 @@ impl Comparable for ParamSpecArgs {
833833
fn eq(
834834
zelf: &crate::Py<ParamSpecArgs>,
835835
other: PyObjectRef,
836-
vm: &VirtualMachine,
836+
_vm: &VirtualMachine,
837837
) -> PyResult<bool> {
838-
// Check if other has __origin__ attribute
839-
if let Ok(other_origin) = other.get_attr("__origin__", vm) {
840-
return Ok(zelf.__origin__.is(&other_origin));
838+
// First check if other is also ParamSpecArgs
839+
if let Ok(other_args) = other.downcast::<ParamSpecArgs>() {
840+
// Check if they have the same origin
841+
return Ok(zelf.__origin__.is(&other_args.__origin__));
841842
}
842843
Ok(false)
843844
}
@@ -911,11 +912,12 @@ impl Comparable for ParamSpecKwargs {
911912
fn eq(
912913
zelf: &crate::Py<ParamSpecKwargs>,
913914
other: PyObjectRef,
914-
vm: &VirtualMachine,
915+
_vm: &VirtualMachine,
915916
) -> PyResult<bool> {
916-
// Check if other has __origin__ attribute
917-
if let Ok(other_origin) = other.get_attr("__origin__", vm) {
918-
return Ok(zelf.__origin__.is(&other_origin));
917+
// First check if other is also ParamSpecKwargs
918+
if let Ok(other_kwargs) = other.downcast::<ParamSpecKwargs>() {
919+
// Check if they have the same origin
920+
return Ok(zelf.__origin__.is(&other_kwargs.__origin__));
919921
}
920922
Ok(false)
921923
}

0 commit comments

Comments
 (0)