Fix encoding errors when hashing XML

We occasionally get UnicodeEncodeErrors from these two places,
because the XML is a Unicode string, and is implicitly encoded to ascii.
This commit is contained in:
Ned Batchelder
2013-06-06 15:46:18 -04:00
parent a3a7d1d548
commit d4db4c6dea
2 changed files with 3 additions and 2 deletions

View File

@@ -87,7 +87,7 @@ class ErrorDescriptor(ErrorFields, JSONEditingDescriptor):
# but url_names aren't guaranteed to be unique between descriptor types,
# and ErrorDescriptor can wrap any type. When the wrapped module is fixed,
# it will be written out with the original url_name.
name=hashlib.sha1(contents).hexdigest()
name=hashlib.sha1(contents.encode('utf8')).hexdigest()
)
# real metadata stays in the content, but add a display name