From: JinWang An Date: Tue, 5 Jan 2021 03:16:07 +0000 (+0900) Subject: Imported Upstream version 2.0.1 X-Git-Tag: upstream/2.0.1^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7fc9bf0e5250e1c1d07080818823fb8ea0feb3ca;p=platform%2Fupstream%2Fpython3-pygments.git Imported Upstream version 2.0.1 --- diff --git a/CHANGES b/CHANGES index 1537480..7031852 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,14 @@ Issue numbers refer to the tracker at pull request numbers to the requests at . + +Version 2.0.1 +------------- +(released Nov 10, 2014) + +- Fix an encoding issue when using ``pygmentize`` with the ``-o`` option. + + Version 2.0 ----------- (released Nov 9, 2014) diff --git a/PKG-INFO b/PKG-INFO index 0cc9dc3..14ade0d 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: Pygments -Version: 2.0 +Version: 2.0.1 Summary: Pygments is a syntax highlighting package written in Python. Home-page: http://pygments.org/ Author: Georg Brandl diff --git a/Pygments.egg-info/PKG-INFO b/Pygments.egg-info/PKG-INFO index 0cc9dc3..14ade0d 100644 --- a/Pygments.egg-info/PKG-INFO +++ b/Pygments.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: Pygments -Version: 2.0 +Version: 2.0.1 Summary: Pygments is a syntax highlighting package written in Python. Home-page: http://pygments.org/ Author: Georg Brandl diff --git a/Pygments.egg-info/SOURCES.txt b/Pygments.egg-info/SOURCES.txt index dac7771..5fb140f 100644 --- a/Pygments.egg-info/SOURCES.txt +++ b/Pygments.egg-info/SOURCES.txt @@ -387,6 +387,33 @@ tests/test_using_api.py tests/test_using_api.pyc tests/test_util.py tests/test_util.pyc +tests/__pycache__/string_asserts.cpython-33.pyc +tests/__pycache__/support.cpython-33.pyc +tests/__pycache__/test_basic_api.cpython-33.pyc +tests/__pycache__/test_cfm.cpython-33.pyc +tests/__pycache__/test_clexer.cpython-33.pyc +tests/__pycache__/test_cmdline.cpython-33.pyc +tests/__pycache__/test_examplefiles.cpython-33.pyc +tests/__pycache__/test_html_formatter.cpython-33.pyc +tests/__pycache__/test_inherit.cpython-33.pyc +tests/__pycache__/test_java.cpython-33.pyc +tests/__pycache__/test_latex_formatter.cpython-33.pyc +tests/__pycache__/test_lexers_other.cpython-33.pyc +tests/__pycache__/test_objectiveclexer.cpython-33.pyc +tests/__pycache__/test_perllexer.cpython-33.pyc +tests/__pycache__/test_qbasiclexer.cpython-33.pyc +tests/__pycache__/test_regexlexer.cpython-33.pyc +tests/__pycache__/test_regexopt.cpython-33.pyc +tests/__pycache__/test_rtf_formatter.cpython-33.pyc +tests/__pycache__/test_ruby.cpython-33.pyc +tests/__pycache__/test_shell.cpython-33.pyc +tests/__pycache__/test_smarty.cpython-33.pyc +tests/__pycache__/test_string_asserts.cpython-33.pyc +tests/__pycache__/test_textfmts.cpython-33.pyc +tests/__pycache__/test_token.cpython-33.pyc +tests/__pycache__/test_unistring.cpython-33.pyc +tests/__pycache__/test_using_api.cpython-33.pyc +tests/__pycache__/test_util.cpython-33.pyc tests/dtds/HTML4-f.dtd tests/dtds/HTML4-s.dtd tests/dtds/HTML4.dcl diff --git a/pygments/__init__.py b/pygments/__init__.py index ef297f2..872ad97 100644 --- a/pygments/__init__.py +++ b/pygments/__init__.py @@ -26,7 +26,7 @@ :license: BSD, see LICENSE for details. """ -__version__ = '2.0' +__version__ = '2.0.1' __docformat__ = 'restructuredtext' __all__ = ['lex', 'format', 'highlight'] diff --git a/pygments/cmdline.py b/pygments/cmdline.py index 1a1f8fa..b6c319c 100644 --- a/pygments/cmdline.py +++ b/pygments/cmdline.py @@ -330,62 +330,6 @@ def main(args=sys.argv): F_opts = _parse_filters(F_opts) opts.pop('-F', None) - # select formatter - outfn = opts.pop('-o', None) - fmter = opts.pop('-f', None) - if fmter: - try: - fmter = get_formatter_by_name(fmter, **parsed_opts) - except (OptionError, ClassNotFound) as err: - print('Error:', err, file=sys.stderr) - return 1 - - if outfn: - if not fmter: - try: - fmter = get_formatter_for_filename(outfn, **parsed_opts) - except (OptionError, ClassNotFound) as err: - print('Error:', err, file=sys.stderr) - return 1 - try: - outfile = open(outfn, 'wb') - except Exception as err: - print('Error: cannot open outfile:', err, file=sys.stderr) - return 1 - else: - if not fmter: - fmter = TerminalFormatter(**parsed_opts) - if sys.version_info > (3,): - # Python 3: we have to use .buffer to get a binary stream - outfile = sys.stdout.buffer - else: - outfile = sys.stdout - - # determine output encoding if not explicitly selected - if not outencoding: - if outfn: - # output file? -> encoding pass-through - fmter.encoding = inencoding - else: - # else use terminal encoding - fmter.encoding = terminal_encoding(sys.stdout) - - # provide coloring under Windows, if possible - if not outfn and sys.platform in ('win32', 'cygwin') and \ - fmter.name in ('Terminal', 'Terminal256'): - # unfortunately colorama doesn't support binary streams on Py3 - if sys.version_info > (3,): - import io - outfile = io.TextIOWrapper(outfile, encoding=fmter.encoding) - fmter.encoding = None - try: - import colorama.initialise - except ImportError: - pass - else: - outfile = colorama.initialise.wrap_stream( - outfile, convert=None, strip=None, autoreset=False, wrap=True) - # select lexer lexer = opts.pop('-l', None) if lexer: @@ -452,6 +396,62 @@ def main(args=sys.argv): except ClassNotFound: lexer = TextLexer(**parsed_opts) + # select formatter + outfn = opts.pop('-o', None) + fmter = opts.pop('-f', None) + if fmter: + try: + fmter = get_formatter_by_name(fmter, **parsed_opts) + except (OptionError, ClassNotFound) as err: + print('Error:', err, file=sys.stderr) + return 1 + + if outfn: + if not fmter: + try: + fmter = get_formatter_for_filename(outfn, **parsed_opts) + except (OptionError, ClassNotFound) as err: + print('Error:', err, file=sys.stderr) + return 1 + try: + outfile = open(outfn, 'wb') + except Exception as err: + print('Error: cannot open outfile:', err, file=sys.stderr) + return 1 + else: + if not fmter: + fmter = TerminalFormatter(**parsed_opts) + if sys.version_info > (3,): + # Python 3: we have to use .buffer to get a binary stream + outfile = sys.stdout.buffer + else: + outfile = sys.stdout + + # determine output encoding if not explicitly selected + if not outencoding: + if outfn: + # output file? use lexer encoding for now (can still be None) + fmter.encoding = inencoding + else: + # else use terminal encoding + fmter.encoding = terminal_encoding(sys.stdout) + + # provide coloring under Windows, if possible + if not outfn and sys.platform in ('win32', 'cygwin') and \ + fmter.name in ('Terminal', 'Terminal256'): + # unfortunately colorama doesn't support binary streams on Py3 + if sys.version_info > (3,): + import io + outfile = io.TextIOWrapper(outfile, encoding=fmter.encoding) + fmter.encoding = None + try: + import colorama.initialise + except ImportError: + pass + else: + outfile = colorama.initialise.wrap_stream( + outfile, convert=None, strip=None, autoreset=False, wrap=True) + # When using the LaTeX formatter and the option `escapeinside` is # specified, we need a special lexer which collects escaped text # before running the chosen language lexer. @@ -494,6 +494,7 @@ def main(args=sys.argv): return 0 except Exception: + raise import traceback info = traceback.format_exception(*sys.exc_info()) msg = info[-1].strip() diff --git a/setup.py b/setup.py index dde886c..c46d805 100755 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ else: setup( name = 'Pygments', - version = '2.0', + version = '2.0.1', url = 'http://pygments.org/', license = 'BSD License', author = 'Georg Brandl', diff --git a/tests/__pycache__/string_asserts.cpython-33.pyc b/tests/__pycache__/string_asserts.cpython-33.pyc new file mode 100644 index 0000000..27c3e11 Binary files /dev/null and b/tests/__pycache__/string_asserts.cpython-33.pyc differ diff --git a/tests/__pycache__/support.cpython-33.pyc b/tests/__pycache__/support.cpython-33.pyc new file mode 100644 index 0000000..714cfd3 Binary files /dev/null and b/tests/__pycache__/support.cpython-33.pyc differ diff --git a/tests/__pycache__/test_basic_api.cpython-33.pyc b/tests/__pycache__/test_basic_api.cpython-33.pyc new file mode 100644 index 0000000..3e7dd7b Binary files /dev/null and b/tests/__pycache__/test_basic_api.cpython-33.pyc differ diff --git a/tests/__pycache__/test_cfm.cpython-33.pyc b/tests/__pycache__/test_cfm.cpython-33.pyc new file mode 100644 index 0000000..ed11088 Binary files /dev/null and b/tests/__pycache__/test_cfm.cpython-33.pyc differ diff --git a/tests/__pycache__/test_clexer.cpython-33.pyc b/tests/__pycache__/test_clexer.cpython-33.pyc new file mode 100644 index 0000000..19586b7 Binary files /dev/null and b/tests/__pycache__/test_clexer.cpython-33.pyc differ diff --git a/tests/__pycache__/test_cmdline.cpython-33.pyc b/tests/__pycache__/test_cmdline.cpython-33.pyc new file mode 100644 index 0000000..1083ed3 Binary files /dev/null and b/tests/__pycache__/test_cmdline.cpython-33.pyc differ diff --git a/tests/__pycache__/test_examplefiles.cpython-33.pyc b/tests/__pycache__/test_examplefiles.cpython-33.pyc new file mode 100644 index 0000000..a1471e9 Binary files /dev/null and b/tests/__pycache__/test_examplefiles.cpython-33.pyc differ diff --git a/tests/__pycache__/test_html_formatter.cpython-33.pyc b/tests/__pycache__/test_html_formatter.cpython-33.pyc new file mode 100644 index 0000000..58cb7c0 Binary files /dev/null and b/tests/__pycache__/test_html_formatter.cpython-33.pyc differ diff --git a/tests/__pycache__/test_inherit.cpython-33.pyc b/tests/__pycache__/test_inherit.cpython-33.pyc new file mode 100644 index 0000000..bc231e9 Binary files /dev/null and b/tests/__pycache__/test_inherit.cpython-33.pyc differ diff --git a/tests/__pycache__/test_java.cpython-33.pyc b/tests/__pycache__/test_java.cpython-33.pyc new file mode 100644 index 0000000..3348c09 Binary files /dev/null and b/tests/__pycache__/test_java.cpython-33.pyc differ diff --git a/tests/__pycache__/test_latex_formatter.cpython-33.pyc b/tests/__pycache__/test_latex_formatter.cpython-33.pyc new file mode 100644 index 0000000..eac2a70 Binary files /dev/null and b/tests/__pycache__/test_latex_formatter.cpython-33.pyc differ diff --git a/tests/__pycache__/test_lexers_other.cpython-33.pyc b/tests/__pycache__/test_lexers_other.cpython-33.pyc new file mode 100644 index 0000000..cc73d13 Binary files /dev/null and b/tests/__pycache__/test_lexers_other.cpython-33.pyc differ diff --git a/tests/__pycache__/test_objectiveclexer.cpython-33.pyc b/tests/__pycache__/test_objectiveclexer.cpython-33.pyc new file mode 100644 index 0000000..8a558b6 Binary files /dev/null and b/tests/__pycache__/test_objectiveclexer.cpython-33.pyc differ diff --git a/tests/__pycache__/test_perllexer.cpython-33.pyc b/tests/__pycache__/test_perllexer.cpython-33.pyc new file mode 100644 index 0000000..53c6f55 Binary files /dev/null and b/tests/__pycache__/test_perllexer.cpython-33.pyc differ diff --git a/tests/__pycache__/test_qbasiclexer.cpython-33.pyc b/tests/__pycache__/test_qbasiclexer.cpython-33.pyc new file mode 100644 index 0000000..effeedc Binary files /dev/null and b/tests/__pycache__/test_qbasiclexer.cpython-33.pyc differ diff --git a/tests/__pycache__/test_regexlexer.cpython-33.pyc b/tests/__pycache__/test_regexlexer.cpython-33.pyc new file mode 100644 index 0000000..c938c17 Binary files /dev/null and b/tests/__pycache__/test_regexlexer.cpython-33.pyc differ diff --git a/tests/__pycache__/test_regexopt.cpython-33.pyc b/tests/__pycache__/test_regexopt.cpython-33.pyc new file mode 100644 index 0000000..5473bbb Binary files /dev/null and b/tests/__pycache__/test_regexopt.cpython-33.pyc differ diff --git a/tests/__pycache__/test_rtf_formatter.cpython-33.pyc b/tests/__pycache__/test_rtf_formatter.cpython-33.pyc new file mode 100644 index 0000000..16cc5a7 Binary files /dev/null and b/tests/__pycache__/test_rtf_formatter.cpython-33.pyc differ diff --git a/tests/__pycache__/test_ruby.cpython-33.pyc b/tests/__pycache__/test_ruby.cpython-33.pyc new file mode 100644 index 0000000..5545277 Binary files /dev/null and b/tests/__pycache__/test_ruby.cpython-33.pyc differ diff --git a/tests/__pycache__/test_shell.cpython-33.pyc b/tests/__pycache__/test_shell.cpython-33.pyc new file mode 100644 index 0000000..16f23ed Binary files /dev/null and b/tests/__pycache__/test_shell.cpython-33.pyc differ diff --git a/tests/__pycache__/test_smarty.cpython-33.pyc b/tests/__pycache__/test_smarty.cpython-33.pyc new file mode 100644 index 0000000..18f8441 Binary files /dev/null and b/tests/__pycache__/test_smarty.cpython-33.pyc differ diff --git a/tests/__pycache__/test_string_asserts.cpython-33.pyc b/tests/__pycache__/test_string_asserts.cpython-33.pyc new file mode 100644 index 0000000..401c439 Binary files /dev/null and b/tests/__pycache__/test_string_asserts.cpython-33.pyc differ diff --git a/tests/__pycache__/test_textfmts.cpython-33.pyc b/tests/__pycache__/test_textfmts.cpython-33.pyc new file mode 100644 index 0000000..4588f0e Binary files /dev/null and b/tests/__pycache__/test_textfmts.cpython-33.pyc differ diff --git a/tests/__pycache__/test_token.cpython-33.pyc b/tests/__pycache__/test_token.cpython-33.pyc new file mode 100644 index 0000000..014d57b Binary files /dev/null and b/tests/__pycache__/test_token.cpython-33.pyc differ diff --git a/tests/__pycache__/test_unistring.cpython-33.pyc b/tests/__pycache__/test_unistring.cpython-33.pyc new file mode 100644 index 0000000..6eb1955 Binary files /dev/null and b/tests/__pycache__/test_unistring.cpython-33.pyc differ diff --git a/tests/__pycache__/test_using_api.cpython-33.pyc b/tests/__pycache__/test_using_api.cpython-33.pyc new file mode 100644 index 0000000..b3f69e5 Binary files /dev/null and b/tests/__pycache__/test_using_api.cpython-33.pyc differ diff --git a/tests/__pycache__/test_util.cpython-33.pyc b/tests/__pycache__/test_util.cpython-33.pyc new file mode 100644 index 0000000..0660cca Binary files /dev/null and b/tests/__pycache__/test_util.cpython-33.pyc differ diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 2e02ae5..038b96b 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -10,7 +10,9 @@ from __future__ import print_function import io +import os import sys +import tempfile import unittest from pygments import highlight @@ -111,3 +113,15 @@ class CmdLineTest(unittest.TestCase): self.assertEqual(o, output) self.assertEqual(e, "") self.assertEqual(c, 0) + + def test_outfile(self): + # test that output file works with and without encoding + fd, name = tempfile.mkstemp() + os.close(fd) + for opts in [['-fhtml', '-o', name, TESTFILE], + ['-flatex', '-o', name, TESTFILE], + ['-fhtml', '-o', name, '-O', 'encoding=utf-8', TESTFILE]]: + try: + self.assertEqual(run_cmdline(*opts)[0], 0) + finally: + os.unlink(name) diff --git a/tests/test_cmdline.pyc b/tests/test_cmdline.pyc index c0172c4..32f2763 100644 Binary files a/tests/test_cmdline.pyc and b/tests/test_cmdline.pyc differ