@@ -323,13 +323,16 @@ impl PyContext {
323323
324324pub fn new_tuple ( & self , elements : Vec < PyObjectRef > ) ->PyObjectRef {
325325PyObject :: new (
326- PyObjectKind :: Tuple { elements : elements} ,
326+ PyObjectKind :: Sequence { elements : elements} ,
327327self . tuple_type ( ) ,
328328)
329329}
330330
331331pub 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+ )
333336}
334337
335338pub fn new_set ( & self , elements : Vec < PyObjectRef > ) ->PyObjectRef {
@@ -673,10 +676,7 @@ pub enum PyObjectKind {
673676Bytes {
674677value : Vec < u8 > ,
675678} ,
676- List {
677- elements : Vec < PyObjectRef > ,
678- } ,
679- Tuple {
679+ Sequence {
680680elements : Vec < PyObjectRef > ,
681681} ,
682682Dict {
@@ -737,9 +737,8 @@ impl fmt::Debug for PyObjectKind {
737737& PyObjectKind :: Integer { ref value} =>write ! ( f, "int {}" , value) ,
738738& PyObjectKind :: Float { ref value} =>write ! ( f, "float {}" , value) ,
739739& 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" ) ,
743742& PyObjectKind :: Dict { elements : _} =>write ! ( f, "dict" ) ,
744743& PyObjectKind :: Set { elements : _} =>write ! ( f, "set" ) ,
745744& PyObjectKind :: Iterator {
@@ -790,28 +789,14 @@ impl PyObject {
790789PyObjectKind :: Float { ref value} =>format ! ( "{:?}" , value) ,
791790PyObjectKind :: Complex { ref value} =>format ! ( "{:?}" , value) ,
792791PyObjectKind :: Bytes { ref value} =>format ! ( "b'{:?}'" , value) ,
793- PyObjectKind :: List { ref elements} =>format ! (
794- "[{}]" ,
792+ PyObjectKind :: Sequence { ref elements} =>format ! (
793+ "(/ [{}]/) " ,
795794 elements
796795. iter( )
797796. map( |elem| elem. borrow( ) . str ( ) )
798797. collect:: <Vec <_>>( )
799798. join( ", " )
800799) ,
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- }
815800PyObjectKind :: Dict { ref elements} =>format ! (
816801"{{ {} }}" ,
817802 elements