@@ -733,75 +733,92 @@ pub fn make_module(ctx: &PyContext) -> PyObjectRef {
733
733
//set __name__ fixes: https://github.com/RustPython/RustPython/issues/146
734
734
py_mod. set_item ( "__name__" , ctx. new_str ( String :: from ( "__main__" ) ) ) ;
735
735
736
- py_mod . set_item ( "abs" , ctx. new_rustfunc ( builtin_abs) ) ;
737
- py_mod . set_item ( "all" , ctx. new_rustfunc ( builtin_all) ) ;
738
- py_mod . set_item ( "any" , ctx. new_rustfunc ( builtin_any) ) ;
739
- py_mod . set_item ( "bin" , ctx. new_rustfunc ( builtin_bin) ) ;
740
- py_mod . set_item ( "bool" , ctx. bool_type ( ) ) ;
741
- py_mod . set_item ( "bytearray" , ctx. bytearray_type ( ) ) ;
742
- py_mod . set_item ( "bytes" , ctx. bytes_type ( ) ) ;
743
- py_mod . set_item ( "callable" , ctx. new_rustfunc ( builtin_callable) ) ;
744
- py_mod . set_item ( "chr" , ctx. new_rustfunc ( builtin_chr) ) ;
745
- py_mod . set_item ( "classmethod" , ctx. classmethod_type ( ) ) ;
746
- py_mod . set_item ( "compile" , ctx. new_rustfunc ( builtin_compile) ) ;
747
- py_mod . set_item ( "complex" , ctx. complex_type ( ) ) ;
748
- py_mod . set_item ( "delattr" , ctx. new_rustfunc ( builtin_delattr) ) ;
749
- py_mod . set_item ( "dict" , ctx. dict_type ( ) ) ;
750
- py_mod . set_item ( "divmod" , ctx. new_rustfunc ( builtin_divmod) ) ;
751
- py_mod . set_item ( "dir" , ctx. new_rustfunc ( builtin_dir) ) ;
752
- py_mod . set_item ( "enumerate" , ctx. new_rustfunc ( builtin_enumerate) ) ;
753
- py_mod . set_item ( "eval" , ctx. new_rustfunc ( builtin_eval) ) ;
754
- py_mod . set_item ( "exec" , ctx. new_rustfunc ( builtin_exec) ) ;
755
- py_mod . set_item ( "float" , ctx. float_type ( ) ) ;
756
- py_mod . set_item ( "frozenset" , ctx. frozenset_type ( ) ) ;
757
- py_mod . set_item ( "filter" , ctx. new_rustfunc ( builtin_filter) ) ;
758
- py_mod . set_item ( "getattr" , ctx. new_rustfunc ( builtin_getattr) ) ;
759
- py_mod . set_item ( "hasattr" , ctx. new_rustfunc ( builtin_hasattr) ) ;
760
- py_mod . set_item ( "hash" , ctx. new_rustfunc ( builtin_hash) ) ;
761
- py_mod . set_item ( "hex" , ctx. new_rustfunc ( builtin_hex) ) ;
762
- py_mod . set_item ( "id" , ctx. new_rustfunc ( builtin_id) ) ;
763
- py_mod . set_item ( "int" , ctx. int_type ( ) ) ;
764
- py_mod . set_item ( "isinstance" , ctx. new_rustfunc ( builtin_isinstance) ) ;
765
- py_mod . set_item ( "issubclass" , ctx. new_rustfunc ( builtin_issubclass) ) ;
766
- py_mod . set_item ( "iter" , ctx. new_rustfunc ( builtin_iter) ) ;
767
- py_mod . set_item ( "len" , ctx. new_rustfunc ( builtin_len) ) ;
768
- py_mod . set_item ( "list" , ctx. list_type ( ) ) ;
769
- py_mod . set_item ( "locals" , ctx. new_rustfunc ( builtin_locals) ) ;
770
- py_mod . set_item ( "map" , ctx. new_rustfunc ( builtin_map) ) ;
771
- py_mod . set_item ( "max" , ctx. new_rustfunc ( builtin_max) ) ;
772
- py_mod . set_item ( "min" , ctx. new_rustfunc ( builtin_min) ) ;
773
- py_mod . set_item ( "object" , ctx. object ( ) ) ;
774
- py_mod . set_item ( "oct" , ctx. new_rustfunc ( builtin_oct) ) ;
775
- py_mod . set_item ( "ord" , ctx. new_rustfunc ( builtin_ord) ) ;
776
- py_mod . set_item ( "next" , ctx. new_rustfunc ( builtin_next) ) ;
777
- py_mod . set_item ( "pow" , ctx. new_rustfunc ( builtin_pow) ) ;
778
- py_mod . set_item ( "print" , ctx. new_rustfunc ( builtin_print) ) ;
779
- py_mod . set_item ( "property" , ctx. property_type ( ) ) ;
780
- py_mod . set_item ( "range" , ctx. new_rustfunc ( builtin_range) ) ;
781
- py_mod . set_item ( "repr" , ctx. new_rustfunc ( builtin_repr) ) ;
782
- py_mod . set_item ( "set" , ctx. set_type ( ) ) ;
783
- py_mod . set_item ( "setattr" , ctx. new_rustfunc ( builtin_setattr) ) ;
784
- py_mod . set_item ( "staticmethod" , ctx. staticmethod_type ( ) ) ;
785
- py_mod . set_item ( "str" , ctx. str_type ( ) ) ;
786
- py_mod . set_item ( "sum" , ctx. new_rustfunc ( builtin_sum) ) ;
787
- py_mod . set_item ( "super" , ctx. super_type ( ) ) ;
788
- py_mod . set_item ( "tuple" , ctx. tuple_type ( ) ) ;
789
- py_mod . set_item ( "type" , ctx. type_type ( ) ) ;
790
- py_mod . set_item ( "zip" , ctx. new_rustfunc ( builtin_zip) ) ;
736
+ ctx . set_item ( & py_mod , "abs" , ctx. new_rustfunc ( builtin_abs) ) ;
737
+ ctx . set_attr ( & py_mod , "all" , ctx. new_rustfunc ( builtin_all) ) ;
738
+ ctx . set_attr ( & py_mod , "any" , ctx. new_rustfunc ( builtin_any) ) ;
739
+ ctx . set_attr ( & py_mod , "bin" , ctx. new_rustfunc ( builtin_bin) ) ;
740
+ ctx . set_attr ( & py_mod , "bool" , ctx. bool_type ( ) ) ;
741
+ ctx . set_attr ( & py_mod , "bytearray" , ctx. bytearray_type ( ) ) ;
742
+ ctx . set_attr ( & py_mod , "bytes" , ctx. bytes_type ( ) ) ;
743
+ ctx . set_attr ( & py_mod , "callable" , ctx. new_rustfunc ( builtin_callable) ) ;
744
+ ctx . set_attr ( & py_mod , "chr" , ctx. new_rustfunc ( builtin_chr) ) ;
745
+ ctx . set_attr ( & py_mod , "classmethod" , ctx. classmethod_type ( ) ) ;
746
+ ctx . set_attr ( & py_mod , "compile" , ctx. new_rustfunc ( builtin_compile) ) ;
747
+ ctx . set_attr ( & py_mod , "complex" , ctx. complex_type ( ) ) ;
748
+ ctx . set_attr ( & py_mod , "delattr" , ctx. new_rustfunc ( builtin_delattr) ) ;
749
+ ctx . set_attr ( & py_mod , "dict" , ctx. dict_type ( ) ) ;
750
+ ctx . set_attr ( & py_mod , "divmod" , ctx. new_rustfunc ( builtin_divmod) ) ;
751
+ ctx . set_attr ( & py_mod , "dir" , ctx. new_rustfunc ( builtin_dir) ) ;
752
+ ctx . set_attr ( & py_mod , "enumerate" , ctx. new_rustfunc ( builtin_enumerate) ) ;
753
+ ctx . set_attr ( & py_mod , "eval" , ctx. new_rustfunc ( builtin_eval) ) ;
754
+ ctx . set_attr ( & py_mod , "exec" , ctx. new_rustfunc ( builtin_exec) ) ;
755
+ ctx . set_attr ( & py_mod , "float" , ctx. float_type ( ) ) ;
756
+ ctx . set_attr ( & py_mod , "frozenset" , ctx. frozenset_type ( ) ) ;
757
+ ctx . set_attr ( & py_mod , "filter" , ctx. new_rustfunc ( builtin_filter) ) ;
758
+ ctx . set_attr ( & py_mod , "getattr" , ctx. new_rustfunc ( builtin_getattr) ) ;
759
+ ctx . set_attr ( & py_mod , "hasattr" , ctx. new_rustfunc ( builtin_hasattr) ) ;
760
+ ctx . set_attr ( & py_mod , "hash" , ctx. new_rustfunc ( builtin_hash) ) ;
761
+ ctx . set_attr ( & py_mod , "hex" , ctx. new_rustfunc ( builtin_hex) ) ;
762
+ ctx . set_attr ( & py_mod , "id" , ctx. new_rustfunc ( builtin_id) ) ;
763
+ ctx . set_attr ( & py_mod , "int" , ctx. int_type ( ) ) ;
764
+ ctx . set_attr ( & py_mod , "isinstance" , ctx. new_rustfunc ( builtin_isinstance) ) ;
765
+ ctx . set_attr ( & py_mod , "issubclass" , ctx. new_rustfunc ( builtin_issubclass) ) ;
766
+ ctx . set_attr ( & py_mod , "iter" , ctx. new_rustfunc ( builtin_iter) ) ;
767
+ ctx . set_attr ( & py_mod , "len" , ctx. new_rustfunc ( builtin_len) ) ;
768
+ ctx . set_attr ( & py_mod , "list" , ctx. list_type ( ) ) ;
769
+ ctx . set_attr ( & py_mod , "locals" , ctx. new_rustfunc ( builtin_locals) ) ;
770
+ ctx . set_attr ( & py_mod , "map" , ctx. new_rustfunc ( builtin_map) ) ;
771
+ ctx . set_attr ( & py_mod , "max" , ctx. new_rustfunc ( builtin_max) ) ;
772
+ ctx . set_attr ( & py_mod , "min" , ctx. new_rustfunc ( builtin_min) ) ;
773
+ ctx . set_attr ( & py_mod , "object" , ctx. object ( ) ) ;
774
+ ctx . set_attr ( & py_mod , "oct" , ctx. new_rustfunc ( builtin_oct) ) ;
775
+ ctx . set_attr ( & py_mod , "ord" , ctx. new_rustfunc ( builtin_ord) ) ;
776
+ ctx . set_attr ( & py_mod , "next" , ctx. new_rustfunc ( builtin_next) ) ;
777
+ ctx . set_attr ( & py_mod , "pow" , ctx. new_rustfunc ( builtin_pow) ) ;
778
+ ctx . set_attr ( & py_mod , "print" , ctx. new_rustfunc ( builtin_print) ) ;
779
+ ctx . set_attr ( & py_mod , "property" , ctx. property_type ( ) ) ;
780
+ ctx . set_attr ( & py_mod , "range" , ctx. new_rustfunc ( builtin_range) ) ;
781
+ ctx . set_attr ( & py_mod , "repr" , ctx. new_rustfunc ( builtin_repr) ) ;
782
+ ctx . set_attr ( & py_mod , "set" , ctx. set_type ( ) ) ;
783
+ ctx . set_attr ( & py_mod , "setattr" , ctx. new_rustfunc ( builtin_setattr) ) ;
784
+ ctx . set_attr ( & py_mod , "staticmethod" , ctx. staticmethod_type ( ) ) ;
785
+ ctx . set_attr ( & py_mod , "str" , ctx. str_type ( ) ) ;
786
+ ctx . set_attr ( & py_mod , "sum" , ctx. new_rustfunc ( builtin_sum) ) ;
787
+ ctx . set_attr ( & py_mod , "super" , ctx. super_type ( ) ) ;
788
+ ctx . set_attr ( & py_mod , "tuple" , ctx. tuple_type ( ) ) ;
789
+ ctx . set_attr ( & py_mod , "type" , ctx. type_type ( ) ) ;
790
+ ctx . set_attr ( & py_mod , "zip" , ctx. new_rustfunc ( builtin_zip) ) ;
791
791
792
792
// Exceptions:
793
- py_mod. set_item ( "BaseException" , ctx. exceptions . base_exception_type . clone ( ) ) ;
794
- py_mod. set_item ( "Exception" , ctx. exceptions . exception_type . clone ( ) ) ;
795
- py_mod. set_item ( "AssertionError" , ctx. exceptions . assertion_error . clone ( ) ) ;
796
- py_mod. set_item ( "AttributeError" , ctx. exceptions . attribute_error . clone ( ) ) ;
797
- py_mod. set_item ( "NameError" , ctx. exceptions . name_error . clone ( ) ) ;
798
- py_mod. set_item ( "RuntimeError" , ctx. exceptions . runtime_error . clone ( ) ) ;
799
- py_mod. set_item (
793
+ ctx. set_attr (
794
+ & py_mod,
795
+ "BaseException" ,
796
+ ctx. exceptions . base_exception_type . clone ( ) ,
797
+ ) ;
798
+ ctx. set_attr ( & py_mod, "Exception" , ctx. exceptions . exception_type . clone ( ) ) ;
799
+ ctx. set_attr (
800
+ & py_mod,
801
+ "AssertionError" ,
802
+ ctx. exceptions . assertion_error . clone ( ) ,
803
+ ) ;
804
+ ctx. set_attr (
805
+ & py_mod,
806
+ "AttributeError" ,
807
+ ctx. exceptions . attribute_error . clone ( ) ,
808
+ ) ;
809
+ ctx. set_attr ( & py_mod, "NameError" , ctx. exceptions . name_error . clone ( ) ) ;
810
+ ctx. set_attr (
811
+ & py_mod,
812
+ "RuntimeError" ,
813
+ ctx. exceptions . runtime_error . clone ( ) ,
814
+ ) ;
815
+ ctx. set_attr (
816
+ & py_mod,
800
817
"NotImplementedError" ,
801
818
ctx. exceptions . not_implemented_error . clone ( ) ,
802
819
) ;
803
F438
- py_mod . set_item ( "TypeError" , ctx. exceptions . type_error . clone ( ) ) ;
804
- py_mod . set_item ( "ValueError" , ctx. exceptions . value_error . clone ( ) ) ;
820
+ ctx . set_attr ( & py_mod , "TypeError" , ctx. exceptions . type_error . clone ( ) ) ;
821
+ ctx . set_attr ( & py_mod , "ValueError" , ctx. exceptions . value_error . clone ( ) ) ;
805
822
806
823
py_mod
807
824
}
0 commit comments