Skip to content

Commit c63f984

Browse files
committed
py: Thin out predefined exceptions.
Only exceptions that are actually used are left prefedined. Hierarchy is still there, and removed exceptions are just commented out.
1 parent 01b877d commit c63f984

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

py/builtintables.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ STATIC const mp_builtin_elem_t builtin_object_table[] = {
8484
{ MP_QSTR_ArithmeticError, (mp_obj_t)&mp_type_ArithmeticError },
8585
{ MP_QSTR_AssertionError, (mp_obj_t)&mp_type_AssertionError },
8686
{ MP_QSTR_AttributeError, (mp_obj_t)&mp_type_AttributeError },
87-
{ MP_QSTR_BufferError, (mp_obj_t)&mp_type_BufferError },
8887
{ MP_QSTR_EOFError, (mp_obj_t)&mp_type_EOFError },
8988
{ MP_QSTR_Exception, (mp_obj_t)&mp_type_Exception },
90-
{ MP_QSTR_FloatingPointError, (mp_obj_t)&mp_type_FloatingPointError },
9189
{ MP_QSTR_GeneratorExit, (mp_obj_t)&mp_type_GeneratorExit },
9290
{ MP_QSTR_IOError, (mp_obj_t)&mp_type_IOError },
9391
{ MP_QSTR_ImportError, (mp_obj_t)&mp_type_ImportError },
@@ -105,7 +103,6 @@ STATIC const mp_builtin_elem_t builtin_object_table[] = {
105103
{ MP_QSTR_SyntaxError, (mp_obj_t)&mp_type_SyntaxError },
106104
{ MP_QSTR_SystemError, (mp_obj_t)&mp_type_SystemError },
107105
{ MP_QSTR_TypeError, (mp_obj_t)&mp_type_TypeError },
108-
{ MP_QSTR_UnboundLocalError, (mp_obj_t)&mp_type_UnboundLocalError },
109106
{ MP_QSTR_ValueError, (mp_obj_t)&mp_type_ValueError },
110107
{ MP_QSTR_ZeroDivisionError, (mp_obj_t)&mp_type_ZeroDivisionError },
111108
// Somehow CPython managed to have OverflowError not inherit from ValueError ;-/

py/obj.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,8 @@ extern const mp_obj_type_t mp_type_BaseException;
203203
extern const mp_obj_type_t mp_type_ArithmeticError;
204204
extern const mp_obj_type_t mp_type_AssertionError;
205205
extern const mp_obj_type_t mp_type_AttributeError;
206-
extern const mp_obj_type_t mp_type_BufferError;
207206
extern const mp_obj_type_t mp_type_EOFError;
208207
extern const mp_obj_type_t mp_type_Exception;
209-
extern const mp_obj_type_t mp_type_FloatingPointError;
210208
extern const mp_obj_type_t mp_type_GeneratorExit;
211209
extern const mp_obj_type_t mp_type_IOError;
212210
extern const mp_obj_type_t mp_type_ImportError;
@@ -224,7 +222,6 @@ extern const mp_obj_type_t mp_type_StopIteration;
224222
extern const mp_obj_type_t mp_type_SyntaxError;
225223
extern const mp_obj_type_t mp_type_SystemError;
226224
extern const mp_obj_type_t mp_type_TypeError;
227-
extern const mp_obj_type_t mp_type_UnboundLocalError;
228225
extern const mp_obj_type_t mp_type_ValueError;
229226
extern const mp_obj_type_t mp_type_ZeroDivisionError;
230227

py/objexcept.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
112112
MP_DEFINE_EXCEPTION(StopIteration, Exception)
113113
MP_DEFINE_EXCEPTION(ArithmeticError, Exception)
114114
MP_DEFINE_EXCEPTION_BASE(ArithmeticError)
115-
MP_DEFINE_EXCEPTION(FloatingPointError, ArithmeticError)
115+
//MP_DEFINE_EXCEPTION(FloatingPointError, ArithmeticError)
116116
MP_DEFINE_EXCEPTION(OverflowError, ArithmeticError)
117117
MP_DEFINE_EXCEPTION(ZeroDivisionError, ArithmeticError)
118118
MP_DEFINE_EXCEPTION(AssertionError, Exception)
119119
MP_DEFINE_EXCEPTION(AttributeError, Exception)
120-
MP_DEFINE_EXCEPTION(BufferError, Exception)
120+
//MP_DEFINE_EXCEPTION(BufferError, Exception)
121121
//MP_DEFINE_EXCEPTION(EnvironmentError, Exception)
122122
MP_DEFINE_EXCEPTION(EOFError, Exception)
123123
MP_DEFINE_EXCEPTION(ImportError, Exception)
@@ -129,11 +129,11 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
129129
MP_DEFINE_EXCEPTION(MemoryError, Exception)
130130
MP_DEFINE_EXCEPTION(NameError, Exception)
131131
MP_DEFINE_EXCEPTION_BASE(NameError)
132-
MP_DEFINE_EXCEPTION(UnboundLocalError, NameError)
132+
//MP_DEFINE_EXCEPTION(UnboundLocalError, NameError)
133133
MP_DEFINE_EXCEPTION(OSError, Exception)
134134
MP_DEFINE_EXCEPTION_BASE(OSError)
135-
// Probably don't need these
136-
/*MP_DEFINE_EXCEPTION(BlockingIOError, OSError)
135+
/*
136+
MP_DEFINE_EXCEPTION(BlockingIOError, OSError)
137137
MP_DEFINE_EXCEPTION(ChildProcessError, OSError)
138138
MP_DEFINE_EXCEPTION(ConnectionError, OSError)
139139
MP_DEFINE_EXCEPTION(BrokenPipeError, ConnectionError)
@@ -145,18 +145,21 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
145145
MP_DEFINE_EXCEPTION(NotADirectoryError, OSError)
146146
MP_DEFINE_EXCEPTION(PermissionError, OSError)
147147
MP_DEFINE_EXCEPTION(ProcessLookupError, OSError)
148-
MP_DEFINE_EXCEPTION(TimeoutError, OSError)*/
148+
MP_DEFINE_EXCEPTION(TimeoutError, OSError)
149149
MP_DEFINE_EXCEPTION(FileExistsError, OSError)
150150
MP_DEFINE_EXCEPTION(FileNotFoundError, OSError)
151-
//MP_DEFINE_EXCEPTION(ReferenceError, Exception)
151+
MP_DEFINE_EXCEPTION(ReferenceError, Exception)
152+
*/
152153
MP_DEFINE_EXCEPTION(RuntimeError, Exception)
153154
MP_DEFINE_EXCEPTION_BASE(RuntimeError)
154155
MP_DEFINE_EXCEPTION(NotImplementedError, RuntimeError)
155156
MP_DEFINE_EXCEPTION(SyntaxError, Exception)
156157
MP_DEFINE_EXCEPTION_BASE(SyntaxError)
157158
MP_DEFINE_EXCEPTION(IndentationError, SyntaxError)
159+
/*
158160
MP_DEFINE_EXCEPTION_BASE(IndentationError)
159-
//MP_DEFINE_EXCEPTION(TabError, IndentationError)
161+
MP_DEFINE_EXCEPTION(TabError, IndentationError)
162+
*/
160163
MP_DEFINE_EXCEPTION(SystemError, Exception)
161164
MP_DEFINE_EXCEPTION(TypeError, Exception)
162165
MP_DEFINE_EXCEPTION(ValueError, Exception)

0 commit comments

Comments
 (0)