mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 19:24:57 +08:00
When I run list[()], I modify it so that list[()] comes out
This commit is contained in:
1 parent
84e714bc56
commit
263aec1532
1 file changed
+20
-11
@@ -98,17 +98,26 @@ impl PyGenericAlias {
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
Ok(format!(
|
||||
"{}[{}]",
|
||||
repr_item(self.origin.as_object().to_owned(), vm)?,
|
||||
self.args
|
||||
.as_slice()
|
||||
.iter()
|
||||
.map(|o| repr_item(o.clone(), vm))
|
||||
.collect::<PyResult<Vec<_>>>()?
|
||||
.join(", ")
|
||||
))
|
||||
|
||||
if self.args.len() == 0 {
|
||||
Ok(format!(
|
||||
"{}[{}]",
|
||||
repr_item(self.origin.as_object().to_owned(), vm)?,
|
||||
"()"
|
||||
))
|
||||
}
|
||||
else {
|
||||
Ok(format!(
|
||||
"{}[{}]",
|
||||
repr_item(self.origin.as_object().to_owned(), vm)?,
|
||||
self.args
|
||||
.as_slice()
|
||||
.iter()
|
||||
.map(|o| repr_item(o.clone(), vm))
|
||||
.collect::<PyResult<Vec<_>>>()?
|
||||
.join(", ")
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[pyproperty(magic)]
|
||||
|
||||
Reference in new issue
Block a user