Skip to content

Commit fab53f0

Browse files
authored
Merge pull request RustPython#4187 from dvermd/structseq_matchargs
match args without n_*_fields
2 parents e56950a + 7f86178 commit fab53f0

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Lib/test/test_structseq.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ def test_extended_getslice(self):
124124
self.assertEqual(list(t[start:stop:step]),
125125
L[start:stop:step])
126126

127-
# TODO: RUSTPYTHON
128-
@unittest.expectedFailure
129127
def test_match_args(self):
130128
expected_args = ('tm_year', 'tm_mon', 'tm_mday', 'tm_hour', 'tm_min',
131129
'tm_sec', 'tm_wday', 'tm_yday', 'tm_isdst')

vm/src/types/structseq.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,16 @@ pub trait PyStructSequence: StaticType + PyClassImpl + Sized + 'static {
8686
.into(),
8787
);
8888
}
89+
90+
class.set_attr(
91+
identifier!(ctx, __match_args__),
92+
ctx.new_tuple(
93+
Self::FIELD_NAMES
94+
.iter()
95+
.map(|&name| ctx.new_str(name).into())
96+
.collect::<Vec<_>>(),
97+
)
98+
.into(),
99+
);
89100
}
90101
}

vm/src/vm/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ declare_const_name! {
152152
__lshift__,
153153
__lt__,
154154
__main__,
155+
__match_args__,
155156
__matmul__,
156157
__missing__,
157158
__mod__,

0 commit comments

Comments
 (0)