diff options
| -rw-r--r-- | pygments/util.py | 4 | ||||
| -rw-r--r-- | tests/test_html_formatter.py | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/pygments/util.py b/pygments/util.py index fc65b676..1bd1455f 100644 --- a/pygments/util.py +++ b/pygments/util.py @@ -8,8 +8,10 @@ :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ + import re import sys +import codecs split_path_re = re.compile(r'[/\\ ]') @@ -206,6 +208,7 @@ if sys.version_info < (3,0): import StringIO, cStringIO BytesIO = cStringIO.StringIO StringIO = StringIO.StringIO + uni_open = codecs.open else: import builtins bytes = builtins.bytes @@ -220,3 +223,4 @@ else: import io BytesIO = io.BytesIO StringIO = io.StringIO + uni_open = builtins.open diff --git a/tests/test_html_formatter.py b/tests/test_html_formatter.py index 9ff593f9..ae54b919 100644 --- a/tests/test_html_formatter.py +++ b/tests/test_html_formatter.py @@ -12,17 +12,19 @@ import re import unittest import StringIO import tempfile -from os.path import join, dirname, isfile, abspath +from os.path import join, dirname, isfile from pygments.lexers import PythonLexer from pygments.formatters import HtmlFormatter, NullFormatter from pygments.formatters.html import escape_html +from pygments.util import uni_open import support TESTFILE, TESTDIR = support.location(__file__) -tokensource = list(PythonLexer(encoding='utf-8').get_tokens(open(TESTFILE).read())) +tokensource = list(PythonLexer().get_tokens( + uni_open(TESTFILE, encoding='utf-8').read())) class HtmlFormatterTest(unittest.TestCase): |
