# HG changeset patch # User Paul Boddie # Date 1484261426 -3600 # Node ID 41896438df61998c39a68ed7736afb961083eff4 # Parent 0e7b5712a29b9cca0a174504d85179dce735cae3 Reorganised the exception hierarchy to more closely resemble the Python one. Removed warning classes. diff -r 0e7b5712a29b -r 41896438df61 lib/__builtins__/__init__.py --- a/lib/__builtins__/__init__.py Thu Jan 12 23:29:39 2017 +0100 +++ b/lib/__builtins__/__init__.py Thu Jan 12 23:50:26 2017 +0100 @@ -3,7 +3,7 @@ """ Simple built-in classes and functions. -Copyright (C) 2015, 2016 Paul Boddie +Copyright (C) 2015, 2016, 2017 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -19,22 +19,19 @@ this program. If not, see . """ -from __builtins__.core import function, get_using, module, object, type, \ - BaseException, Exception, MemoryError, \ - OverflowError, TypeError, ZeroDivisionError, \ - UnboundMethodInvocation, Warning +from __builtins__.core import ( + function, get_using, module, object, type, + ArithmeticError, Exception, FloatingPointError, MemoryError, OverflowError, + TypeError, UnboundMethodInvocation, ZeroDivisionError + ) # Exceptions. from __builtins__.exception import ( - ArithmeticError, AssertionError, AttributeError, - DeprecationWarning, EOFError, EnvironmentError, - FloatingPointError, - FutureWarning, IndentationError, IndexError, IOError, @@ -42,12 +39,9 @@ KeyboardInterrupt, NotImplementedError, OSError, - PendingDeprecationWarning, RuntimeError, - RuntimeWarning, StopIteration, SyntaxError, - SyntaxWarning, SystemError, SystemExit, TabError, @@ -55,8 +49,6 @@ UnicodeEncodeError, UnicodeError, UnicodeTranslateError, - UnicodeWarning, - UserWarning, ValueError ) diff -r 0e7b5712a29b -r 41896438df61 lib/__builtins__/core.py --- a/lib/__builtins__/core.py Thu Jan 12 23:29:39 2017 +0100 +++ b/lib/__builtins__/core.py Thu Jan 12 23:50:26 2017 +0100 @@ -3,7 +3,7 @@ """ Core objects. -Copyright (C) 2015, 2016 Paul Boddie +Copyright (C) 2015, 2016, 2017 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -113,18 +113,57 @@ __repr__ = __str__ -class BaseException: +class Exception: "The root of all exception types." pass -class Exception(BaseException): pass -class MemoryError(Exception): pass -class OverflowError(Exception): pass -class TypeError(Exception): pass -class UnboundMethodInvocation(Exception): pass -class Warning: pass -class ZeroDivisionError(Exception): pass +# Fundamental exceptions + +class MemoryError(Exception): + + "An error indicating failure to allocate or manage memory." + + pass + +class TypeError(Exception): + + "An error indicating unsuitable type usage." + + pass + +class UnboundMethodInvocation(Exception): + + "An error indicating an attempt to call an unbound method." + + pass + +class ArithmeticError(Exception): + + "A general arithmetic operation error." + + pass + +class FloatingPointError(Exception): + + "A floating point operation error." + + pass + +class OverflowError(ArithmeticError): + + """ + Indicates that an arithmetic operation produced a result that could not be + represented. + """ + + pass + +class ZeroDivisionError(ArithmeticError): + + "An error occurring when an attempt was made to divide an operand by zero." + + pass # vim: tabstop=4 expandtab shiftwidth=4 diff -r 0e7b5712a29b -r 41896438df61 lib/__builtins__/exception/__init__.py --- a/lib/__builtins__/exception/__init__.py Thu Jan 12 23:29:39 2017 +0100 +++ b/lib/__builtins__/exception/__init__.py Thu Jan 12 23:50:26 2017 +0100 @@ -3,7 +3,7 @@ """ Exception objects. -Copyright (C) 2015 Paul Boddie +Copyright (C) 2015, 2016, 2017 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -27,6 +27,7 @@ IndexError, KeyError, NotImplementedError, + RuntimeError, StopIteration, ValueError ) @@ -41,27 +42,15 @@ AttributeError ) -from __builtins__.exception.numeric import ( - ArithmeticError, - FloatingPointError - ) - from __builtins__.exception.program import ( - DeprecationWarning, - FutureWarning, IndentationError, - PendingDeprecationWarning, SyntaxError, - SyntaxWarning, - TabError, - UserWarning + TabError ) from __builtins__.exception.system import ( EnvironmentError, OSError, - RuntimeError, - RuntimeWarning, SystemError, SystemExit ) @@ -70,8 +59,7 @@ UnicodeDecodeError, UnicodeEncodeError, UnicodeError, - UnicodeTranslateError, - UnicodeWarning + UnicodeTranslateError ) # vim: tabstop=4 expandtab shiftwidth=4 diff -r 0e7b5712a29b -r 41896438df61 lib/__builtins__/exception/base.py --- a/lib/__builtins__/exception/base.py Thu Jan 12 23:29:39 2017 +0100 +++ b/lib/__builtins__/exception/base.py Thu Jan 12 23:50:26 2017 +0100 @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -Base exception objects. +Base exception objects. See __builtins__.core for the core exceptions. Copyright (C) 2015, 2016 Paul Boddie @@ -19,21 +19,33 @@ this program. If not, see . """ -class IndexError(Exception): +class LookupError(Exception): + + "A general lookup error." + + pass + +class IndexError(LookupError): "An error condition involving an index." def __init__(self, index): self.index = index -class KeyError(Exception): +class KeyError(LookupError): "An error concerned with a dictionary key." def __init__(self, key): self.key = key -class NotImplementedError(Exception): +class RuntimeError(Exception): + + "A general runtime error." + + pass + +class NotImplementedError(RuntimeError): "An error indicating an unimplemented function or method." diff -r 0e7b5712a29b -r 41896438df61 lib/__builtins__/exception/io.py --- a/lib/__builtins__/exception/io.py Thu Jan 12 23:29:39 2017 +0100 +++ b/lib/__builtins__/exception/io.py Thu Jan 12 23:50:26 2017 +0100 @@ -3,7 +3,7 @@ """ Input/output exception objects. -Copyright (C) 2015, 2016 Paul Boddie +Copyright (C) 2015, 2016, 2017 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -35,6 +35,10 @@ self.value = value -class KeyboardInterrupt(Exception): pass +class KeyboardInterrupt(Exception): + + "An interruption condition initiated by keyboard or console input." + + pass # vim: tabstop=4 expandtab shiftwidth=4 diff -r 0e7b5712a29b -r 41896438df61 lib/__builtins__/exception/numeric.py --- a/lib/__builtins__/exception/numeric.py Thu Jan 12 23:29:39 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -#!/usr/bin/env python - -""" -Numeric exception objects. - -Copyright (C) 2015, 2016 Paul Boddie - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 3 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see . -""" - -class ArithmeticError(Exception): pass -class FloatingPointError(Exception): pass - -# vim: tabstop=4 expandtab shiftwidth=4 diff -r 0e7b5712a29b -r 41896438df61 lib/__builtins__/exception/program.py --- a/lib/__builtins__/exception/program.py Thu Jan 12 23:29:39 2017 +0100 +++ b/lib/__builtins__/exception/program.py Thu Jan 12 23:50:26 2017 +0100 @@ -3,7 +3,7 @@ """ Program exception objects. -Copyright (C) 2015 Paul Boddie +Copyright (C) 2015, 2016, 2017 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -19,13 +19,13 @@ this program. If not, see . """ -class DeprecationWarning(Exception): pass -class FutureWarning(Warning): pass -class IndentationError(Exception): pass -class PendingDeprecationWarning(Warning): pass -class SyntaxError(Exception): pass -class SyntaxWarning(Warning): pass -class TabError(Exception): pass -class UserWarning(Warning): pass +class SyntaxError(Exception): + + "A general syntax error." + + pass + +class IndentationError(SyntaxError): pass +class TabError(SyntaxError): pass # vim: tabstop=4 expandtab shiftwidth=4 diff -r 0e7b5712a29b -r 41896438df61 lib/__builtins__/exception/system.py --- a/lib/__builtins__/exception/system.py Thu Jan 12 23:29:39 2017 +0100 +++ b/lib/__builtins__/exception/system.py Thu Jan 12 23:50:26 2017 +0100 @@ -3,7 +3,7 @@ """ System exception objects. -Copyright (C) 2015, 2016 Paul Boddie +Copyright (C) 2015, 2016, 2017 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -19,7 +19,11 @@ this program. If not, see . """ -class EnvironmentError(Exception): pass +class EnvironmentError(Exception): + + "The base class for external errors." + + pass class OSError(Exception): @@ -37,9 +41,11 @@ __repr__ = __str__ -class RuntimeError(Exception): pass -class RuntimeWarning(Warning): pass -class SystemError(Exception): pass +class SystemError(Exception): + + "A non-serious error occurring within the runtime system." + + pass class SystemExit(Exception): diff -r 0e7b5712a29b -r 41896438df61 lib/__builtins__/exception/unicode.py --- a/lib/__builtins__/exception/unicode.py Thu Jan 12 23:29:39 2017 +0100 +++ b/lib/__builtins__/exception/unicode.py Thu Jan 12 23:50:26 2017 +0100 @@ -3,7 +3,7 @@ """ Unicode exception objects. -Copyright (C) 2015, 2016 Paul Boddie +Copyright (C) 2015, 2016, 2017 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -19,7 +19,13 @@ this program. If not, see . """ -class UnicodeDecodeError(Exception): +class UnicodeError(ValueError): + + "A general Unicode error." + + pass + +class UnicodeDecodeError(UnicodeError): """ An exception indicating a failure to interpret a byte sequence according to @@ -35,9 +41,7 @@ self.value = value -class UnicodeEncodeError(Exception): pass -class UnicodeError(Exception): pass -class UnicodeTranslateError(Exception): pass -class UnicodeWarning(Warning): pass +class UnicodeEncodeError(UnicodeError): pass +class UnicodeTranslateError(UnicodeError): pass # vim: tabstop=4 expandtab shiftwidth=4