Imported Upstream version 2.0.1 upstream/2.0.1
authorJinWang An <jinwang.an@samsung.com>
Tue, 5 Jan 2021 03:16:07 +0000 (12:16 +0900)
committerJinWang An <jinwang.an@samsung.com>
Tue, 5 Jan 2021 03:16:07 +0000 (12:16 +0900)
36 files changed:
CHANGES
PKG-INFO
Pygments.egg-info/PKG-INFO
Pygments.egg-info/SOURCES.txt
pygments/__init__.py
pygments/cmdline.py
setup.py
tests/__pycache__/string_asserts.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/support.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_basic_api.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_cfm.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_clexer.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_cmdline.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_examplefiles.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_html_formatter.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_inherit.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_java.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_latex_formatter.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_lexers_other.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_objectiveclexer.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_perllexer.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_qbasiclexer.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_regexlexer.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_regexopt.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_rtf_formatter.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_ruby.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_shell.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_smarty.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_string_asserts.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_textfmts.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_token.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_unistring.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_using_api.cpython-33.pyc [new file with mode: 0644]
tests/__pycache__/test_util.cpython-33.pyc [new file with mode: 0644]
tests/test_cmdline.py
tests/test_cmdline.pyc

diff --git a/CHANGES b/CHANGES
index 1537480f5d76245e814a56f269411a9a59b69e7a..7031852e684942d63fe0324ed8c81f8eaccbb9db 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,14 @@ Issue numbers refer to the tracker at
 pull request numbers to the requests at
 <http://bitbucket.org/birkenfeld/pygments-main/pull-requests/merged>.
 
+
+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)
index 0cc9dc31a29b6213830d5e84c688a6de7022bdf7..14ade0d174d3f0ba9cbfc2d540cb1246b7ad79a3 100644 (file)
--- 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
index 0cc9dc31a29b6213830d5e84c688a6de7022bdf7..14ade0d174d3f0ba9cbfc2d540cb1246b7ad79a3 100644 (file)
@@ -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
index dac7771f11c4cd2a9e0d84966b0faba9ec8531a0..5fb140f42893e98095e5744c0ce511df940a6803 100644 (file)
@@ -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
index ef297f2b1ea7ff614feef8358892d65589b0ca48..872ad9761968a30c5ca10aadfd9adc23cea9ed26 100644 (file)
@@ -26,7 +26,7 @@
     :license: BSD, see LICENSE for details.
 """
 
-__version__ = '2.0'
+__version__ = '2.0.1'
 __docformat__ = 'restructuredtext'
 
 __all__ = ['lex', 'format', 'highlight']
index 1a1f8faa839792328c57db4627fc32d222e3e28a..b6c319cfafc86d4eeb08aadd732bb39d9435840c 100644 (file)
@@ -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()
index dde886c5b6de79a223a351a655ab52e46df6419e..c46d805e1272715c2f296b3390911c1415473f6c 100755 (executable)
--- 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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
index 0000000..0660cca
Binary files /dev/null and b/tests/__pycache__/test_util.cpython-33.pyc differ
index 2e02ae522576bedb79d70faa675fe8b8e4601efb..038b96bf562470f3f0f7dfccfe7059ecf4b52e80 100644 (file)
@@ -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)
index c0172c4302fc0caa2871fe775647fc7e8d274733..32f2763d66ca0e2368831428b7ce209fa3f74df4 100644 (file)
Binary files a/tests/test_cmdline.pyc and b/tests/test_cmdline.pyc differ