Skip to content

Commit

Permalink
avoid duplicate 'Exception: message' in CellExecutionError (#283)
Browse files Browse the repository at this point in the history
tracebacks end with this info, so no need to repeat it in our template

Removes unused `__unicode__` method for Python 2 unicode reprs
  • Loading branch information
minrk authored Apr 17, 2023
1 parent 3646f68 commit eab9611
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions nbclient/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,10 @@ def __reduce__(self) -> tuple:

def __str__(self) -> str:
"""Str repr."""
s = self.__unicode__()
if not isinstance(s, str):
s = s.encode('utf8', 'replace')
return s

def __unicode__(self) -> str:
"""Unicode repr."""
return self.traceback
if self.traceback:
return self.traceback
else:
return f"{self.ename}: {self.evalue}"

@classmethod
def from_cell_and_msg(cls, cell: NotebookNode, msg: Dict) -> "CellExecutionError":
Expand All @@ -93,8 +89,6 @@ def from_cell_and_msg(cls, cell: NotebookNode, msg: Dict) -> "CellExecutionError
exec_err_msg.format(
cell=cell,
traceback=tb,
ename=msg.get('ename', '<Error>'),
evalue=msg.get('evalue', ''),
),
ename=msg.get('ename', '<Error>'),
evalue=msg.get('evalue', ''),
Expand All @@ -108,7 +102,6 @@ def from_cell_and_msg(cls, cell: NotebookNode, msg: Dict) -> "CellExecutionError
------------------
{traceback}
{ename}: {evalue}
"""


Expand Down

0 comments on commit eab9611

Please sign in to comment.