From 657fae8155304ccb8f67427fed6ceb0267d641fa Mon Sep 17 00:00:00 2001 From: Peter Schmidt Date: Tue, 19 Jan 2016 10:47:21 +1100 Subject: [PATCH 1/6] Add coding: utf-8 header needed for Py2.6/Py2.7 --- premailer/tests/test_premailer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/premailer/tests/test_premailer.py b/premailer/tests/test_premailer.py index a7e7442..a7af303 100644 --- a/premailer/tests/test_premailer.py +++ b/premailer/tests/test_premailer.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals import sys import re From d7afa2066ec7f78dc3474184671fa9c38d9deeb0 Mon Sep 17 00:00:00 2001 From: Peter Schmidt Date: Tue, 19 Jan 2016 10:53:01 +1100 Subject: [PATCH 2/6] =?UTF-8?q?Add=20test=20for=20the=20unicode=20crescent?= =?UTF-8?q?=20moon=20=F0=9F=8C=99=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seems to only affect pyenv-installed Python 3.4; Python 2.6 and 2.7 are fine in my tox. --- premailer/tests/test_premailer.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/premailer/tests/test_premailer.py b/premailer/tests/test_premailer.py index a7af303..365fc88 100644 --- a/premailer/tests/test_premailer.py +++ b/premailer/tests/test_premailer.py @@ -2226,6 +2226,23 @@ def test_capture_cssutils_logging(self): p.transform() # it should work eq_(mylog.getvalue(), '') + def test_unicode_crescent_moon_0x1f319(self): + html = ''' + + + + + Dear Skyelar 🌙, + + +''' + p = Premailer(html) + + # Calling transform should not mangle + # the unicode character 🌙 + mojibake = p.transform() + compare_html(mojibake, html) + def test_type_test(self): """test the correct type is returned""" From 48c43b81cac915e197652ec933c7e6e1c2a02767 Mon Sep 17 00:00:00 2001 From: Peter Schmidt Date: Tue, 19 Jan 2016 11:22:51 +1100 Subject: [PATCH 3/6] Do one thing per line for easier debugging --- premailer/premailer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/premailer/premailer.py b/premailer/premailer.py index 293b8d3..e7eb2d8 100644 --- a/premailer/premailer.py +++ b/premailer/premailer.py @@ -462,7 +462,8 @@ def transform(self, pretty_print=True, **kwargs): kwargs.setdefault('method', self.method) kwargs.setdefault('pretty_print', pretty_print) kwargs.setdefault('encoding', 'utf-8') # As Ken Thompson intended - out = etree.tostring(root, **kwargs).decode(kwargs['encoding']) + out_bytes = etree.tostring(root, **kwargs) + out = out_bytes.decode(kwargs['encoding']) if self.method == 'xml': out = _cdata_regex.sub( lambda m: '/**/' % m.group(1), From 031f35eb1d5293009597fd90e8ddb47b10edb5fe Mon Sep 17 00:00:00 2001 From: Peter Schmidt Date: Thu, 28 Jan 2016 20:02:14 +1100 Subject: [PATCH 4/6] Add os: osx to .travis.yml To see if it's reproducible on Travis which if true may make whatever the underlying issue(s) are easier to debug. https://docs.travis-ci.com/user/multi-os/ --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index c1393b4..0a46a5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,10 @@ # directive. sudo: no +os: + - linux + - osx + env: PIP_DOWNLOAD_CACHE="pip_cache" cache: directories: From 66bd5361cf2d76b70ad59c267b62b18d6bc30584 Mon Sep 17 00:00:00 2001 From: Peter Schmidt Date: Thu, 28 Jan 2016 20:24:01 +1100 Subject: [PATCH 5/6] Try switching back to 2.7 To see if only Python 3.5 fails at the building environment under OSX stage and we can perhaps get 3.3 or 3.4 out. However this is not very inspiring... https://github.com/apache/libcloud/commit/95338d89ae1653f9c50369cd3201f172aed17354 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0a46a5f..19cf0ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,8 @@ install: # See https://github.com/travis-ci/travis-ci/issues/4794 # and https://github.com/audreyr/cookiecutter/pull/540/files -python: 3.5 +# TODO: Temporarily changed back to 2.7 to see if OSX installs most of these +python: 2.7 env: - TOX_ENV=flake8 From f32952d01fe9e29fd711c743b4bc7f8efab4b05b Mon Sep 17 00:00:00 2001 From: Peter Schmidt Date: Thu, 28 Jan 2016 20:35:44 +1100 Subject: [PATCH 6/6] Last long shot try for OSX Travis See https://github.com/apache/libcloud/pull/543 and https://github.com/gabik/libcloud/blob/LIBCLOUD-720_GCE-timeout/.travis.yml --- .travis.yml | 58 +++++++++-------------------------------------------- 1 file changed, 10 insertions(+), 48 deletions(-) diff --git a/.travis.yml b/.travis.yml index 19cf0ad..4a87d50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,59 +1,21 @@ -# https://travis-ci.org/peterbe/premailer - -# This indicates to Travis that we will not use or need sudo -# so that we can benefit from and use the cache->directories -# directive. -sudo: no - +language: python +python: 2.7 +sudo: false os: - linux - osx - -env: PIP_DOWNLOAD_CACHE="pip_cache" -cache: - directories: - - pip_cache - -language: python - -before_install: - # twine is necessary so that travis can deploy - - travis_retry pip install twine - - travis_retry pip install tox coveralls - -install: - - travis_retry python setup.py install - -# See https://github.com/travis-ci/travis-ci/issues/4794 -# and https://github.com/audreyr/cookiecutter/pull/540/files -# TODO: Temporarily changed back to 2.7 to see if OSX installs most of these -python: 2.7 - env: - - TOX_ENV=flake8 + - TOX_ENV=lint - TOX_ENV=py26 - TOX_ENV=py27 + - TOX_ENV=pypy + - TOX_ENV=py32 - TOX_ENV=py33 - TOX_ENV=py34 - - TOX_ENV=py35 - - TOX_ENV=pypy + - TOX_ENV=docs + +install: + - pip install tox script: - tox -e $TOX_ENV - -after_success: - # Report coverage results to coveralls.io - - coveralls - -deploy: - provider: pypi - user: peterbe - password: - secure: mdzD1SHDQ84ZK8tVXdF2LuMsws7it/7foompnuNUTQSVaKdjaHpwTYQtmdLUX0Jv54Plx4861GWNf6CD5IVfU7G8R2Ls/5/tQECFG01AspGz23lL1PxUg9tpNm+LPkQtkJzvS3f4i6/mODnKcoaSnhL63JuGaUNa72B1yBaN4hY= - on: - repo: peterbe/premailer - distributions: "sdist bdist_wheel" - -notifications: - email: - on_success: never