We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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>.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `IPython/core/error.py`
Content:
```
1 # encoding: utf-8
2 """
3 Global exception classes for IPython.core.
4 
5 Authors:
6 
7 * Brian Granger
8 * Fernando Perez
9 * Min Ragan-Kelley
10 
11 Notes
12 -----
13 """
14 
15 #-----------------------------------------------------------------------------
16 #  Copyright (C) 2008-2011  The IPython Development Team
17 #
18 #  Distributed under the terms of the BSD License.  The full license is in
19 #  the file COPYING, distributed as part of this software.
20 #-----------------------------------------------------------------------------
21 
22 #-----------------------------------------------------------------------------
23 # Imports
24 #-----------------------------------------------------------------------------
25 
26 #-----------------------------------------------------------------------------
27 # Exception classes
28 #-----------------------------------------------------------------------------
29 
30 class IPythonCoreError(Exception):
31     pass
32 
33 
34 class TryNext(IPythonCoreError):
35     """Try next hook exception.
36 
37     Raise this in your hook function to indicate that the next hook handler
38     should be used to handle the operation.
39     """
40 
41 class UsageError(IPythonCoreError):
42     """Error in magic function arguments, etc.
43 
44     Something that probably won't warrant a full traceback, but should
45     nevertheless interrupt a macro / batch file.
46     """
47 
48 class StdinNotImplementedError(IPythonCoreError, NotImplementedError):
49     """raw_input was requested in a context where it is not supported
50 
51     For use in IPython kernels, where only some frontends may support
52     stdin requests.
53     """
54
```

