Skip to content

Commit ffb5cfc

Browse files
committed
py: Removed some unnecessary exception objects.
They still exist in commented-out form in objexcept.c if they are ever needed.
1 parent caac542 commit ffb5cfc

5 files changed

Lines changed: 110 additions & 151 deletions

File tree

py/builtintables.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ STATIC const mp_builtin_elem_t builtin_object_table[] = {
8585
{ MP_QSTR_AttributeError, (mp_obj_t)&mp_type_AttributeError },
8686
{ MP_QSTR_BufferError, (mp_obj_t)&mp_type_BufferError },
8787
{ MP_QSTR_EOFError, (mp_obj_t)&mp_type_EOFError },
88-
{ MP_QSTR_EnvironmentError, (mp_obj_t)&mp_type_EnvironmentError },
8988
{ MP_QSTR_Exception, (mp_obj_t)&mp_type_Exception },
9089
{ MP_QSTR_FloatingPointError, (mp_obj_t)&mp_type_FloatingPointError },
9190
{ MP_QSTR_GeneratorExit, (mp_obj_t)&mp_type_GeneratorExit },
@@ -100,17 +99,14 @@ STATIC const mp_builtin_elem_t builtin_object_table[] = {
10099
{ MP_QSTR_NotImplementedError, (mp_obj_t)&mp_type_NotImplementedError },
101100
{ MP_QSTR_OSError, (mp_obj_t)&mp_type_OSError },
102101
{ MP_QSTR_OverflowError, (mp_obj_t)&mp_type_OverflowError },
103-
{ MP_QSTR_ReferenceError, (mp_obj_t)&mp_type_ReferenceError },
104102
{ MP_QSTR_RuntimeError, (mp_obj_t)&mp_type_RuntimeError },
103+
{ MP_QSTR_StopIteration, (mp_obj_t)&mp_type_StopIteration },
105104
{ MP_QSTR_SyntaxError, (mp_obj_t)&mp_type_SyntaxError },
106105
{ MP_QSTR_SystemError, (mp_obj_t)&mp_type_SystemError },
107-
{ MP_QSTR_SystemExit, (mp_obj_t)&mp_type_SystemExit },
108-
{ MP_QSTR_TabError, (mp_obj_t)&mp_type_TabError },
109106
{ MP_QSTR_TypeError, (mp_obj_t)&mp_type_TypeError },
110107
{ MP_QSTR_UnboundLocalError, (mp_obj_t)&mp_type_UnboundLocalError },
111108
{ MP_QSTR_ValueError, (mp_obj_t)&mp_type_ValueError },
112109
{ MP_QSTR_ZeroDivisionError, (mp_obj_t)&mp_type_ZeroDivisionError },
113-
{ MP_QSTR_StopIteration, (mp_obj_t)&mp_type_StopIteration },
114110
// Somehow CPython managed to have OverflowError not inherit from ValueError ;-/
115111
// TODO: For MICROPY_CPYTHON_COMPAT==0 use ValueError to avoid exc proliferation
116112

py/obj.h

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,12 @@ extern const mp_obj_type_t mp_type_ArithmeticError;
191191
extern const mp_obj_type_t mp_type_AssertionError;
192192
extern const mp_obj_type_t mp_type_AttributeError;
193193
extern const mp_obj_type_t mp_type_BufferError;
194-
extern const mp_obj_type_t mp_type_BytesWarning;
195-
extern const mp_obj_type_t mp_type_DeprecationWarning;
196194
extern const mp_obj_type_t mp_type_EOFError;
197-
extern const mp_obj_type_t mp_type_EnvironmentError;
198195
extern const mp_obj_type_t mp_type_Exception;
199196
extern const mp_obj_type_t mp_type_FloatingPointError;
200-
extern const mp_obj_type_t mp_type_FutureWarning;
201197
extern const mp_obj_type_t mp_type_GeneratorExit;
202198
extern const mp_obj_type_t mp_type_IOError;
203199
extern const mp_obj_type_t mp_type_ImportError;
204-
extern const mp_obj_type_t mp_type_ImportWarning;
205200
extern const mp_obj_type_t mp_type_IndentationError;
206201
extern const mp_obj_type_t mp_type_IndexError;
207202
extern const mp_obj_type_t mp_type_KeyError;
@@ -211,43 +206,16 @@ extern const mp_obj_type_t mp_type_NameError;
211206
extern const mp_obj_type_t mp_type_NotImplementedError;
212207
extern const mp_obj_type_t mp_type_OSError;
213208
extern const mp_obj_type_t mp_type_OverflowError;
214-
extern const mp_obj_type_t mp_type_PendingDeprecationWarning;
215-
extern const mp_obj_type_t mp_type_ReferenceError;
216-
extern const mp_obj_type_t mp_type_ResourceWarning;
217209
extern const mp_obj_type_t mp_type_RuntimeError;
218-
extern const mp_obj_type_t mp_type_RuntimeWarning;
210+
extern const mp_obj_type_t mp_type_StopIteration;
219211
extern const mp_obj_type_t mp_type_SyntaxError;
220-
extern const mp_obj_type_t mp_type_SyntaxWarning;
221212
extern const mp_obj_type_t mp_type_SystemError;
222-
extern const mp_obj_type_t mp_type_SystemExit;
223-
extern const mp_obj_type_t mp_type_TabError;
224213
extern const mp_obj_type_t mp_type_TypeError;
225214
extern const mp_obj_type_t mp_type_UnboundLocalError;
226-
extern const mp_obj_type_t mp_type_UserWarning;
227215
extern const mp_obj_type_t mp_type_ValueError;
228-
extern const mp_obj_type_t mp_type_Warning;
229216
extern const mp_obj_type_t mp_type_ZeroDivisionError;
230217

231-
extern const mp_obj_type_t mp_type_StopIteration;
232-
/*extern const mp_obj_type_t mp_type_BaseException;
233-
extern const mp_obj_type_t mp_type_AssertionError;
234-
extern const mp_obj_type_t mp_type_AttributeError;
235-
extern const mp_obj_type_t mp_type_ImportError;
236-
extern const mp_obj_type_t mp_type_IndentationError;
237-
extern const mp_obj_type_t mp_type_IndexError;
238-
extern const mp_obj_type_t mp_type_KeyError;
239-
extern const mp_obj_type_t mp_type_NameError;
240-
extern const mp_obj_type_t mp_type_SyntaxError;
241-
extern const mp_obj_type_t mp_type_TypeError;
242-
extern const mp_obj_type_t mp_type_ValueError;
243-
extern const mp_obj_type_t mp_type_OverflowError;
244-
extern const mp_obj_type_t mp_type_OSError;
245-
extern const mp_obj_type_t mp_type_NotImplementedError;
246-
extern const mp_obj_type_t mp_type_StopIteration;
247-
extern const mp_obj_type_t mp_type_ZeroDivisionError;*/
248-
249218
// Constant objects, globally accessible
250-
251219
extern const mp_obj_t mp_const_none;
252220
extern const mp_obj_t mp_const_false;
253221
extern const mp_obj_t mp_const_true;

py/objexcept.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const mp_obj_type_t mp_type_ ## exc_name = { \
9696
// List of all exceptions, arranged as in the table at:
9797
// http://docs.python.org/3.3/library/exceptions.html
9898
MP_DEFINE_EXCEPTION_BASE(BaseException)
99-
MP_DEFINE_EXCEPTION(SystemExit, BaseException)
99+
//MP_DEFINE_EXCEPTION(SystemExit, BaseException)
100100
//MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException)
101101
MP_DEFINE_EXCEPTION(GeneratorExit, BaseException)
102102
MP_DEFINE_EXCEPTION(Exception, BaseException)
@@ -110,7 +110,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
110110
MP_DEFINE_EXCEPTION(AssertionError, Exception)
111111
MP_DEFINE_EXCEPTION(AttributeError, Exception)
112112
MP_DEFINE_EXCEPTION(BufferError, Exception)
113-
MP_DEFINE_EXCEPTION(EnvironmentError, Exception)
113+
//MP_DEFINE_EXCEPTION(EnvironmentError, Exception)
114114
MP_DEFINE_EXCEPTION(EOFError, Exception)
115115
MP_DEFINE_EXCEPTION(ImportError, Exception)
116116
MP_DEFINE_EXCEPTION(IOError, Exception)
@@ -140,15 +140,15 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
140140
MP_DEFINE_EXCEPTION(TimeoutError, OSError)*/
141141
MP_DEFINE_EXCEPTION(FileExistsError, OSError)
142142
MP_DEFINE_EXCEPTION(FileNotFoundError, OSError)
143-
MP_DEFINE_EXCEPTION(ReferenceError, Exception)
143+
//MP_DEFINE_EXCEPTION(ReferenceError, Exception)
144144
MP_DEFINE_EXCEPTION(RuntimeError, Exception)
145145
MP_DEFINE_EXCEPTION_BASE(RuntimeError)
146146
MP_DEFINE_EXCEPTION(NotImplementedError, RuntimeError)
147147
MP_DEFINE_EXCEPTION(SyntaxError, Exception)
148148
MP_DEFINE_EXCEPTION_BASE(SyntaxError)
149149
MP_DEFINE_EXCEPTION(IndentationError, SyntaxError)
150150
MP_DEFINE_EXCEPTION_BASE(IndentationError)
151-
MP_DEFINE_EXCEPTION(TabError, IndentationError)
151+
//MP_DEFINE_EXCEPTION(TabError, IndentationError)
152152
MP_DEFINE_EXCEPTION(SystemError, Exception)
153153
MP_DEFINE_EXCEPTION(TypeError, Exception)
154154
MP_DEFINE_EXCEPTION(ValueError, Exception)

py/qstrdefs.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Q(AssertionError)
3939
Q(AttributeError)
4040
Q(BufferError)
4141
Q(EOFError)
42-
Q(EnvironmentError)
4342
Q(Exception)
4443
Q(FileExistsError)
4544
Q(FileNotFoundError)
@@ -56,16 +55,12 @@ Q(NameError)
5655
Q(NotImplementedError)
5756
Q(OSError)
5857
Q(OverflowError)
59-
Q(ReferenceError)
6058
Q(RuntimeError)
6159
Q(SyntaxError)
6260
Q(SystemError)
63-
Q(SystemExit)
64-
Q(TabError)
6561
Q(TypeError)
6662
Q(UnboundLocalError)
6763
Q(ValueError)
68-
Q(Warning)
6964
Q(ZeroDivisionError)
7065

7166
Q(None)

0 commit comments

Comments
 (0)