Skip to content

Commit

Permalink
Fix crash due to unpicklable exc_info
Browse files Browse the repository at this point in the history
  • Loading branch information
rotu committed Aug 29, 2019
1 parent 1109c38 commit d3ca897
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions colcon_core/package_identification/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import multiprocessing
import os
import traceback
from typing import Optional

from colcon_core.dependency_descriptor import DependencyDescriptor
Expand Down Expand Up @@ -90,13 +89,13 @@ def get_setup_result(setup_py, *, env: Optional[dict]):
p.start()
p.join()
with conn_recv:
result_or_exc_info = conn_recv.recv()
result_or_exception_string = conn_recv.recv()

if isinstance(result_or_exc_info, dict):
return result_or_exc_info
if isinstance(result_or_exception_string, dict):
return result_or_exception_string
raise RuntimeError(
'Failure when trying to run setup script {}:\n{}'
.format(setup_py, traceback.format_exception(*result_or_exc_info)))
.format(setup_py, result_or_exception_string))


def _get_setup_result_target(setup_py: str, env: Optional[dict], conn_send):
Expand All @@ -108,11 +107,11 @@ def _get_setup_result_target(setup_py: str, env: Optional[dict], conn_send):
:param setup_py: Absolute path to a setup.py script
:param env: Environment variables to set before running setup.py
:param conn_send: Connection to send the result as either a dict or the
result of sys.exc_info
:param conn_send: Connection to send the result as either a dict or an
error string
"""
import distutils.core
import sys
import traceback
try:
# need to be in setup.py's parent dir to detect any setup.cfg
os.chdir(os.path.dirname(setup_py))
Expand Down Expand Up @@ -140,7 +139,7 @@ def _get_setup_result_target(setup_py: str, env: Optional[dict], conn_send):
and not attr.startswith('_')
)})
except BaseException:
conn_send.send(sys.exc_info())
conn_send.send(traceback.format_exc())
raise


Expand Down

0 comments on commit d3ca897

Please sign in to comment.