Commit ffb5cfc8 authored by Damien George's avatar Damien George
Browse files

py: Removed some unnecessary exception objects.

They still exist in commented-out form in objexcept.c if they are ever
needed.
parent caac542b
...@@ -85,7 +85,6 @@ STATIC const mp_builtin_elem_t builtin_object_table[] = { ...@@ -85,7 +85,6 @@ STATIC const mp_builtin_elem_t builtin_object_table[] = {
{ MP_QSTR_AttributeError, (mp_obj_t)&mp_type_AttributeError }, { MP_QSTR_AttributeError, (mp_obj_t)&mp_type_AttributeError },
{ MP_QSTR_BufferError, (mp_obj_t)&mp_type_BufferError }, { MP_QSTR_BufferError, (mp_obj_t)&mp_type_BufferError },
{ MP_QSTR_EOFError, (mp_obj_t)&mp_type_EOFError }, { MP_QSTR_EOFError, (mp_obj_t)&mp_type_EOFError },
{ MP_QSTR_EnvironmentError, (mp_obj_t)&mp_type_EnvironmentError },
{ MP_QSTR_Exception, (mp_obj_t)&mp_type_Exception }, { MP_QSTR_Exception, (mp_obj_t)&mp_type_Exception },
{ MP_QSTR_FloatingPointError, (mp_obj_t)&mp_type_FloatingPointError }, { MP_QSTR_FloatingPointError, (mp_obj_t)&mp_type_FloatingPointError },
{ MP_QSTR_GeneratorExit, (mp_obj_t)&mp_type_GeneratorExit }, { MP_QSTR_GeneratorExit, (mp_obj_t)&mp_type_GeneratorExit },
...@@ -100,17 +99,14 @@ STATIC const mp_builtin_elem_t builtin_object_table[] = { ...@@ -100,17 +99,14 @@ STATIC const mp_builtin_elem_t builtin_object_table[] = {
{ MP_QSTR_NotImplementedError, (mp_obj_t)&mp_type_NotImplementedError }, { MP_QSTR_NotImplementedError, (mp_obj_t)&mp_type_NotImplementedError },
{ MP_QSTR_OSError, (mp_obj_t)&mp_type_OSError }, { MP_QSTR_OSError, (mp_obj_t)&mp_type_OSError },
{ MP_QSTR_OverflowError, (mp_obj_t)&mp_type_OverflowError }, { MP_QSTR_OverflowError, (mp_obj_t)&mp_type_OverflowError },
{ MP_QSTR_ReferenceError, (mp_obj_t)&mp_type_ReferenceError },
{ MP_QSTR_RuntimeError, (mp_obj_t)&mp_type_RuntimeError }, { MP_QSTR_RuntimeError, (mp_obj_t)&mp_type_RuntimeError },
{ MP_QSTR_StopIteration, (mp_obj_t)&mp_type_StopIteration },
{ MP_QSTR_SyntaxError, (mp_obj_t)&mp_type_SyntaxError }, { MP_QSTR_SyntaxError, (mp_obj_t)&mp_type_SyntaxError },
{ MP_QSTR_SystemError, (mp_obj_t)&mp_type_SystemError }, { MP_QSTR_SystemError, (mp_obj_t)&mp_type_SystemError },
{ MP_QSTR_SystemExit, (mp_obj_t)&mp_type_SystemExit },
{ MP_QSTR_TabError, (mp_obj_t)&mp_type_TabError },
{ MP_QSTR_TypeError, (mp_obj_t)&mp_type_TypeError }, { MP_QSTR_TypeError, (mp_obj_t)&mp_type_TypeError },
{ MP_QSTR_UnboundLocalError, (mp_obj_t)&mp_type_UnboundLocalError }, { MP_QSTR_UnboundLocalError, (mp_obj_t)&mp_type_UnboundLocalError },
{ MP_QSTR_ValueError, (mp_obj_t)&mp_type_ValueError }, { MP_QSTR_ValueError, (mp_obj_t)&mp_type_ValueError },
{ MP_QSTR_ZeroDivisionError, (mp_obj_t)&mp_type_ZeroDivisionError }, { MP_QSTR_ZeroDivisionError, (mp_obj_t)&mp_type_ZeroDivisionError },
{ MP_QSTR_StopIteration, (mp_obj_t)&mp_type_StopIteration },
// Somehow CPython managed to have OverflowError not inherit from ValueError ;-/ // Somehow CPython managed to have OverflowError not inherit from ValueError ;-/
// TODO: For MICROPY_CPYTHON_COMPAT==0 use ValueError to avoid exc proliferation // TODO: For MICROPY_CPYTHON_COMPAT==0 use ValueError to avoid exc proliferation
......
...@@ -191,17 +191,12 @@ extern const mp_obj_type_t mp_type_ArithmeticError; ...@@ -191,17 +191,12 @@ extern const mp_obj_type_t mp_type_ArithmeticError;
extern const mp_obj_type_t mp_type_AssertionError; extern const mp_obj_type_t mp_type_AssertionError;
extern const mp_obj_type_t mp_type_AttributeError; extern const mp_obj_type_t mp_type_AttributeError;
extern const mp_obj_type_t mp_type_BufferError; extern const mp_obj_type_t mp_type_BufferError;
extern const mp_obj_type_t mp_type_BytesWarning;
extern const mp_obj_type_t mp_type_DeprecationWarning;
extern const mp_obj_type_t mp_type_EOFError; extern const mp_obj_type_t mp_type_EOFError;
extern const mp_obj_type_t mp_type_EnvironmentError;
extern const mp_obj_type_t mp_type_Exception; extern const mp_obj_type_t mp_type_Exception;
extern const mp_obj_type_t mp_type_FloatingPointError; extern const mp_obj_type_t mp_type_FloatingPointError;
extern const mp_obj_type_t mp_type_FutureWarning;
extern const mp_obj_type_t mp_type_GeneratorExit; extern const mp_obj_type_t mp_type_GeneratorExit;
extern const mp_obj_type_t mp_type_IOError; extern const mp_obj_type_t mp_type_IOError;
extern const mp_obj_type_t mp_type_ImportError; extern const mp_obj_type_t mp_type_ImportError;
extern const mp_obj_type_t mp_type_ImportWarning;
extern const mp_obj_type_t mp_type_IndentationError; extern const mp_obj_type_t mp_type_IndentationError;
extern const mp_obj_type_t mp_type_IndexError; extern const mp_obj_type_t mp_type_IndexError;
extern const mp_obj_type_t mp_type_KeyError; extern const mp_obj_type_t mp_type_KeyError;
...@@ -211,43 +206,16 @@ extern const mp_obj_type_t mp_type_NameError; ...@@ -211,43 +206,16 @@ extern const mp_obj_type_t mp_type_NameError;
extern const mp_obj_type_t mp_type_NotImplementedError; extern const mp_obj_type_t mp_type_NotImplementedError;
extern const mp_obj_type_t mp_type_OSError; extern const mp_obj_type_t mp_type_OSError;
extern const mp_obj_type_t mp_type_OverflowError; extern const mp_obj_type_t mp_type_OverflowError;
extern const mp_obj_type_t mp_type_PendingDeprecationWarning;
extern const mp_obj_type_t mp_type_ReferenceError;
extern const mp_obj_type_t mp_type_ResourceWarning;
extern const mp_obj_type_t mp_type_RuntimeError; extern const mp_obj_type_t mp_type_RuntimeError;
extern const mp_obj_type_t mp_type_RuntimeWarning; extern const mp_obj_type_t mp_type_StopIteration;
extern const mp_obj_type_t mp_type_SyntaxError; extern const mp_obj_type_t mp_type_SyntaxError;
extern const mp_obj_type_t mp_type_SyntaxWarning;
extern const mp_obj_type_t mp_type_SystemError; extern const mp_obj_type_t mp_type_SystemError;
extern const mp_obj_type_t mp_type_SystemExit;
extern const mp_obj_type_t mp_type_TabError;
extern const mp_obj_type_t mp_type_TypeError; extern const mp_obj_type_t mp_type_TypeError;
extern const mp_obj_type_t mp_type_UnboundLocalError; extern const mp_obj_type_t mp_type_UnboundLocalError;
extern const mp_obj_type_t mp_type_UserWarning;
extern const mp_obj_type_t mp_type_ValueError; extern const mp_obj_type_t mp_type_ValueError;
extern const mp_obj_type_t mp_type_Warning;
extern const mp_obj_type_t mp_type_ZeroDivisionError; extern const mp_obj_type_t mp_type_ZeroDivisionError;
extern const mp_obj_type_t mp_type_StopIteration;
/*extern const mp_obj_type_t mp_type_BaseException;
extern const mp_obj_type_t mp_type_AssertionError;
extern const mp_obj_type_t mp_type_AttributeError;
extern const mp_obj_type_t mp_type_ImportError;
extern const mp_obj_type_t mp_type_IndentationError;
extern const mp_obj_type_t mp_type_IndexError;
extern const mp_obj_type_t mp_type_KeyError;
extern const mp_obj_type_t mp_type_NameError;
extern const mp_obj_type_t mp_type_SyntaxError;
extern const mp_obj_type_t mp_type_TypeError;
extern const mp_obj_type_t mp_type_ValueError;
extern const mp_obj_type_t mp_type_OverflowError;
extern const mp_obj_type_t mp_type_OSError;
extern const mp_obj_type_t mp_type_NotImplementedError;
extern const mp_obj_type_t mp_type_StopIteration;
extern const mp_obj_type_t mp_type_ZeroDivisionError;*/
// Constant objects, globally accessible // Constant objects, globally accessible
extern const mp_obj_t mp_const_none; extern const mp_obj_t mp_const_none;
extern const mp_obj_t mp_const_false; extern const mp_obj_t mp_const_false;
extern const mp_obj_t mp_const_true; extern const mp_obj_t mp_const_true;
......
...@@ -96,7 +96,7 @@ const mp_obj_type_t mp_type_ ## exc_name = { \ ...@@ -96,7 +96,7 @@ const mp_obj_type_t mp_type_ ## exc_name = { \
// List of all exceptions, arranged as in the table at: // List of all exceptions, arranged as in the table at:
// http://docs.python.org/3.3/library/exceptions.html // http://docs.python.org/3.3/library/exceptions.html
MP_DEFINE_EXCEPTION_BASE(BaseException) MP_DEFINE_EXCEPTION_BASE(BaseException)
MP_DEFINE_EXCEPTION(SystemExit, BaseException) //MP_DEFINE_EXCEPTION(SystemExit, BaseException)
//MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException) //MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException)
MP_DEFINE_EXCEPTION(GeneratorExit, BaseException) MP_DEFINE_EXCEPTION(GeneratorExit, BaseException)
MP_DEFINE_EXCEPTION(Exception, BaseException) MP_DEFINE_EXCEPTION(Exception, BaseException)
...@@ -110,7 +110,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException) ...@@ -110,7 +110,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
MP_DEFINE_EXCEPTION(AssertionError, Exception) MP_DEFINE_EXCEPTION(AssertionError, Exception)
MP_DEFINE_EXCEPTION(AttributeError, Exception) MP_DEFINE_EXCEPTION(AttributeError, Exception)
MP_DEFINE_EXCEPTION(BufferError, Exception) MP_DEFINE_EXCEPTION(BufferError, Exception)
MP_DEFINE_EXCEPTION(EnvironmentError, Exception) //MP_DEFINE_EXCEPTION(EnvironmentError, Exception)
MP_DEFINE_EXCEPTION(EOFError, Exception) MP_DEFINE_EXCEPTION(EOFError, Exception)
MP_DEFINE_EXCEPTION(ImportError, Exception) MP_DEFINE_EXCEPTION(ImportError, Exception)
MP_DEFINE_EXCEPTION(IOError, Exception) MP_DEFINE_EXCEPTION(IOError, Exception)
...@@ -140,7 +140,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException) ...@@ -140,7 +140,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
MP_DEFINE_EXCEPTION(TimeoutError, OSError)*/ MP_DEFINE_EXCEPTION(TimeoutError, OSError)*/
MP_DEFINE_EXCEPTION(FileExistsError, OSError) MP_DEFINE_EXCEPTION(FileExistsError, OSError)
MP_DEFINE_EXCEPTION(FileNotFoundError, OSError) MP_DEFINE_EXCEPTION(FileNotFoundError, OSError)
MP_DEFINE_EXCEPTION(ReferenceError, Exception) //MP_DEFINE_EXCEPTION(ReferenceError, Exception)
MP_DEFINE_EXCEPTION(RuntimeError, Exception) MP_DEFINE_EXCEPTION(RuntimeError, Exception)
MP_DEFINE_EXCEPTION_BASE(RuntimeError) MP_DEFINE_EXCEPTION_BASE(RuntimeError)
MP_DEFINE_EXCEPTION(NotImplementedError, RuntimeError) MP_DEFINE_EXCEPTION(NotImplementedError, RuntimeError)
...@@ -148,7 +148,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException) ...@@ -148,7 +148,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
MP_DEFINE_EXCEPTION_BASE(SyntaxError) MP_DEFINE_EXCEPTION_BASE(SyntaxError)
MP_DEFINE_EXCEPTION(IndentationError, SyntaxError) MP_DEFINE_EXCEPTION(IndentationError, SyntaxError)
MP_DEFINE_EXCEPTION_BASE(IndentationError) MP_DEFINE_EXCEPTION_BASE(IndentationError)
MP_DEFINE_EXCEPTION(TabError, IndentationError) //MP_DEFINE_EXCEPTION(TabError, IndentationError)
MP_DEFINE_EXCEPTION(SystemError, Exception) MP_DEFINE_EXCEPTION(SystemError, Exception)
MP_DEFINE_EXCEPTION(TypeError, Exception) MP_DEFINE_EXCEPTION(TypeError, Exception)
MP_DEFINE_EXCEPTION(ValueError, Exception) MP_DEFINE_EXCEPTION(ValueError, Exception)
......
...@@ -39,7 +39,6 @@ Q(AssertionError) ...@@ -39,7 +39,6 @@ Q(AssertionError)
Q(AttributeError) Q(AttributeError)
Q(BufferError) Q(BufferError)
Q(EOFError) Q(EOFError)
Q(EnvironmentError)
Q(Exception) Q(Exception)
Q(FileExistsError) Q(FileExistsError)
Q(FileNotFoundError) Q(FileNotFoundError)
...@@ -56,16 +55,12 @@ Q(NameError) ...@@ -56,16 +55,12 @@ Q(NameError)
Q(NotImplementedError) Q(NotImplementedError)
Q(OSError) Q(OSError)
Q(OverflowError) Q(OverflowError)
Q(ReferenceError)
Q(RuntimeError) Q(RuntimeError)
Q(SyntaxError) Q(SyntaxError)
Q(SystemError) Q(SystemError)
Q(SystemExit)
Q(TabError)
Q(TypeError) Q(TypeError)
Q(UnboundLocalError) Q(UnboundLocalError)
Q(ValueError) Q(ValueError)
Q(Warning)
Q(ZeroDivisionError) Q(ZeroDivisionError)
Q(None) Q(None)
......
...@@ -38,25 +38,25 @@ try: ...@@ -38,25 +38,25 @@ try:
except BufferError: except BufferError:
print("Caught BufferError") print("Caught BufferError")
try: #try:
raise BytesWarning # raise BytesWarning
except Warning: #except Warning:
print("Caught BytesWarning via Warning") # print("Caught BytesWarning via Warning")
try: #try:
raise BytesWarning # raise BytesWarning
except BytesWarning: #except BytesWarning:
print("Caught BytesWarning") # print("Caught BytesWarning")
try: #try:
raise DeprecationWarning # raise DeprecationWarning
except Warning: #except Warning:
print("Caught DeprecationWarning via Warning") # print("Caught DeprecationWarning via Warning")
try: #try:
raise DeprecationWarning # raise DeprecationWarning
except DeprecationWarning: #except DeprecationWarning:
print("Caught DeprecationWarning") # print("Caught DeprecationWarning")
try: try:
raise EOFError raise EOFError
...@@ -68,15 +68,15 @@ try: ...@@ -68,15 +68,15 @@ try:
except EOFError: except EOFError:
print("Caught EOFError") print("Caught EOFError")
try: #try:
raise EnvironmentError # raise EnvironmentError
except Exception: #except Exception:
print("Caught EnvironmentError via Exception") # print("Caught EnvironmentError via Exception")
try: #try:
raise EnvironmentError # raise EnvironmentError
except EnvironmentError: #except EnvironmentError:
print("Caught EnvironmentError") # print("Caught EnvironmentError")
try: try:
raise Exception raise Exception
...@@ -98,15 +98,15 @@ try: ...@@ -98,15 +98,15 @@ try:
except FloatingPointError: except FloatingPointError:
print("Caught FloatingPointError") print("Caught FloatingPointError")
try: #try:
raise FutureWarning # raise FutureWarning
except Warning: #except Warning:
print("Caught FutureWarning via Warning") # print("Caught FutureWarning via Warning")
try: #try:
raise FutureWarning # raise FutureWarning
except FutureWarning: #except FutureWarning:
print("Caught FutureWarning") # print("Caught FutureWarning")
try: try:
raise IOError raise IOError
...@@ -128,15 +128,15 @@ try: ...@@ -128,15 +128,15 @@ try:
except ImportError: except ImportError:
print("Caught ImportError") print("Caught ImportError")
try: #try:
raise ImportWarning # raise ImportWarning
except Warning: #except Warning:
print("Caught ImportWarning via Warning") # print("Caught ImportWarning via Warning")
try: #try:
raise ImportWarning # raise ImportWarning
except ImportWarning: #except ImportWarning:
print("Caught ImportWarning") # print("Caught ImportWarning")
try: try:
raise IndentationError raise IndentationError
...@@ -228,35 +228,35 @@ try: ...@@ -228,35 +228,35 @@ try:
except OverflowError: except OverflowError:
print("Caught OverflowError") print("Caught OverflowError")
try: #try:
raise PendingDeprecationWarning # raise PendingDeprecationWarning
except Warning: #except Warning:
print("Caught PendingDeprecationWarning via Warning") # print("Caught PendingDeprecationWarning via Warning")
try: #try:
raise PendingDeprecationWarning # raise PendingDeprecationWarning
except PendingDeprecationWarning: #except PendingDeprecationWarning:
print("Caught PendingDeprecationWarning") # print("Caught PendingDeprecationWarning")
try: #try:
raise ReferenceError # raise ReferenceError
except Exception: #except Exception:
print("Caught ReferenceError via Exception") # print("Caught ReferenceError via Exception")
try: #try:
raise ReferenceError # raise ReferenceError
except ReferenceError: #except ReferenceError:
print("Caught ReferenceError") # print("Caught ReferenceError")
try: #try:
raise ResourceWarning # raise ResourceWarning
except Warning: #except Warning:
print("Caught ResourceWarning via Warning") # print("Caught ResourceWarning via Warning")
try: #try:
raise ResourceWarning # raise ResourceWarning
except ResourceWarning: #except ResourceWarning:
print("Caught ResourceWarning") # print("Caught ResourceWarning")
try: try:
raise RuntimeError raise RuntimeError
...@@ -268,15 +268,15 @@ try: ...@@ -268,15 +268,15 @@ try:
except RuntimeError: except RuntimeError:
print("Caught RuntimeError") print("Caught RuntimeError")
try: #try:
raise RuntimeWarning # raise RuntimeWarning
except Warning: #except Warning:
print("Caught RuntimeWarning via Warning") # print("Caught RuntimeWarning via Warning")
try: #try:
raise RuntimeWarning # raise RuntimeWarning
except RuntimeWarning: #except RuntimeWarning:
print("Caught RuntimeWarning") # print("Caught RuntimeWarning")
try: try:
raise SyntaxError raise SyntaxError
...@@ -288,15 +288,15 @@ try: ...@@ -288,15 +288,15 @@ try:
except SyntaxError: except SyntaxError:
print("Caught SyntaxError") print("Caught SyntaxError")
try: #try:
raise SyntaxWarning # raise SyntaxWarning
except Warning: #except Warning:
print("Caught SyntaxWarning via Warning") # print("Caught SyntaxWarning via Warning")
try: #try:
raise SyntaxWarning # raise SyntaxWarning
except SyntaxWarning: #except SyntaxWarning:
print("Caught SyntaxWarning") # print("Caught SyntaxWarning")
try: try:
raise SystemError raise SystemError
...@@ -308,15 +308,15 @@ try: ...@@ -308,15 +308,15 @@ try:
except SystemError: except SystemError:
print("Caught SystemError") print("Caught SystemError")
try: #try:
raise TabError # raise TabError
except IndentationError: #except IndentationError:
print("Caught TabError via IndentationError") # print("Caught TabError via IndentationError")
try: #try:
raise TabError # raise TabError
except TabError: #except TabError:
print("Caught TabError") # print("Caught TabError")
try: try:
raise TypeError raise TypeError
...@@ -338,15 +338,15 @@ try: ...@@ -338,15 +338,15 @@ try:
except UnboundLocalError: except UnboundLocalError:
print("Caught UnboundLocalError") print("Caught UnboundLocalError")
try: #try:
raise UserWarning # raise UserWarning
except Warning: #except Warning:
print("Caught UserWarning via Warning") # print("Caught UserWarning via Warning")
try: #try:
raise UserWarning # raise UserWarning
except UserWarning: #except UserWarning:
print("Caught UserWarning") # print("Caught UserWarning")
try: try:
raise ValueError raise ValueError
...@@ -358,15 +358,15 @@ try: ...@@ -358,15 +358,15 @@ try:
except ValueError: except ValueError:
print("Caught ValueError") print("Caught ValueError")
try: #try:
raise Warning # raise Warning
except Exception: #except Exception:
print("Caught Warning via Exception") # print("Caught Warning via Exception")
try: #try:
raise Warning # raise Warning
except Warning: #except Warning:
print("Caught Warning") # print("Caught Warning")
try: try:
raise ZeroDivisionError raise ZeroDivisionError
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment