Mercurial > hg
changeset 41833:89f01ea906ae
attr: don't attempt to .encode() a str on Python 2
Otherwise it coerces automatically.
Differential Revision: https://phab.mercurial-scm.org/D6048
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 02 Mar 2019 12:55:29 -0800 |
parents | b275dbb60089 |
children | 7f63ec6969f3 |
files | mercurial/thirdparty/attr/_make.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/thirdparty/attr/_make.py Sat Mar 02 12:51:55 2019 -0800 +++ b/mercurial/thirdparty/attr/_make.py Sat Mar 02 12:55:29 2019 -0800 @@ -555,7 +555,10 @@ # We cache the generated init methods for the same kinds of attributes. sha1 = hashlib.sha1() - sha1.update(repr(attrs).encode("utf-8")) + r = repr(attrs) + if not isinstance(r, bytes): + r = r.encode('utf-8') + sha1.update(r) unique_filename = "<attrs generated init {0}>".format( sha1.hexdigest() )