Repository: ipython/ipython

Issue:
prune unused names from parallel.error
<del>The error classes defined in parallel.error have no real reason to be defined separately from the core, and their presence elsewhere can cause shenanigans to be required if they are used in core, as in #2043.</del>


parallel.error is a leftover from the old kernel code, and should probably be aggressively pruned of unused exception classes <del>when they are merged into core.error</del>.



Discussion:
It strikes me that that's a fair chunk of code which is only really used by IPython.parallel. Bringing it into core just to customise the display of an exception seems like the wrong way to go about this.

I propose that we check for the existence of a particular method, like `render_traceback` (maybe the name should be more specific, to avoid collisions). If it exists, we use that to produce a traceback, rather than the usual structured_traceback helper. That way, other packages that need to do something similar can do it easily and Pythonically.

That sounds sensible.  What would be a good name?  The API is a list of lines fo the traceback.

Once we decide, I will retarget this issue as just pruning the many unused names from the old Twisted days.

How about `_render_traceback_`, like our `_repr_foo_` display names? I'll whip up a PR, we can discuss the name before merging it.

it will seem a bit silly to alias `_render_traceback_` to `render_traceback`, since that is a deliberately public API method, but that may make the most sense.

Should I close this, because we've decided not to merge parallel errors into core? Or leave it open to track the pruning of unused exception classes left from the old parallel code?

Issue updated to reflect the fact that it's just cleanup, not merge.


Resolving patch:
diff --git a/IPython/core/error.py b/IPython/core/error.py
--- a/IPython/core/error.py
+++ b/IPython/core/error.py
@@ -13,7 +13,7 @@
 """
 
 #-----------------------------------------------------------------------------
-#  Copyright (C) 2008-2011  The IPython Development Team
+#  Copyright (C) 2008 The IPython Development Team
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/parallel/error.py b/IPython/parallel/error.py
--- a/IPython/parallel/error.py
+++ b/IPython/parallel/error.py
@@ -40,125 +40,19 @@ class IPythonError(Exception):
 
     pass
 
-# Exceptions associated with the controller objects
-class ControllerError(IPythonError): pass
-
-class ControllerCreationError(ControllerError): pass
-
-
-# Exceptions associated with the Engines
-class EngineError(IPythonError): pass
-
-class EngineCreationError(EngineError): pass
-
 class KernelError(IPythonError):
     pass
 
-class NotDefined(KernelError):
-    def __init__(self, name):
-        self.name = name
-        self.args = (name,)
-
-    def __repr__(self):
-        return '<NotDefined: %s>' % self.name
-
-    __str__ = __repr__
-
-
-class QueueCleared(KernelError):
-    pass
-
-
-class IdInUse(KernelError):
-    pass
-
-
-class ProtocolError(KernelError):
-    pass
-
-
-class ConnectionError(KernelError):
-    pass
-
-
-class InvalidEngineID(KernelError):
-    pass
 
 
 class NoEnginesRegistered(KernelError):
     pass
 
 
-class InvalidClientID(KernelError):
-    pass
-
-
-class InvalidDeferredID(KernelError):
-    pass
-
-
-class SerializationError(KernelError):
-    pass
-
-
-class MessageSizeError(KernelError):
-    pass
-
-
-class PBMessageSizeError(MessageSizeError):
-    pass
-
-
-class ResultNotCompleted(KernelError):
-    pass
-
-
-class ResultAlreadyRetrieved(KernelError):
-    pass
-
-class ClientError(KernelError):
-    pass
-
-
 class TaskAborted(KernelError):
     pass
 
 
-class TaskTimeout(KernelError):
-    pass
-
-
-class NotAPendingResult(KernelError):
-    pass
-
-
-class UnpickleableException(KernelError):
-    pass
-
-
-class AbortedPendingDeferredError(KernelError):
-    pass
-
-
-class InvalidProperty(KernelError):
-    pass
-
-
-class MissingBlockArgument(KernelError):
-    pass
-
-
-class StopLocalExecution(KernelError):
-    pass
-
-
-class SecurityError(KernelError):
-    pass
-
-
-class FileTimeoutError(KernelError):
-    pass
-
 class TimeoutError(KernelError):
     pass
 


Test patch: