diff --git a/examples/bench/basic.py b/examples/bench/basic.py index c0318ee..79c6049 100644 --- a/examples/bench/basic.py +++ b/examples/bench/basic.py @@ -5,12 +5,20 @@ from __future__ import print_function -from cgi import escape import os -from StringIO import StringIO import sys import timeit +try: + from html import escape +except ImportError: + from cgi import escape + +try: + from io import StringIO +except ImportError: + from StringIO import StringIO + __all__ = ['clearsilver', 'mako', 'django', 'kid', 'genshi', 'genshi_text', 'simpletal'] diff --git a/examples/bench/bigtable.py b/examples/bench/bigtable.py index 521f6c3..b51a540 100644 --- a/examples/bench/bigtable.py +++ b/examples/bench/bigtable.py @@ -7,15 +7,23 @@ from __future__ import print_function -import cgi import sys import timeit -from StringIO import StringIO from genshi.builder import tag from genshi.filters.i18n import Translator from genshi.filters.tests.i18n import DummyTranslations from genshi.template import MarkupTemplate, NewTextTemplate +try: + from html import escape +except ImportError: + from cgi import escape + +try: + from io import StringIO +except ImportError: + from StringIO import StringIO + try: from elementtree import ElementTree as et except ImportError: @@ -202,7 +210,7 @@ def test_clearsilver(): hdf = neo_util.HDF() for i, row in enumerate(table): for j, c in enumerate(row.values()): - hdf.setValue("rows.%d.cell.%d" % (i, j), cgi.escape(str(c))) + hdf.setValue("rows.%d.cell.%d" % (i, j), escape(str(c))) cs = neo_cs.CS(hdf) cs.parseStr("""