From: Stephen F. <st...@th...> - 2019-08-25 15:57:08
|
This doesn't involve a whole lot of changes, but references to Python 3.3 and 3.4 (plus some to the already removed Python 2.6) are removed and 'setup.py' is updated as necessary. This has already been agreed upon, as noted in RELEASE-NOTES.txt: Docutils 0.15.x is the last version supporting Python 2.6, 3.3, and 3.4. Docutils 0.16 is compatible with Python versions 2.7 and 3.5 to 3.7. Signed-off-by: Stephen Finucane <st...@th...ru> --- docutils/HISTORY.txt | 2 +- docutils/README.txt | 4 +- docutils/docs/dev/distributing.txt | 2 +- docutils/docs/dev/testing.txt | 45 +++++++++---------- docutils/docutils/frontend.py | 2 +- docutils/docutils/utils/code_analyzer.py | 2 +- docutils/docutils/writers/odf_odt/__init__.py | 5 ++- docutils/setup.py | 3 +- docutils/test/test_error_reporting.py | 13 ++---- .../test_rst/test_directives/test_tables.py | 14 +++--- docutils/test/test_utils.py | 9 ++-- docutils/test/test_writers/test_odt.py | 1 + docutils/tools/buildhtml.py | 2 +- docutils/tox.ini | 2 +- 14 files changed, 48 insertions(+), 58 deletions(-) diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 40a5c6642..70bac5fa4 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -20,7 +20,7 @@ Changes Since 0.15 * General - - Dropped support for Python 2.6 (work in progress). + - Dropped support for Python 2.6, 3.3 and 3.4 (work in progress). - Keep `backslash escapes`__ in the document tree. Backslash characters in text are be represented by NULL characters in the ``text`` attribute of Doctree nodes and removed in the writing stage by the node's diff --git a/docutils/README.txt b/docutils/README.txt index 747a04a52..41c8c6ba9 100644 --- a/docutils/README.txt +++ b/docutils/README.txt @@ -16,7 +16,7 @@ Quick-Start This is for those who want to get up & running quickly. -1. Docutils requires Python (version 2.6 or later), available from +1. Docutils requires Python (version 2.7 or later), available from http://www.python.org/ @@ -104,7 +104,7 @@ Requirements To run the code, Python_ must be installed. Docutils is compatible with Python versions 2.7, and -versions 3.3 to 3.7 (cf. `Python 3 compatibility`_). +versions 3.5 to 3.7 (cf. `Python 3 compatibility`_). Docutils uses the following packages for enhanced functionality, if they are installed: diff --git a/docutils/docs/dev/distributing.txt b/docutils/docs/dev/distributing.txt index 3aeb6af24..e4d4fa349 100644 --- a/docutils/docs/dev/distributing.txt +++ b/docutils/docs/dev/distributing.txt @@ -28,7 +28,7 @@ Dependencies Docutils has the following dependencies: -* Python 2.6 or later is required. Use ">= Python 2.6" in the +* Python 2.7 or later is required. Use ">= Python 2.7" in the dependencies. * Docutils may optionally make use of the PIL (`Python Imaging diff --git a/docutils/docs/dev/testing.txt b/docutils/docs/dev/testing.txt index f9d326b52..d7151d681 100644 --- a/docutils/docs/dev/testing.txt +++ b/docutils/docs/dev/testing.txt @@ -38,29 +38,25 @@ Python 3, ``cd`` to the package's root directory and do:: Python Versions =============== -A docutils release has a commitment to support a minimum version and -beyond. Before a release is cut, tests must pass in all supported python -versions. +A docutils release has a commitment to support a minimum version and beyond. +Before a release is cut, tests must pass in all supported Python versions. -The Docutils 0.15 release supports Python 2.6 or later. +The Docutils 0.15 release supports Python 2.7 and Python 3.5 or later. -Therefore, you should install python 2.6, 2.7 as well as 3.3 up to the -latest Python (3.5 at the time of this writing) installed and always run the -tests on all of them. In a pinch, the edge cases (2.6, and 3.5) should cover -most of it. +Therefore, you should install Python 2.7 as well as 3.5 up to the latest Python +(3.7 at the time of this writing) installed and always run the tests on all of +them. In a pinch, the edge cases (2.7, and 3.7) should cover most of it. Good resources covering the differences between Python versions: -* `What's New in Python 2.6`__ -* `What's New in Python 2.7`__ -* `What's New in Python 3.3`__ -* `What's New in Python 3.4`__ +* `What's New in Python 3.5`__ +* `What's New in Python 3.6`__ +* `What's New in Python 3.7`__ * `PEP 290 - Code Migration and Modernization`__ -__ http://docs.python.org/whatsnew/2.6.html -__ http://docs.python.org/whatsnew/2.7.html -__ https://docs.python.org/3/whatsnew/3.3.html -__ https://docs.python.org/3/whatsnew/3.4.html +__ https://docs.python.org/3/whatsnew/3.5.html +__ https://docs.python.org/3/whatsnew/3.6.html +__ https://docs.python.org/3/whatsnew/3.7.html __ http://www.python.org/peps/pep-0290.html .. _Python Check-in Policies: http://www.python.org/dev/tools.html @@ -76,20 +72,19 @@ Testing across multiple python versions test multiple python versions:: # assuming your system runs 2.7.x - pyenv install 2.6.9 - pyenv install 3.3.6 - pyenv install 3.4.3 - pyenv global system 2.6.9 3.3.6 3.4.3 + pyenv install 3.5.7 + pyenv install 3.6.9 + pyenv install 3.7.3 + pyenv global system 3.5.7 3.6.9 3.7.3 # reset your shims rm -rf ~/.pyenv/shims && pyenv rehash -This will give you ``python2.6``, ``python2.7``, ``python3.3`` and -``python3.4``. Along with that, ``pip2.6``, ``pip2.7`` and so on. +This will give you ``python2.7`` and ``python3.5`` through ``python3.7``. +You will also get ``pip2.7``, ``pip3.5``, etc. -To save time, you can use `tox`_. To -install tox, you can use ``easy_install tox`` or ``pip install tox``. -From shell:: +To save time, you can use `tox`_. To install tox, run ``pip install tox``. +Once installed, from shell:: cd docutils tox diff --git a/docutils/docutils/frontend.py b/docutils/docutils/frontend.py index f5f7046cb..a297b9c91 100644 --- a/docutils/docutils/frontend.py +++ b/docutils/docutils/frontend.py @@ -777,7 +777,7 @@ Skipping "%s" configuration file. except IOError: continue try: - if sys.version_info < (3,2): + if sys.version_info < (3, 0): CP.RawConfigParser.readfp(self, fp, filename) else: CP.RawConfigParser.read_file(self, fp, filename) diff --git a/docutils/docutils/utils/code_analyzer.py b/docutils/docutils/utils/code_analyzer.py index eedf621b0..218d8dbf6 100644 --- a/docutils/docutils/utils/code_analyzer.py +++ b/docutils/docutils/utils/code_analyzer.py @@ -18,7 +18,7 @@ try: from pygments.lexers import get_lexer_by_name from pygments.formatters.html import _get_ttype_class with_pygments = True -except (ImportError, SyntaxError): # pygments 2.0.1 fails with Py 3.1 and 3.2 +except ImportError: with_pygments = False # Filter the following token types from the list of class arguments: diff --git a/docutils/docutils/writers/odf_odt/__init__.py b/docutils/docutils/writers/odf_odt/__init__.py index 6ecd610c7..9bc0fba8d 100644 --- a/docutils/docutils/writers/odf_odt/__init__.py +++ b/docutils/docutils/writers/odf_odt/__init__.py @@ -22,10 +22,12 @@ import re import copy import itertools import weakref + try: import locale # module missing in Jython except ImportError: pass + import docutils from docutils import frontend, nodes, utils, writers, languages from docutils.readers import standalone @@ -91,6 +93,7 @@ if isinstance(etree.Element, type): else: _ElementInterface = etree._ElementInterface + class _ElementInterfaceWrapper(_ElementInterface): def __init__(self, tag, attrib=None): _ElementInterface.__init__(self, tag, attrib) @@ -302,7 +305,7 @@ def add_ns(tag, nsdict=CNSD): def ToString(et): outstream = StringIO() - if sys.version_info >= (3, 2): + if sys.version_info >= (3, 0): et.write(outstream, encoding="unicode") else: et.write(outstream) diff --git a/docutils/setup.py b/docutils/setup.py index ff7e4a9e6..b7c899516 100755 --- a/docutils/setup.py +++ b/docutils/setup.py @@ -123,7 +123,7 @@ what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60 'maintainer_email': 'doc...@li...', 'license': 'public domain, Python, 2-Clause BSD, GPL 3 (see COPYING.txt)', 'platforms': 'OS-independent', - 'python_requires': '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*', + 'python_requires': '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', 'package_dir': {'docutils': 'docutils', 'docutils.tools': 'tools'}, 'packages': ['docutils', @@ -199,7 +199,6 @@ classifiers = [ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', diff --git a/docutils/test/test_error_reporting.py b/docutils/test/test_error_reporting.py index 845927ca7..d62e6dbad 100644 --- a/docutils/test/test_error_reporting.py +++ b/docutils/test/test_error_reporting.py @@ -27,7 +27,6 @@ unless the minimal required Python version has this problem fixed. import unittest import sys, os -import codecs from io import StringIO, BytesIO import DocutilsTestSupport # must be imported before docutils @@ -35,15 +34,13 @@ from docutils import core, parsers, frontend, utils from docutils.utils.error_reporting import SafeString, ErrorString, ErrorOutput oldlocale = None -if sys.version_info < (3,0): # problems solved in py3k +if sys.version_info < (3, 0): # problems solved in py3k try: - import locale # module missing in Jython + import locale # module missing in Jython oldlocale = locale.getlocale() - # Why does getlocale return the defaultlocale in Python 3.2 ???? - # oldlocale = (None, None) # test suite runs without locale except ImportError: print ('cannot test error reporting with problematic locales,\n' - '`import locale` failed.') + '`import locale` failed.') # locales confirmed to use non-ASCII chars in the IOError message @@ -81,8 +78,6 @@ class SafeStringTests(unittest.TestCase): us = u'\xfc' # bytes(us) fails; str(us) fails in Python 2 be = Exception(bs) # unicode(be) fails ue = Exception(us) # bytes(ue) fails, str(ue) fails in Python 2; - # unicode(ue) fails in Python < 2.6 (issue2517_) - # .. _issue2517: http://bugs.python.org/issue2517 # wrapped test data: wbs = SafeString(bs) wus = SafeString(us) @@ -114,7 +109,7 @@ class SafeStringTests(unittest.TestCase): self.assertEqual(unicode(self.us), unicode(self.wus)) # unicode(self.be) fails self.assertEqual(unicode, type(unicode(self.wbe))) - # unicode(ue) fails in Python < 2.6 (issue2517_) + self.assertEqual(unicode, type(unicode(self.ue))) self.assertEqual(unicode, type(unicode(self.wue))) self.assertEqual(self.us, unicode(self.wue)) diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_tables.py b/docutils/test/test_parsers/test_rst/test_directives/test_tables.py index ed11b3ab2..a6a02f5fb 100755 --- a/docutils/test/test_parsers/test_rst/test_directives/test_tables.py +++ b/docutils/test/test_parsers/test_rst/test_directives/test_tables.py @@ -10,7 +10,8 @@ Tests for tables.py directives. from __init__ import DocutilsTestSupport -import os, sys +import os +import sys import csv import platform from docutils.parsers.rst.directives import tables @@ -33,21 +34,20 @@ if isinstance(unichr_exception, OverflowError): else: unichr_exception_string = str(unichr_exception) -# some error messages changed in Python 3.3: -# CPython has backported to 2.7.4, PyPy has not -# platform.python_implementation is new in 2.6 +# some error messages changed in Python 3.3, CPython has backported to 2.7.4, +# PyPy has not csv_eod_error_str = 'unexpected end of data' if sys.version_info < (2,7,4) or platform.python_implementation() == 'PyPy': csv_eod_error_str = 'newline inside string' # pypy adds a line number -if sys.version_info > (2, 6) and platform.python_implementation() == 'PyPy': +if sys.version_info > (2, 7) and platform.python_implementation() == 'PyPy': csv_eod_error_str = 'line 1: ' + csv_eod_error_str csv_unknown_url = "'bogus.csv'" -if sys.version_info < (3,3,2): +if sys.version_info < (3, 0): csv_unknown_url = "bogus.csv" + def null_bytes(): - import csv with open(utf_16_csv, 'rb') as f: csv_data = f.read() csv_data = unicode(csv_data, 'latin1').splitlines() diff --git a/docutils/test/test_utils.py b/docutils/test/test_utils.py index 07b62e11a..1be74aad5 100755 --- a/docutils/test/test_utils.py +++ b/docutils/test/test_utils.py @@ -9,14 +9,11 @@ Test module for utils/__init__.py. """ -import unittest -import sys +from io import StringIO import os +import unittest + from DocutilsTestSupport import docutils, utils, nodes -try: - from io import StringIO -except ImportError: # io is new in Python 2.6 - from StringIO import StringIO class ReporterTests(unittest.TestCase): diff --git a/docutils/test/test_writers/test_odt.py b/docutils/test/test_writers/test_odt.py index 4dcb784ec..74788eeb7 100755 --- a/docutils/test/test_writers/test_odt.py +++ b/docutils/test/test_writers/test_odt.py @@ -46,6 +46,7 @@ TEMP_FILE_PATH = 'functional/output/' INPUT_PATH = 'functional/input/' EXPECTED_PATH = 'functional/expected/' + class DocutilsOdtTestCase(DocutilsTestSupport.StandardTestCase): def process_test(self, input_filename, expected_filename, diff --git a/docutils/tools/buildhtml.py b/docutils/tools/buildhtml.py index 798dca04b..5cd8ef706 100755 --- a/docutils/tools/buildhtml.py +++ b/docutils/tools/buildhtml.py @@ -241,7 +241,7 @@ class Builder: writer_name=pub_struct.writer_name, settings=settings) except ApplicationError: - error = sys.exc_info()[1] # get exception in Python <2.6 and 3.x + error = sys.exc_info()[1] # get exception in Python 3.x errout.write(' %s\n' % ErrorString(error)) diff --git a/docutils/tox.ini b/docutils/tox.ini index 19892b732..0a13197e0 100644 --- a/docutils/tox.ini +++ b/docutils/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py33, py34, py35, py36, py37 +envlist = py{27,35,36,37} [testenv] commands = python test/alltests.py -- 2.21.0 |