mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Format single-element tuple string representations correctly
(i.e. with a trailing comma within the parentheses)
This commit is contained in:
@@ -365,14 +365,18 @@ impl PyObject {
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
),
|
||||
PyObjectKind::Tuple { ref elements } => format!(
|
||||
"({})",
|
||||
elements
|
||||
.iter()
|
||||
.map(|elem| elem.borrow().str())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
),
|
||||
PyObjectKind::Tuple { ref elements } => if elements.len() == 1 {
|
||||
format!("({},)", elements[0].borrow().str())
|
||||
} else {
|
||||
format!(
|
||||
"({})",
|
||||
elements
|
||||
.iter()
|
||||
.map(|elem| elem.borrow().str())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
)
|
||||
},
|
||||
PyObjectKind::Dict { ref elements } => format!(
|
||||
"{{ {} }}",
|
||||
elements
|
||||
|
||||
Reference in New Issue
Block a user