@@ -86,7 +86,7 @@ fn _nothing() -> PyObjectRef {
86
86
pub fn create_type (
87
87
name : & str ,
88
88
type_type : & PyObjectRef ,
89
- object : & PyObjectRef ,
89
+ base : & PyObjectRef ,
90
90
dict_type : & PyObjectRef ,
91
91
) -> PyObjectRef {
92
92
let dict = PyObject :: new (
@@ -95,7 +95,7 @@ pub fn create_type(
95
95
} ,
96
96
dict_type. clone ( ) ,
97
97
) ;
98
- objtype:: new ( type_type. clone ( ) , name, vec ! [ object . clone( ) ] , dict) . unwrap ( )
98
+ objtype:: new ( type_type. clone ( ) , name, vec ! [ base . clone( ) ] , dict) . unwrap ( )
99
99
}
100
100
101
101
// Basic objects:
@@ -119,7 +119,7 @@ impl PyContext {
119
119
let float_type = create_type ( "float" , & type_type, & object_type, & dict_type) ;
120
120
let bytes_type = create_type ( "bytes" , & type_type, & object_type, & dict_type) ;
121
121
let tuple_type = create_type ( "tuple" , & type_type, & object_type, & dict_type) ;
122
- let bool_type = create_type ( "bool" , & type_type, & object_type , & dict_type) ;
122
+ let bool_type = create_type ( "bool" , & type_type, & int_type , & dict_type) ;
123
123
let exceptions = exceptions:: ExceptionZoo :: new ( & type_type, & object_type, & dict_type) ;
124
124
125
125
let none = PyObject :: new (
@@ -220,7 +220,12 @@ impl PyContext {
220
220
}
221
221
222
222
pub fn new_bool ( & self , b : bool ) -> PyObjectRef {
223
- PyObject :: new ( PyObjectKind :: Boolean { value : b } , self . bool_type ( ) )
223
+ PyObject :: new (
224
+ PyObjectKind :: Integer {
225
+ value : if b { 1 } else { 0 } ,
226
+ } ,
227
+ self . bool_type ( ) ,
228
+ )
224
229
}
225
230
226
231
pub fn new_tuple ( & self , elements : Vec < PyObjectRef > ) -> PyObjectRef {
@@ -563,9 +568,6 @@ pub enum PyObjectKind {
563
568
Float {
564
569
value : f64 ,
565
570
} ,
566
- Boolean {
567
- value : bool ,
568
- } ,
569
571
Bytes {
570
572
value : Vec < u8 > ,
571
573
} ,
@@ -627,7 +629,6 @@ impl fmt::Debug for PyObjectKind {
627
629
& PyObjectKind :: Integer { ref value } => write ! ( f, "int {}" , value) ,
628
630
& PyObjectKind :: Float { ref value } => write ! ( f, "float {}" , value) ,
629
631
& PyObjectKind :: Bytes { ref value } => write ! ( f, "bytes {:?}" , value) ,
630
- & PyObjectKind :: Boolean { ref value } => write ! ( f, "boolean {}" , value) ,
631
632
& PyObjectKind :: List { elements : _ } => write ! ( f, "list" ) ,
632
633
& PyObjectKind :: Tuple { elements : _ } => write ! ( f, "tuple" ) ,
633
634
& PyObjectKind :: Dict { elements : _ } => write ! ( f, "dict" ) ,
@@ -675,7 +676,6 @@ impl PyObject {
675
676
PyObjectKind :: Integer { ref value } => format ! ( "{:?}" , value) ,
676
677
PyObjectKind :: Float { ref value } => format ! ( "{:?}" , value) ,
677
678
PyObjectKind :: Bytes { ref value } => format ! ( "b'{:?}'" , value) ,
678
- PyObjectKind :: Boolean { ref value } => format ! ( "{:?}" , value) ,
679
679
PyObjectKind :: List { ref elements } => format ! (
680
680
"[{}]" ,
681
681
elements
@@ -797,7 +797,6 @@ impl PartialEq for PyObject {
797
797
false
798
798
}
799
799
}
800
- ( PyObjectKind :: Boolean { value : a } , PyObjectKind :: Boolean { value : b } ) => a == b,
801
800
( PyObjectKind :: None , PyObjectKind :: None ) => true ,
802
801
_ => panic ! (
803
802
"TypeError in COMPARE_OP: can't compare {:?} with {:?}" ,
0 commit comments