Skip to content

Commit b42bfc4

Browse files
committed
issue #125: handle frozen classes as exception
Seriously, who is the nutcrack which thought this was a good idea? Signed-off-by: Matteo Cafasso <[email protected]>
1 parent 16210b7 commit b42bfc4

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

pebble/common.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ def __reduce__(self):
122122

123123

124124
def rebuild_exception(exception, traceback):
125-
exception.__cause__ = RemoteTraceback(traceback)
125+
try:
126+
exception.traceback = traceback
127+
exception.__cause__ = RemoteTraceback(traceback)
128+
except AttributeError: # Frozen exception
129+
pass
126130

127131
return exception
128132

@@ -165,7 +169,11 @@ def execute(function, *args, **kwargs):
165169
try:
166170
return Result(SUCCESS, function(*args, **kwargs))
167171
except BaseException as error:
168-
error.traceback = format_exc()
172+
try:
173+
error.traceback = format_exc()
174+
except AttributeError: # Frozen exception
175+
pass
176+
169177
return Result(FAILURE, error)
170178

171179

@@ -174,17 +182,15 @@ def process_execute(function, *args, **kwargs):
174182
try:
175183
return Result(SUCCESS, function(*args, **kwargs))
176184
except BaseException as error:
177-
error.traceback = format_exc()
178-
return Result(FAILURE, RemoteException(error, error.traceback))
185+
return Result(FAILURE, RemoteException(error, format_exc()))
179186

180187

181188
def send_result(pipe, data):
182189
"""Send result handling pickling and communication errors."""
183190
try:
184191
pipe.send(data)
185192
except (pickle.PicklingError, TypeError) as error:
186-
error.traceback = format_exc()
187-
pipe.send(Result(ERROR, RemoteException(error, error.traceback)))
193+
pipe.send(Result(ERROR, RemoteException(error, format_exc())))
188194

189195

190196
Result = namedtuple('Result', ('status', 'value'))

0 commit comments

Comments
 (0)