The future of Python: fixing broken error handling in Python 8

Python's exception handling system is currently badly brokeTypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'n. Therefore, with the recent news of the joyous release of Python 8 ( https://mail.python.org/pipermail/python-dev/2016-March/143603.html), I have decided to propose a revolutionary idea: safe mock objects. A "safe" mock object (qualified name `_frozensafemockobjectimplementation.SafeMockObjectThatIsIncludedWithPython8`; Java-style naming was adopted for readability purposes; comments are now no longer necessary) is a magic object that supports everything and returns itself. Since examples speak more words than are in the Python source code, here are some (examples, not words in the Python source code): a = 1 b = None c = a + b # Returns a _frozensafemockobjectimplementation.SafeMockObjectThatIsIncludedWithPython8 print(c) # Prints the empty string. d = c+1 # All operations on `_frozensafemockobjectimplementation.SafeMockObjectThatIsIncludedWithPython8`'s return a new one. e = d.xyz(1, 2, 3) # `e` is now a `_frozensafemockobjectimplementation.SafeMockObjectThatIsIncludedWithPython8`. def f(): assert 0 # Causes the function to return a `_frozensafemockobjectimplementation.SafeMockObjectThatIsIncludedWithPython8`. raise 123 # Does the same thing. print(L) # L is undefined, so it becomes a `_frozensafemockobjectimplementation.SafeMockObjectThatIsIncludedWithPython8`. Safe mock objects are obviously the Next Error Handling Revolution ™. Unicode errors now simply disappear and return more `_frozensafemockobjectimplementation.SafeMockObjectThatIsIncludedWithPython8`s. As for `try` and `catch` (protest the naming of `except`!!) statements, they will be completely ignored. The `try`, `except`, and `finally` bodies will all be executed in sequence, except that printing and returning values with an `except` statement does nothing: try: xyz = None.a # `xyz` becomes a `_frozensafemockobjectimplementation.SafeMockObjectThatIsIncludedWithPython8`. except: print(123) # Does nothing. return None # Does nothing. finally: return xyz # Returns a `_frozensafemockobjectimplementation.SafeMockObjectThatIsIncludedWithPython8`. Aggressive error handling (as shown in PanicSort [https://xkcd.com/1185/]) that does destructive actions (such as `rm -rf /`) will always execute the destructive code, encouraging more honest development. In addition, due to errors simply being ignored, nothing can ever quite go wrong. All discussions about a safe navigation operator can now be immediately halted, since any undefined attributes will simply return a `_frozensafemockobjectimplementation.SafeMockObjectThatIsIncludedWithPython8`. Although I have not yet destroy--I mean, improved CPython to allow for this amazing idea, I have created a primitive implementation of the `_frozensafemockobjectimplementation` module: https://github.com/kirbyfan64/_frozensafemockobjectimplementation I hope you will all realize that this new idea is a drastic improvement over current technologies and therefore support it, because we can Make Python Great Again™. -- Ryan [ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong. http://kirbyfan64.github.io/

On Sat, Apr 2, 2016 at 1:19 AM, Ryan Gonzalez <rymg19@gmail.com> wrote:
Finally. It's about time. For some reason, technology deals with the hard problems but not the easy ones. I mean, we put a man on the moon, but we can't cure the common cold OR cancer. We make aeroplanes that fly us around the world any time we like, but can't get through airport security in less than an hour. And we design programming languages that eliminate memory allocation problems, but can't make it so bytes and text magically work together. At last, a language that lets me express myself in code without having to think about any languages other than my own parochial subset of English. ChrisA

On Sat, Apr 2, 2016 at 1:19 AM, Ryan Gonzalez <rymg19@gmail.com> wrote:
Finally. It's about time. For some reason, technology deals with the hard problems but not the easy ones. I mean, we put a man on the moon, but we can't cure the common cold OR cancer. We make aeroplanes that fly us around the world any time we like, but can't get through airport security in less than an hour. And we design programming languages that eliminate memory allocation problems, but can't make it so bytes and text magically work together. At last, a language that lets me express myself in code without having to think about any languages other than my own parochial subset of English. ChrisA
participants (2)
-
Chris Angelico
-
Ryan Gonzalez