From 460780200685ab56f030e0ff459a36be1dbbb72f Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 21 Mar 2019 09:26:27 +0200 Subject: Fix test failures on Python 3.8.0a1 (#15) * Avoid the deprecated cgi.escape Fixes test failures on Python 3.8 prereleases (where cgi.escape is not just deprecated, but gone entirely). --- .travis.yml | 4 ++-- CHANGES.rst | 3 ++- src/zope/tales/tales.py | 6 +++++- tox.ini | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 80e6fd7..1984782 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: python -sudo: false python: - 2.7 - 3.4 @@ -11,7 +10,8 @@ matrix: include: - python: "3.7" dist: xenial - sudo: true + - python: "3.8-dev" + dist: xenial install: - pip install -U pip setuptools - pip install -U coverage coveralls diff --git a/CHANGES.rst b/CHANGES.rst index bb36cbb..78064d6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,8 @@ 4.4 (unreleased) ================ -- Nothing changed yet. +- Fix test failures and deprecation warnings occurring when using Python 3.8a1. + (`#15 `_) 4.3 (2018-10-05) diff --git a/src/zope/tales/tales.py b/src/zope/tales/tales.py index 9765fc8..0cb5ce2 100644 --- a/src/zope/tales/tales.py +++ b/src/zope/tales/tales.py @@ -18,6 +18,11 @@ An implementation of a TAL expression engine __docformat__ = "reStructuredText" import re +try: + from html import escape +except ImportError: + from cgi import escape + from zope.interface import implementer from zope.interface import Interface import six @@ -822,5 +827,4 @@ class TALESTracebackSupplement(object): if not as_html: return ' - Names:\n %s' % s.replace('\n', '\n ') - from cgi import escape return 'Names:
%s
' % (escape(s)) diff --git a/tox.ini b/tox.ini index fd0ceb6..a3996de 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py27,py34,py35,py36,py37,pypy,pypy3,coverage,docs + py27,py34,py35,py36,py37,py38,pypy,pypy3,coverage,docs [testenv] commands = -- cgit v1.2.1