From af0e2a48443e501d1eebfc69e92b35f36752a951 Mon Sep 17 00:00:00 2001 From: Nikolay Orlyuk Date: Thu, 17 Jan 2019 23:30:33 +0100 Subject: Use unicode literals in docstrings as well Resolves #1492 --- pygments/lexers/qvt.py | 2 +- pygments/styles/arduino.py | 4 ++-- pygments/styles/paraiso_dark.py | 2 +- pygments/styles/paraiso_light.py | 2 +- tests/test_cmdline.py | 13 ++++++++++--- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/pygments/lexers/qvt.py b/pygments/lexers/qvt.py index af091a65..9b2559b1 100644 --- a/pygments/lexers/qvt.py +++ b/pygments/lexers/qvt.py @@ -18,7 +18,7 @@ __all__ = ['QVToLexer'] class QVToLexer(RegexLexer): - """ + u""" For the `QVT Operational Mapping language `_. Reference for implementing this: «Meta Object Facility (MOF) 2.0 diff --git a/pygments/styles/arduino.py b/pygments/styles/arduino.py index 57e3809e..b500b6d9 100644 --- a/pygments/styles/arduino.py +++ b/pygments/styles/arduino.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -""" +u""" pygments.styles.arduino ~~~~~~~~~~~~~~~~~~~~~~~ @@ -15,7 +15,7 @@ from pygments.token import Keyword, Name, Comment, String, Error, \ class ArduinoStyle(Style): - """ + u""" The Arduino® language style. This style is designed to highlight the Arduino source code, so exepect the best results with it. """ diff --git a/pygments/styles/paraiso_dark.py b/pygments/styles/paraiso_dark.py index 5f334bb9..68abb9f6 100644 --- a/pygments/styles/paraiso_dark.py +++ b/pygments/styles/paraiso_dark.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -""" +u""" pygments.styles.paraiso_dark ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pygments/styles/paraiso_light.py b/pygments/styles/paraiso_light.py index a8112819..186e4775 100644 --- a/pygments/styles/paraiso_light.py +++ b/pygments/styles/paraiso_light.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -""" +u""" pygments.styles.paraiso_light ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 1500c875..a55e30ec 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -28,6 +28,13 @@ def func(args): ''' +def _decode_output(text): + try: + return text.decode('utf-8') + except UnicodeEncodeError: # implicit encode on Python 2 with data loss + return text + + def run_cmdline(*args, **kwds): saved_stdin = sys.stdin saved_stdout = sys.stdout @@ -53,9 +60,9 @@ def run_cmdline(*args, **kwds): sys.stderr = saved_stderr new_stdout.flush() new_stderr.flush() - out, err = stdout_buffer.getvalue().decode('utf-8'), \ - stderr_buffer.getvalue().decode('utf-8') - return (ret, out, err) + out, err = stdout_buffer.getvalue(), \ + stderr_buffer.getvalue() + return (ret, _decode_output(out), _decode_output(err)) class CmdLineTest(unittest.TestCase): -- cgit v1.2.1