Skip to content

Commit

Permalink
Repair unhandled AttributeError during pex bootstrapping. (#599)
Browse files Browse the repository at this point in the history
A quick, surface level fix for #598.
  • Loading branch information
kwlzn authored Nov 15, 2018
1 parent e53fadc commit a74f63a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pex/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,21 @@ def update_module_paths(cls, new_code_path):
TRACER.log('Adding to the head of sys.path: %s' % new_code_path)
sys.path.insert(0, new_code_path)
for name, module in sys.modules.items():
if hasattr(module, "__path__"):
if hasattr(module, '__path__'):
module_dir = os.path.join(new_code_path, *name.split("."))
TRACER.log('Adding to the head of %s.__path__: %s' % (module.__name__, module_dir))
module.__path__.insert(0, module_dir)
try:
module.__path__.insert(0, module_dir)
except AttributeError:
# TODO: This is a temporary bandaid for an unhandled AttributeError which results
# in a startup crash. See https://github.com/pantsbuild/pex/issues/598 for more info.
TRACER.log(
'Failed to insert %s: %s.__path__ of type %s does not support insertion!' % (
module_dir,
module.__name__,
type(module.__path__)
)
)

@classmethod
def write_zipped_internal_cache(cls, pex, pex_info):
Expand Down

0 comments on commit a74f63a

Please sign in to comment.