Skip to content

Commit 815dd09

Browse files
Merge pull request RustPython#309 from holygits/add-os-error
Add OSError
2 parents 676f602 + 9a37825 commit 815dd09

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

vm/src/exceptions.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,38 +108,27 @@ impl ExceptionZoo {
108108
dict_type: &PyObjectRef,
109109
) -> Self {
110110
// Sorted By Hierarchy then alphabetized.
111-
112111
let base_exception_type =
113112
create_type("BaseException", &type_type, &object_type, &dict_type);
114113

115114
let exception_type = create_type("Exception", &type_type, &base_exception_type, &dict_type);
116115

117116
let assertion_error =
118117
create_type("AssertionError", &type_type, &exception_type, &dict_type);
119-
let attribute_error = create_type(
120-
"AttributeError",
121-
&type_type,
122-
&exception_type.clone(),
123-
&dict_type,
124-
);
118+
let attribute_error =
119+
create_type("AttributeError", &type_type, &exception_type, &dict_type);
125120
let import_error = create_type("ImportError", &type_type, &exception_type, &dict_type);
126-
let index_error = create_type(
127-
"IndexError",
128-
&type_type,
129-
&exception_type.clone(),
130-
&dict_type,
131-
);
132-
let key_error = create_type("KeyError", &type_type, &exception_type.clone(), &dict_type);
133-
let name_error = create_type("NameError", &type_type, &exception_type.clone(), &dict_type);
121+
let index_error = create_type("IndexError", &type_type, &exception_type, &dict_type);
122+
let key_error = create_type("KeyError", &type_type, &exception_type, &dict_type);
123+
let name_error = create_type("NameError", &type_type, &exception_type, &dict_type);
124+
let os_error = create_type("OSError", &type_type, &exception_type, &dict_type);
134125
let runtime_error = create_type("RuntimeError", &type_type, &exception_type, &dict_type);
135126
let stop_iteration = create_type("StopIteration", &type_type, &exception_type, &dict_type);
136127
let syntax_error = create_type("SyntaxError", &type_type, &exception_type, &dict_type);
137128
let type_error = create_type("TypeError", &type_type, &exception_type, &dict_type);
138129
let value_error = create_type("ValueError", &type_type, &exception_type, &dict_type);
139130
let os_error = create_type("OSError", &type_type, &exception_type.clone(), &dict_type);
140131

141-
let file_not_found_error =
142-
create_type("FileNotFoundError", &type_type, &import_error, &dict_type);
143132
let module_not_found_error =
144133
create_type("ModuleNotFoundError", &type_type, &import_error, &dict_type);
145134
let not_implemented_error = create_type(
@@ -148,8 +137,10 @@ impl ExceptionZoo {
148137
&runtime_error,
149138
&dict_type,
150139
);
151-
let permission_error =
152-
create_type("PermissionError", &type_type, &import_error, &dict_type);
140+
141+
let file_not_found_error =
142+
create_type("FileNotFoundError", &type_type, &os_error, &dict_type);
143+
let permission_error = create_type("PermissionError", &type_type, &os_error, &dict_type);
153144

154145
ExceptionZoo {
155146
assertion_error,
@@ -163,6 +154,7 @@ impl ExceptionZoo {
163154
module_not_found_error,
164155
name_error,
165156
not_implemented_error,
157+
os_error,
166158
permission_error,
167159
runtime_error,
168160
stop_iteration,

0 commit comments

Comments
 (0)