@@ -15,7 +15,7 @@ fn exception_init(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
1515 vm. new_str ( "No msg" . to_string ( ) )
1616 } ;
1717 let traceback = vm. ctx . new_list ( Vec :: new ( ) ) ;
18- zelf. set_attr ( "__msg__ " , msg) ;
18+ zelf. set_attr ( "msg " , msg) ;
1919 zelf. set_attr ( "__traceback__" , traceback) ;
2020 Ok ( vm. get_none ( ) )
2121}
@@ -71,7 +71,7 @@ fn exception_str(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
7171 required = [ ( exc, Some ( vm. ctx. exceptions. exception_type. clone( ) ) ) ]
7272 ) ;
7373 let type_name = objtype:: get_type_name ( & exc. typ ( ) ) ;
74- let msg = if let Some ( m) = exc. get_attr ( "__msg__ " ) {
74+ let msg = if let Some ( m) = exc. get_attr ( "msg " ) {
7575 objstr:: get_value ( & m)
7676 } else {
7777 panic ! ( "Error message must be set" ) ;
@@ -84,6 +84,7 @@ fn exception_str(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
8484pub struct ExceptionZoo {
8585 pub base_exception_type : PyObjectRef ,
8686 pub exception_type : PyObjectRef ,
87+ pub syntax_error : PyObjectRef ,
8788 pub assertion_error : PyObjectRef ,
8889 pub attribute_error : PyObjectRef ,
8990 pub name_error : PyObjectRef ,
@@ -92,6 +93,8 @@ pub struct ExceptionZoo {
9293 pub stop_iteration : PyObjectRef ,
9394 pub type_error : PyObjectRef ,
9495 pub value_error : PyObjectRef ,
96+ pub import_error : PyObjectRef ,
97+ pub module_not_found_error : PyObjectRef ,
9598}
9699
97100impl ExceptionZoo {
@@ -109,6 +112,12 @@ impl ExceptionZoo {
109112 & base_exception_type,
110113 & dict_type,
111114 ) ;
115+ let syntax_error = create_type (
116+ & String :: from ( "SyntaxError" ) ,
117+ & type_type,
118+ & exception_type,
119+ & dict_type,
120+ ) ;
112121 let assertion_error = create_type (
113122 & String :: from ( "AssertionError" ) ,
114123 & type_type,
@@ -157,10 +166,23 @@ impl ExceptionZoo {
157166 & exception_type,
158167 & dict_type,
159168 ) ;
169+ let import_error = create_type (
170+ & String :: from ( "ImportError" ) ,
171+ & type_type,
172+ & exception_type,
173+ & dict_type,
174+ ) ;
175+ let module_not_found_error = create_type (
176+ & String :: from ( "ModuleNotFoundError" ) ,
177+ & type_type,
178+ & import_error,
179+ & dict_type,
180+ ) ;
160181
161182 ExceptionZoo {
162183 base_exception_type : base_exception_type,
163184 exception_type : exception_type,
185+ syntax_error : syntax_error,
164186 assertion_error : assertion_error,
165187 attribute_error : attribute_error,
166188 name_error : name_error,
@@ -169,6 +191,8 @@ impl ExceptionZoo {
169191 stop_iteration : stop_iteration,
170192 type_error : type_error,
171193 value_error : value_error,
194+ import_error : import_error,
195+ module_not_found_error : module_not_found_error,
172196 }
173197 }
174198}
0 commit comments