Skip to content

Commit

Permalink
Extra diagnostics on decode failure in package_hash.py
Browse files Browse the repository at this point in the history
  • Loading branch information
greenc-FNAL committed Dec 1, 2023
1 parent 96af824 commit a1b08fa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/spack/spack/util/package_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,11 @@ def package_ast(spec, filter_multimethods=True, source=None):

if source is None:
filename = spack.repo.PATH.filename_for_package_name(spec.name)
with open(filename) as f:
source = f.read()
try:
with open(filename) as f:
source = f.read()
except UnicodeDecodeError as e:
raise PackageHashError(f"Unicode error in {filename}: {e}")

# create an AST
root = ast.parse(source)
Expand Down

0 comments on commit a1b08fa

Please sign in to comment.