@@ -323,13 +323,16 @@ impl PyContext {
323
323
324
324
pub fn new_tuple ( & self , elements : Vec < PyObjectRef > ) -> PyObjectRef {
325
325
PyObject :: new (
326
- PyObjectKind :: Tuple { elements : elements } ,
326
+ PyObjectKind :: Sequence { elements : elements } ,
327
327
self . tuple_type ( ) ,
328
328
)
329
329
}
330
330
331
331
pub fn new_list ( & self , elements : Vec < PyObjectRef > ) -> PyObjectRef {
332
- PyObject :: new ( PyObjectKind :: List { elements : elements } , self . list_type ( ) )
332
+ PyObject :: new (
333
+ PyObjectKind :: Sequence { elements : elements } ,
334
+ self . list_type ( ) ,
335
+ )
333
336
}
334
337
335
338
pub fn new_set ( & self , elements : Vec < PyObjectRef > ) -> PyObjectRef {
@@ -673,10 +676,7 @@ pub enum PyObjectKind {
673
676
Bytes {
674
677
value : Vec < u8 > ,
675
678
} ,
676
- List {
677
- elements : Vec < PyObjectRef > ,
678
- } ,
679
- Tuple {
679
+ Sequence {
680
680
elements : Vec < PyObjectRef > ,
681
681
} ,
682
682
Dict {
@@ -737,9 +737,8 @@ impl fmt::Debug for PyObjectKind {
737
737
& PyObjectKind :: Integer { ref value } => write ! ( f, "int {}" , value) ,
738
738
& PyObjectKind :: Float { ref value } => write ! ( f, "float {}" , value) ,
739
739
& PyObjectKind :: Complex { ref value } => write ! ( f, "complex {}" , value) ,
740
- & PyObjectKind :: Bytes { ref value } => write ! ( f, "bytes {:?}" , value) ,
741
- & PyObjectKind :: List { elements : _ } => write ! ( f, "list" ) ,
742
- & PyObjectKind :: Tuple { elements : _ } => write ! ( f, "tuple" ) ,
740
+ & PyObjectKind :: Bytes { ref value } => write ! ( f, "bytes/bytearray {:?}" , value) ,
741
+ & PyObjectKind :: Sequence { elements : _ } => write ! ( f, "list or tuple" ) ,
743
742
& PyObjectKind :: Dict { elements : _ } => write ! ( f, "dict" ) ,
744
743
& PyObjectKind :: Set { elements : _ } => write ! ( f, "set" ) ,
745
744
& PyObjectKind :: Iterator {
@@ -790,28 +789,14 @@ impl PyObject {
790
789
PyObjectKind :: Float { ref value } => format ! ( "{:?}" , value) ,
791
790
PyObjectKind :: Complex { ref value } => format ! ( "{:?}" , value) ,
792
791
PyObjectKind :: Bytes { ref value } => format ! ( "b'{:?}'" , value) ,
793
- PyObjectKind :: List { ref elements } => format ! (
794
- "[{}]" ,
792
+ PyObjectKind :: Sequence { ref elements } => format ! (
793
+ "(/ [{}]/) " ,
795
794
elements
796
795
. iter( )
797
796
. map( |elem| elem. borrow( ) . str ( ) )
798
797
. collect:: <Vec <_>>( )
799
798
. join( ", " )
800
799
) ,
801
- PyObjectKind :: Tuple { ref elements } => {
802
- if elements. len ( ) == 1 {
803
- format ! ( "({},)" , elements[ 0 ] . borrow( ) . str ( ) )
804
- } else {
805
- format ! (
806
- "({})" ,
807
- elements
808
- . iter( )
809
- . map( |elem| elem. borrow( ) . str ( ) )
810
- . collect:: <Vec <_>>( )
811
- . join( ", " )
812
- )
813
- }
814
- }
815
800
PyObjectKind :: Dict { ref elements } => format ! (
816
801
"{{ {} }}" ,
817
802
elements
0 commit comments