From ec48af448333fb06f991d7ce4509d894ecce95a3 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Tue, 9 Jul 2019 08:35:52 +0700 Subject: [PATCH 1/2] :green_heart: Remove Python 3.8-dev The Python 3.8-dev job has broken on building ruamel.yaml, and the template doesnt provide control over allowing failures. --- .moban.d/travis.yml | 1 - .travis.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.moban.d/travis.yml b/.moban.d/travis.yml index 741fd994..01e298ba 100644 --- a/.moban.d/travis.yml +++ b/.moban.d/travis.yml @@ -10,7 +10,6 @@ matrix: {%block custom_python_versions%} python: - &pypy2 pypy2.7-6.0 - - 3.8-dev - 3.7 - 3.6 - 3.5 diff --git a/.travis.yml b/.travis.yml index 6706df51..e5734eba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ notifications: email: false python: - &pypy2 pypy2.7-6.0 - - 3.8-dev - 3.7 - 3.6 - 3.5 From 10bebef26a160266df52fb845e2030b953863cbd Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Tue, 9 Jul 2019 06:19:19 +0700 Subject: [PATCH 2/2] :ambulance: fix unicode support on Python 2.7 Fixes two UnicodeEncodeError's occurring when hashing and writing files. Closes https://github.com/moremoban/moban/issues/281 --- moban/hashstore.py | 2 ++ moban/utils.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/moban/hashstore.py b/moban/hashstore.py index 17c9efd9..25b72518 100644 --- a/moban/hashstore.py +++ b/moban/hashstore.py @@ -65,6 +65,8 @@ def get_file_hash(afile): def get_hash(content): md5 = hashlib.md5() + if PY2 and content.__class__.__name__ == "unicode": + content = content.encode("utf-8") md5.update(content) return md5.digest().decode("latin1") diff --git a/moban/utils.py b/moban/utils.py index 3c498c95..87e0f63b 100644 --- a/moban/utils.py +++ b/moban/utils.py @@ -7,6 +7,7 @@ from moban import constants, exceptions log = logging.getLogger(__name__) +PY2 = sys.version_info[0] == 2 def merge(left, right): @@ -60,6 +61,8 @@ def file_permissions(afile): def write_file_out(filename, content): + if PY2 and content.__class__.__name__ == "unicode": + content = content.encode("utf-8") dest_folder = os.path.dirname(filename) if dest_folder: mkdir_p(dest_folder)