Path: `IPython/parallel/error.py`
Content:
```
1 # encoding: utf-8
2 
3 """Classes and functions for kernel related errors and exceptions.
4 
5 Inheritance diagram:
6 
7 .. inheritance-diagram:: IPython.parallel.error
8    :parts: 3
9 
10 Authors:
11 
12 * Brian Granger
13 * Min RK
14 """
15 from __future__ import print_function
16 
17 import sys
18 import traceback
19 
20 __docformat__ = "restructuredtext en"
21 
22 # Tell nose to skip this module
23 __test__ = {}
24 
25 #-------------------------------------------------------------------------------
26 #  Copyright (C) 2008-2011  The IPython Development Team
27 #
28 #  Distributed under the terms of the BSD License.  The full license is in
29 #  the file COPYING, distributed as part of this software.
30 #-------------------------------------------------------------------------------
31 
32 #-------------------------------------------------------------------------------
33 # Error classes
34 #-------------------------------------------------------------------------------
35 class IPythonError(Exception):
36     """Base exception that all of our exceptions inherit from.
37 
38     This can be raised by code that doesn't have any more specific
39     information."""
40 
41     pass
42 
43 # Exceptions associated with the controller objects
44 class ControllerError(IPythonError): pass
45 
46 class ControllerCreationError(ControllerError): pass
47 
48 
49 # Exceptions associated with the Engines
50 class EngineError(IPythonError): pass
51 
52 class EngineCreationError(EngineError): pass
53 
54 class KernelError(IPythonError):
55     pass
56 
57 class NotDefined(KernelError):
58     def __init__(self, name):
59         self.name = name
60         self.args = (name,)
61 
62     def __repr__(self):
63         return '<NotDefined: %s>' % self.name
64 
65     __str__ = __repr__
66 
67 
68 class QueueCleared(KernelError):
69     pass
70 
71 
72 class IdInUse(KernelError):
73     pass
74 
75 
76 class ProtocolError(KernelError):
77     pass
78 
79 
80 class ConnectionError(KernelError):
81     pass
82 
83 
84 class InvalidEngineID(KernelError):
85     pass
86 
87 
88 class NoEnginesRegistered(KernelError):
89     pass
90 
91 
92 class InvalidClientID(KernelError):
93     pass
94 
95 
96 class InvalidDeferredID(KernelError):
97     pass
98 
99 
100 class SerializationError(KernelError):
101     pass
102 
103 
104 class MessageSizeError(KernelError):
105     pass
106 
107 
108 class PBMessageSizeError(MessageSizeError):
109     pass
110 
111 
112 class ResultNotCompleted(KernelError):
113     pass
114 
115 
116 class ResultAlreadyRetrieved(KernelError):
117     pass
118 
119 class ClientError(KernelError):
120     pass
121 
122 
123 class TaskAborted(KernelError):
124     pass
125 
126 
127 class TaskTimeout(KernelError):
128     pass
129 
130 
131 class NotAPendingResult(KernelError):
132     pass
133 
134 
135 class UnpickleableException(KernelError):
136     pass
137 
138 
139 class AbortedPendingDeferredError(KernelError):
140     pass
141 
142 
143 class InvalidProperty(KernelError):
144     pass
145 
146 
147 class MissingBlockArgument(KernelError):
148     pass
149 
150 
151 class StopLocalExecution(KernelError):
152     pass
153 
154 
155 class SecurityError(KernelError):
156     pass
157 
158 
159 class FileTimeoutError(KernelError):
160     pass
161 
162 class TimeoutError(KernelError):
163     pass
164 
165 class UnmetDependency(KernelError):
166     pass
167 
168 class ImpossibleDependency(UnmetDependency):
169     pass
170 
171 class DependencyTimeout(ImpossibleDependency):
172     pass
173 
174 class InvalidDependency(ImpossibleDependency):
175     pass
176 
177 class RemoteError(KernelError):
178     """Error raised elsewhere"""
179     ename=None
180     evalue=None
181     traceback=None
182     engine_info=None
183 
184     def __init__(self, ename, evalue, traceback, engine_info=None):
185         self.ename=ename
186         self.evalue=evalue
187         self.traceback=traceback
188         self.engine_info=engine_info or {}
189         self.args=(ename, evalue)
190 
191     def __repr__(self):
192         engineid = self.engine_info.get('engine_id', ' ')
193         return "<Remote[%s]:%s(%s)>"%(engineid, self.ename, self.evalue)
194 
195     def __str__(self):
196         return "%s(%s)" % (self.ename, self.evalue)
197     
198     def render_traceback(self):
199         """render traceback to a list of lines"""
200         return (self.traceback or "No traceback available").splitlines()
201     
202     def _render_traceback_(self):
203         """Special method for custom tracebacks within IPython.
204         
205         This will be called by IPython instead of displaying the local traceback.
206         
207         It should return a traceback rendered as a list of lines.
208         """
209         return self.render_traceback()
210     
211     def print_traceback(self, excid=None):
212         """print my traceback"""
213         print('\n'.join(self.render_traceback()))
214 
215     
216 
217 
218 class TaskRejectError(KernelError):
219     """Exception to raise when a task should be rejected by an engine.
220 
221     This exception can be used to allow a task running on an engine to test
222     if the engine (or the user's namespace on the engine) has the needed
223     task dependencies.  If not, the task should raise this exception.  For
224     the task to be retried on another engine, the task should be created
225     with the `retries` argument > 1.
226 
227     The advantage of this approach over our older properties system is that
228     tasks have full access to the user's namespace on the engines and the
229     properties don't have to be managed or tested by the controller.
230     """
231 
232 
233 class CompositeError(RemoteError):
234     """Error for representing possibly multiple errors on engines"""
235     tb_limit = 4 # limit on how many tracebacks to draw
236     
237     def __init__(self, message, elist):
238         Exception.__init__(self, *(message, elist))
239         # Don't use pack_exception because it will conflict with the .message
240         # attribute that is being deprecated in 2.6 and beyond.
241         self.msg = message
242         self.elist = elist
243         self.args = [ e[0] for e in elist ]
244 
245     def _get_engine_str(self, ei):
246         if not ei:
247             return '[Engine Exception]'
248         else:
249             return '[%s:%s]: ' % (ei['engine_id'], ei['method'])
250 
251     def _get_traceback(self, ev):
252         try:
253             tb = ev._ipython_traceback_text
254         except AttributeError:
255             return 'No traceback available'
256         else:
257             return tb
258 
259     def __str__(self):
260         s = str(self.msg)
261         for en, ev, etb, ei in self.elist[:self.tb_limit]:
262             engine_str = self._get_engine_str(ei)
263             s = s + '\n' + engine_str + en + ': ' + str(ev)
264         if len(self.elist) > self.tb_limit:
265             s = s + '\n.... %i more exceptions ...' % (len(self.elist) - self.tb_limit)
266         return s
267 
268     def __repr__(self):
269         return "CompositeError(%i)" % len(self.elist)
270     
271     def render_traceback(self, excid=None):
272         """render one or all of my tracebacks to a list of lines"""
273         lines = []
274         if excid is None:
275             for (en,ev,etb,ei) in self.elist[:self.tb_limit]:
276                 lines.append(self._get_engine_str(ei))
277                 lines.extend((etb or 'No traceback available').splitlines())
278                 lines.append('')
279             if len(self.elist) > self.tb_limit:
280                 lines.append(
281                     '... %i more exceptions ...' % (len(self.elist) - self.tb_limit)
282                 )
283         else:
284             try:
285                 en,ev,etb,ei = self.elist[excid]
286             except:
287                 raise IndexError("an exception with index %i does not exist"%excid)
288             else:
289                 lines.append(self._get_engine_str(ei))
290                 lines.extend((etb or 'No traceback available').splitlines())
291         
292         return lines
293     
294     def print_traceback(self, excid=None):
295         print('\n'.join(self.render_traceback(excid)))
296 
297     def raise_exception(self, excid=0):
298         try:
299             en,ev,etb,ei = self.elist[excid]
300         except:
301             raise IndexError("an exception with index %i does not exist"%excid)
302         else:
303             raise RemoteError(en, ev, etb, ei)
304 
305 
306 def collect_exceptions(rdict_or_list, method='unspecified'):
307     """check a result dict for errors, and raise CompositeError if any exist.
308     Passthrough otherwise."""
309     elist = []
310     if isinstance(rdict_or_list, dict):
311         rlist = rdict_or_list.values()
312     else:
313         rlist = rdict_or_list
314     for r in rlist:
315         if isinstance(r, RemoteError):
316             en, ev, etb, ei = r.ename, r.evalue, r.traceback, r.engine_info
317             # Sometimes we could have CompositeError in our list.  Just take
318             # the errors out of them and put them in our new list.  This
319             # has the effect of flattening lists of CompositeErrors into one
320             # CompositeError
321             if en=='CompositeError':
322                 for e in ev.elist:
323                     elist.append(e)
324             else:
325                 elist.append((en, ev, etb, ei))
326     if len(elist)==0:
327         return rdict_or_list
328     else:
329         msg = "one or more exceptions from call to method: %s" % (method)
330         # This silliness is needed so the debugger has access to the exception
331         # instance (e in this case)
332         try:
333             raise CompositeError(msg, elist)
334         except CompositeError as e:
335             raise e
336 
337 def wrap_exception(engine_info={}):
338     etype, evalue, tb = sys.exc_info()
339     stb = traceback.format_exception(etype, evalue, tb)
340     exc_content = {
341         'status' : 'error',
342         'traceback' : stb,
343         'ename' : unicode(etype.__name__),
344         'evalue' : unicode(evalue),
345         'engine_info' : engine_info
346     }
347     return exc_content
348 
349 def unwrap_exception(content):
350     err = RemoteError(content['ename'], content['evalue'],
351                 ''.join(content['traceback']),
352                 content.get('engine_info', {}))
353     return err
354 
355
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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 @@
 
     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

{"golden_diff": "diff --git a/IPython/core/error.py b/IPython/core/error.py\n--- a/IPython/core/error.py\n+++ b/IPython/core/error.py\n@@ -13,7 +13,7 @@\n \"\"\"\n \n #-----------------------------------------------------------------------------\n-#  Copyright (C) 2008-2011  The IPython Development Team\n+#  Copyright (C) 2008 The IPython Development Team\n #\n #  Distributed under the terms of the BSD License.  The full license is in\n #  the file COPYING, distributed as part of this software.\ndiff --git a/IPython/parallel/error.py b/IPython/parallel/error.py\n--- a/IPython/parallel/error.py\n+++ b/IPython/parallel/error.py\n@@ -40,125 +40,19 @@\n \n     pass\n \n-# Exceptions associated with the controller objects\n-class ControllerError(IPythonError): pass\n-\n-class ControllerCreationError(ControllerError): pass\n-\n-\n-# Exceptions associated with the Engines\n-class EngineError(IPythonError): pass\n-\n-class EngineCreationError(EngineError): pass\n-\n class KernelError(IPythonError):\n     pass\n \n-class NotDefined(KernelError):\n-    def __init__(self, name):\n-        self.name = name\n-        self.args = (name,)\n-\n-    def __repr__(self):\n-        return '<NotDefined: %s>' % self.name\n-\n-    __str__ = __repr__\n-\n-\n-class QueueCleared(KernelError):\n-    pass\n-\n-\n-class IdInUse(KernelError):\n-    pass\n-\n-\n-class ProtocolError(KernelError):\n-    pass\n-\n-\n-class ConnectionError(KernelError):\n-    pass\n-\n-\n-class InvalidEngineID(KernelError):\n-    pass\n \n \n class NoEnginesRegistered(KernelError):\n     pass\n \n \n-class InvalidClientID(KernelError):\n-    pass\n-\n-\n-class InvalidDeferredID(KernelError):\n-    pass\n-\n-\n-class SerializationError(KernelError):\n-    pass\n-\n-\n-class MessageSizeError(KernelError):\n-    pass\n-\n-\n-class PBMessageSizeError(MessageSizeError):\n-    pass\n-\n-\n-class ResultNotCompleted(KernelError):\n-    pass\n-\n-\n-class ResultAlreadyRetrieved(KernelError):\n-    pass\n-\n-class ClientError(KernelError):\n-    pass\n-\n-\n class TaskAborted(KernelError):\n     pass\n \n \n-class TaskTimeout(KernelError):\n-    pass\n-\n-\n-class NotAPendingResult(KernelError):\n-    pass\n-\n-\n-class UnpickleableException(KernelError):\n-    pass\n-\n-\n-class AbortedPendingDeferredError(KernelError):\n-    pass\n-\n-\n-class InvalidProperty(KernelError):\n-    pass\n-\n-\n-class MissingBlockArgument(KernelError):\n-    pass\n-\n-\n-class StopLocalExecution(KernelError):\n-    pass\n-\n-\n-class SecurityError(KernelError):\n-    pass\n-\n-\n-class FileTimeoutError(KernelError):\n-    pass\n-\n class TimeoutError(KernelError):\n     pass\n", "issue": "prune unused names from parallel.error\n<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>\n\n\nparallel.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>.\n\n", "before_files": [{"content": "# encoding: utf-8\n\"\"\"\nGlobal exception classes for IPython.core.\n\nAuthors:\n\n* Brian Granger\n* Fernando Perez\n* Min Ragan-Kelley\n\nNotes\n-----\n\"\"\"\n\n#-----------------------------------------------------------------------------\n#  Copyright (C) 2008-2011  The IPython Development Team\n#\n#  Distributed under the terms of the BSD License.  The full license is in\n#  the file COPYING, distributed as part of this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Exception classes\n#-----------------------------------------------------------------------------\n\nclass IPythonCoreError(Exception):\n    pass\n\n\nclass TryNext(IPythonCoreError):\n    \"\"\"Try next hook exception.\n\n    Raise this in your hook function to indicate that the next hook handler\n    should be used to handle the operation.\n    \"\"\"\n\nclass UsageError(IPythonCoreError):\n    \"\"\"Error in magic function arguments, etc.\n\n    Something that probably won't warrant a full traceback, but should\n    nevertheless interrupt a macro / batch file.\n    \"\"\"\n\nclass StdinNotImplementedError(IPythonCoreError, NotImplementedError):\n    \"\"\"raw_input was requested in a context where it is not supported\n\n    For use in IPython kernels, where only some frontends may support\n    stdin requests.\n    \"\"\"\n", "path": "IPython/core/error.py"}, {"content": "# encoding: utf-8\n\n\"\"\"Classes and functions for kernel related errors and exceptions.\n\nInheritance diagram:\n\n.. inheritance-diagram:: IPython.parallel.error\n   :parts: 3\n\nAuthors:\n\n* Brian Granger\n* Min RK\n\"\"\"\nfrom __future__ import print_function\n\nimport sys\nimport traceback\n\n__docformat__ = \"restructuredtext en\"\n\n# Tell nose to skip this module\n__test__ = {}\n\n#-------------------------------------------------------------------------------\n#  Copyright (C) 2008-2011  The IPython Development Team\n#\n#  Distributed under the terms of the BSD License.  The full license is in\n#  the file COPYING, distributed as part of this software.\n#-------------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------------\n# Error classes\n#-------------------------------------------------------------------------------\nclass IPythonError(Exception):\n    \"\"\"Base exception that all of our exceptions inherit from.\n\n    This can be raised by code that doesn't have any more specific\n    information.\"\"\"\n\n    pass\n\n# Exceptions associated with the controller objects\nclass ControllerError(IPythonError): pass\n\nclass ControllerCreationError(ControllerError): pass\n\n\n# Exceptions associated with the Engines\nclass EngineError(IPythonError): pass\n\nclass EngineCreationError(EngineError): pass\n\nclass KernelError(IPythonError):\n    pass\n\nclass NotDefined(KernelError):\n    def __init__(self, name):\n        self.name = name\n        self.args = (name,)\n\n    def __repr__(self):\n        return '<NotDefined: %s>' % self.name\n\n    __str__ = __repr__\n\n\nclass QueueCleared(KernelError):\n    pass\n\n\nclass IdInUse(KernelError):\n    pass\n\n\nclass ProtocolError(KernelError):\n    pass\n\n\nclass ConnectionError(KernelError):\n    pass\n\n\nclass InvalidEngineID(KernelError):\n    pass\n\n\nclass NoEnginesRegistered(KernelError):\n    pass\n\n\nclass InvalidClientID(KernelError):\n    pass\n\n\nclass InvalidDeferredID(KernelError):\n    pass\n\n\nclass SerializationError(KernelError):\n    pass\n\n\nclass MessageSizeError(KernelError):\n    pass\n\n\nclass PBMessageSizeError(MessageSizeError):\n    pass\n\n\nclass ResultNotCompleted(KernelError):\n    pass\n\n\nclass ResultAlreadyRetrieved(KernelError):\n    pass\n\nclass ClientError(KernelError):\n    pass\n\n\nclass TaskAborted(KernelError):\n    pass\n\n\nclass TaskTimeout(KernelError):\n    pass\n\n\nclass NotAPendingResult(KernelError):\n    pass\n\n\nclass UnpickleableException(KernelError):\n    pass\n\n\nclass AbortedPendingDeferredError(KernelError):\n    pass\n\n\nclass InvalidProperty(KernelError):\n    pass\n\n\nclass MissingBlockArgument(KernelError):\n    pass\n\n\nclass StopLocalExecution(KernelError):\n    pass\n\n\nclass SecurityError(KernelError):\n    pass\n\n\nclass FileTimeoutError(KernelError):\n    pass\n\nclass TimeoutError(KernelError):\n    pass\n\nclass UnmetDependency(KernelError):\n    pass\n\nclass ImpossibleDependency(UnmetDependency):\n    pass\n\nclass DependencyTimeout(ImpossibleDependency):\n    pass\n\nclass InvalidDependency(ImpossibleDependency):\n    pass\n\nclass RemoteError(KernelError):\n    \"\"\"Error raised elsewhere\"\"\"\n    ename=None\n    evalue=None\n    traceback=None\n    engine_info=None\n\n    def __init__(self, ename, evalue, traceback, engine_info=None):\n        self.ename=ename\n        self.evalue=evalue\n        self.traceback=traceback\n        self.engine_info=engine_info or {}\n        self.args=(ename, evalue)\n\n    def __repr__(self):\n        engineid = self.engine_info.get('engine_id', ' ')\n        return \"<Remote[%s]:%s(%s)>\"%(engineid, self.ename, self.evalue)\n\n    def __str__(self):\n        return \"%s(%s)\" % (self.ename, self.evalue)\n    \n    def render_traceback(self):\n        \"\"\"render traceback to a list of lines\"\"\"\n        return (self.traceback or \"No traceback available\").splitlines()\n    \n    def _render_traceback_(self):\n        \"\"\"Special method for custom tracebacks within IPython.\n        \n        This will be called by IPython instead of displaying the local traceback.\n        \n        It should return a traceback rendered as a list of lines.\n        \"\"\"\n        return self.render_traceback()\n    \n    def print_traceback(self, excid=None):\n        \"\"\"print my traceback\"\"\"\n        print('\\n'.join(self.render_traceback()))\n\n    \n\n\nclass TaskRejectError(KernelError):\n    \"\"\"Exception to raise when a task should be rejected by an engine.\n\n    This exception can be used to allow a task running on an engine to test\n    if the engine (or the user's namespace on the engine) has the needed\n    task dependencies.  If not, the task should raise this exception.  For\n    the task to be retried on another engine, the task should be created\n    with the `retries` argument > 1.\n\n    The advantage of this approach over our older properties system is that\n    tasks have full access to the user's namespace on the engines and the\n    properties don't have to be managed or tested by the controller.\n    \"\"\"\n\n\nclass CompositeError(RemoteError):\n    \"\"\"Error for representing possibly multiple errors on engines\"\"\"\n    tb_limit = 4 # limit on how many tracebacks to draw\n    \n    def __init__(self, message, elist):\n        Exception.__init__(self, *(message, elist))\n        # Don't use pack_exception because it will conflict with the .message\n        # attribute that is being deprecated in 2.6 and beyond.\n        self.msg = message\n        self.elist = elist\n        self.args = [ e[0] for e in elist ]\n\n    def _get_engine_str(self, ei):\n        if not ei:\n            return '[Engine Exception]'\n        else:\n            return '[%s:%s]: ' % (ei['engine_id'], ei['method'])\n\n    def _get_traceback(self, ev):\n        try:\n            tb = ev._ipython_traceback_text\n        except AttributeError:\n            return 'No traceback available'\n        else:\n            return tb\n\n    def __str__(self):\n        s = str(self.msg)\n        for en, ev, etb, ei in self.elist[:self.tb_limit]:\n            engine_str = self._get_engine_str(ei)\n            s = s + '\\n' + engine_str + en + ': ' + str(ev)\n        if len(self.elist) > self.tb_limit:\n            s = s + '\\n.... %i more exceptions ...' % (len(self.elist) - self.tb_limit)\n        return s\n\n    def __repr__(self):\n        return \"CompositeError(%i)\" % len(self.elist)\n    \n    def render_traceback(self, excid=None):\n        \"\"\"render one or all of my tracebacks to a list of lines\"\"\"\n        lines = []\n        if excid is None:\n            for (en,ev,etb,ei) in self.elist[:self.tb_limit]:\n                lines.append(self._get_engine_str(ei))\n                lines.extend((etb or 'No traceback available').splitlines())\n                lines.append('')\n            if len(self.elist) > self.tb_limit:\n                lines.append(\n                    '... %i more exceptions ...' % (len(self.elist) - self.tb_limit)\n                )\n        else:\n            try:\n                en,ev,etb,ei = self.elist[excid]\n            except:\n                raise IndexError(\"an exception with index %i does not exist\"%excid)\n            else:\n                lines.append(self._get_engine_str(ei))\n                lines.extend((etb or 'No traceback available').splitlines())\n        \n        return lines\n    \n    def print_traceback(self, excid=None):\n        print('\\n'.join(self.render_traceback(excid)))\n\n    def raise_exception(self, excid=0):\n        try:\n            en,ev,etb,ei = self.elist[excid]\n        except:\n            raise IndexError(\"an exception with index %i does not exist\"%excid)\n        else:\n            raise RemoteError(en, ev, etb, ei)\n\n\ndef collect_exceptions(rdict_or_list, method='unspecified'):\n    \"\"\"check a result dict for errors, and raise CompositeError if any exist.\n    Passthrough otherwise.\"\"\"\n    elist = []\n    if isinstance(rdict_or_list, dict):\n        rlist = rdict_or_list.values()\n    else:\n        rlist = rdict_or_list\n    for r in rlist:\n        if isinstance(r, RemoteError):\n            en, ev, etb, ei = r.ename, r.evalue, r.traceback, r.engine_info\n            # Sometimes we could have CompositeError in our list.  Just take\n            # the errors out of them and put them in our new list.  This\n            # has the effect of flattening lists of CompositeErrors into one\n            # CompositeError\n            if en=='CompositeError':\n                for e in ev.elist:\n                    elist.append(e)\n            else:\n                elist.append((en, ev, etb, ei))\n    if len(elist)==0:\n        return rdict_or_list\n    else:\n        msg = \"one or more exceptions from call to method: %s\" % (method)\n        # This silliness is needed so the debugger has access to the exception\n        # instance (e in this case)\n        try:\n            raise CompositeError(msg, elist)\n        except CompositeError as e:\n            raise e\n\ndef wrap_exception(engine_info={}):\n    etype, evalue, tb = sys.exc_info()\n    stb = traceback.format_exception(etype, evalue, tb)\n    exc_content = {\n        'status' : 'error',\n        'traceback' : stb,\n        'ename' : unicode(etype.__name__),\n        'evalue' : unicode(evalue),\n        'engine_info' : engine_info\n    }\n    return exc_content\n\ndef unwrap_exception(content):\n    err = RemoteError(content['ename'], content['evalue'],\n                ''.join(content['traceback']),\n                content.get('engine_info', {}))\n    return err\n\n", "path": "IPython/parallel/error.py"}], "after_files": [{"content": "# encoding: utf-8\n\"\"\"\nGlobal exception classes for IPython.core.\n\nAuthors:\n\n* Brian Granger\n* Fernando Perez\n* Min Ragan-Kelley\n\nNotes\n-----\n\"\"\"\n\n#-----------------------------------------------------------------------------\n#  Copyright (C) 2008 The IPython Development Team\n#\n#  Distributed under the terms of the BSD License.  The full license is in\n#  the file COPYING, distributed as part of this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Exception classes\n#-----------------------------------------------------------------------------\n\nclass IPythonCoreError(Exception):\n    pass\n\n\nclass TryNext(IPythonCoreError):\n    \"\"\"Try next hook exception.\n\n    Raise this in your hook function to indicate that the next hook handler\n    should be used to handle the operation.\n    \"\"\"\n\nclass UsageError(IPythonCoreError):\n    \"\"\"Error in magic function arguments, etc.\n\n    Something that probably won't warrant a full traceback, but should\n    nevertheless interrupt a macro / batch file.\n    \"\"\"\n\nclass StdinNotImplementedError(IPythonCoreError, NotImplementedError):\n    \"\"\"raw_input was requested in a context where it is not supported\n\n    For use in IPython kernels, where only some frontends may support\n    stdin requests.\n    \"\"\"\n", "path": "IPython/core/error.py"}, {"content": "# encoding: utf-8\n\n\"\"\"Classes and functions for kernel related errors and exceptions.\n\nInheritance diagram:\n\n.. inheritance-diagram:: IPython.parallel.error\n   :parts: 3\n\nAuthors:\n\n* Brian Granger\n* Min RK\n\"\"\"\nfrom __future__ import print_function\n\nimport sys\nimport traceback\n\n__docformat__ = \"restructuredtext en\"\n\n# Tell nose to skip this module\n__test__ = {}\n\n#-------------------------------------------------------------------------------\n#  Copyright (C) 2008-2011  The IPython Development Team\n#\n#  Distributed under the terms of the BSD License.  The full license is in\n#  the file COPYING, distributed as part of this software.\n#-------------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------------\n# Error classes\n#-------------------------------------------------------------------------------\nclass IPythonError(Exception):\n    \"\"\"Base exception that all of our exceptions inherit from.\n\n    This can be raised by code that doesn't have any more specific\n    information.\"\"\"\n\n    pass\n\nclass KernelError(IPythonError):\n    pass\n\n\n\nclass NoEnginesRegistered(KernelError):\n    pass\n\n\nclass TaskAborted(KernelError):\n    pass\n\n\nclass TimeoutError(KernelError):\n    pass\n\nclass UnmetDependency(KernelError):\n    pass\n\nclass ImpossibleDependency(UnmetDependency):\n    pass\n\nclass DependencyTimeout(ImpossibleDependency):\n    pass\n\nclass InvalidDependency(ImpossibleDependency):\n    pass\n\nclass RemoteError(KernelError):\n    \"\"\"Error raised elsewhere\"\"\"\n    ename=None\n    evalue=None\n    traceback=None\n    engine_info=None\n\n    def __init__(self, ename, evalue, traceback, engine_info=None):\n        self.ename=ename\n        self.evalue=evalue\n        self.traceback=traceback\n        self.engine_info=engine_info or {}\n        self.args=(ename, evalue)\n\n    def __repr__(self):\n        engineid = self.engine_info.get('engine_id', ' ')\n        return \"<Remote[%s]:%s(%s)>\"%(engineid, self.ename, self.evalue)\n\n    def __str__(self):\n        return \"%s(%s)\" % (self.ename, self.evalue)\n    \n    def render_traceback(self):\n        \"\"\"render traceback to a list of lines\"\"\"\n        return (self.traceback or \"No traceback available\").splitlines()\n    \n    def _render_traceback_(self):\n        \"\"\"Special method for custom tracebacks within IPython.\n        \n        This will be called by IPython instead of displaying the local traceback.\n        \n        It should return a traceback rendered as a list of lines.\n        \"\"\"\n        return self.render_traceback()\n    \n    def print_traceback(self, excid=None):\n        \"\"\"print my traceback\"\"\"\n        print('\\n'.join(self.render_traceback()))\n\n    \n\n\nclass TaskRejectError(KernelError):\n    \"\"\"Exception to raise when a task should be rejected by an engine.\n\n    This exception can be used to allow a task running on an engine to test\n    if the engine (or the user's namespace on the engine) has the needed\n    task dependencies.  If not, the task should raise this exception.  For\n    the task to be retried on another engine, the task should be created\n    with the `retries` argument > 1.\n\n    The advantage of this approach over our older properties system is that\n    tasks have full access to the user's namespace on the engines and the\n    properties don't have to be managed or tested by the controller.\n    \"\"\"\n\n\nclass CompositeError(RemoteError):\n    \"\"\"Error for representing possibly multiple errors on engines\"\"\"\n    tb_limit = 4 # limit on how many tracebacks to draw\n    \n    def __init__(self, message, elist):\n        Exception.__init__(self, *(message, elist))\n        # Don't use pack_exception because it will conflict with the .message\n        # attribute that is being deprecated in 2.6 and beyond.\n        self.msg = message\n        self.elist = elist\n        self.args = [ e[0] for e in elist ]\n\n    def _get_engine_str(self, ei):\n        if not ei:\n            return '[Engine Exception]'\n        else:\n            return '[%s:%s]: ' % (ei['engine_id'], ei['method'])\n\n    def _get_traceback(self, ev):\n        try:\n            tb = ev._ipython_traceback_text\n        except AttributeError:\n            return 'No traceback available'\n        else:\n            return tb\n\n    def __str__(self):\n        s = str(self.msg)\n        for en, ev, etb, ei in self.elist[:self.tb_limit]:\n            engine_str = self._get_engine_str(ei)\n            s = s + '\\n' + engine_str + en + ': ' + str(ev)\n        if len(self.elist) > self.tb_limit:\n            s = s + '\\n.... %i more exceptions ...' % (len(self.elist) - self.tb_limit)\n        return s\n\n    def __repr__(self):\n        return \"CompositeError(%i)\" % len(self.elist)\n    \n    def render_traceback(self, excid=None):\n        \"\"\"render one or all of my tracebacks to a list of lines\"\"\"\n        lines = []\n        if excid is None:\n            for (en,ev,etb,ei) in self.elist[:self.tb_limit]:\n                lines.append(self._get_engine_str(ei))\n                lines.extend((etb or 'No traceback available').splitlines())\n                lines.append('')\n            if len(self.elist) > self.tb_limit:\n                lines.append(\n                    '... %i more exceptions ...' % (len(self.elist) - self.tb_limit)\n                )\n        else:\n            try:\n                en,ev,etb,ei = self.elist[excid]\n            except:\n                raise IndexError(\"an exception with index %i does not exist\"%excid)\n            else:\n                lines.append(self._get_engine_str(ei))\n                lines.extend((etb or 'No traceback available').splitlines())\n        \n        return lines\n    \n    def print_traceback(self, excid=None):\n        print('\\n'.join(self.render_traceback(excid)))\n\n    def raise_exception(self, excid=0):\n        try:\n            en,ev,etb,ei = self.elist[excid]\n        except:\n            raise IndexError(\"an exception with index %i does not exist\"%excid)\n        else:\n            raise RemoteError(en, ev, etb, ei)\n\n\ndef collect_exceptions(rdict_or_list, method='unspecified'):\n    \"\"\"check a result dict for errors, and raise CompositeError if any exist.\n    Passthrough otherwise.\"\"\"\n    elist = []\n    if isinstance(rdict_or_list, dict):\n        rlist = rdict_or_list.values()\n    else:\n        rlist = rdict_or_list\n    for r in rlist:\n        if isinstance(r, RemoteError):\n            en, ev, etb, ei = r.ename, r.evalue, r.traceback, r.engine_info\n            # Sometimes we could have CompositeError in our list.  Just take\n            # the errors out of them and put them in our new list.  This\n            # has the effect of flattening lists of CompositeErrors into one\n            # CompositeError\n            if en=='CompositeError':\n                for e in ev.elist:\n                    elist.append(e)\n            else:\n                elist.append((en, ev, etb, ei))\n    if len(elist)==0:\n        return rdict_or_list\n    else:\n        msg = \"one or more exceptions from call to method: %s\" % (method)\n        # This silliness is needed so the debugger has access to the exception\n        # instance (e in this case)\n        try:\n            raise CompositeError(msg, elist)\n        except CompositeError as e:\n            raise e\n\ndef wrap_exception(engine_info={}):\n    etype, evalue, tb = sys.exc_info()\n    stb = traceback.format_exception(etype, evalue, tb)\n    exc_content = {\n        'status' : 'error',\n        'traceback' : stb,\n        'ename' : unicode(etype.__name__),\n        'evalue' : unicode(evalue),\n        'engine_info' : engine_info\n    }\n    return exc_content\n\ndef unwrap_exception(content):\n    err = RemoteError(content['ename'], content['evalue'],\n                ''.join(content['traceback']),\n                content.get('engine_info', {}))\n    return err\n\n", "path": "IPython/parallel/error.py"}]}