Skip to content

Commit 5617d23

Browse files
committed
apply review
1 parent 54df283 commit 5617d23

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

Lib/test/test_patma.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3207,7 +3207,6 @@ def test_wildcard_makes_remaining_patterns_unreachable_5(self):
32073207
pass
32083208
""")
32093209

3210-
@unittest.expectedFailure # TODO: RUSTPYTHON
32113210
def test_mapping_pattern_duplicate_key(self):
32123211
self.assert_syntax_error("""
32133212
match ...:

compiler/codegen/src/compile.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3583,11 +3583,16 @@ impl Compiler {
35833583
let mut seen = std::collections::HashSet::new();
35843584
for key in keys {
35853585
let is_attribute = matches!(key, Expr::Attribute(_));
3586-
let key_repr = if let Expr::NumberLiteral(_)
3587-
| Expr::StringLiteral(_)
3588-
| Expr::BooleanLiteral(_) = key
3589-
{
3590-
format!("{:?}", key)
3586+
let is_literal = matches!(
3587+
key,
3588+
Expr::NumberLiteral(_)
3589+
| Expr::StringLiteral(_)
3590+
| Expr::BytesLiteral(_)
3591+
| Expr::BooleanLiteral(_)
3592+
| Expr::NoneLiteral(_)
3593+
);
3594+
let key_repr = if is_literal {
3595+
unparse_expr(key, &self.source_file).to_string()
35913596
} else if is_attribute {
35923597
String::new()
35933598
} else {

vm/src/frame.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,10 +1332,11 @@ impl ExecutingFrame<'_> {
13321332
for key in keys {
13331333
match subject.get_item(key.as_object(), vm) {
13341334
Ok(value) => values.push(value),
1335-
Err(_) => {
1335+
Err(e) if e.fast_isinstance(vm.ctx.exceptions.key_error) => {
13361336
all_match = false;
13371337
break;
13381338
}
1339+
Err(e) => return Err(e),
13391340
}
13401341
}
13411342

0 commit comments

Comments
 (0)