From: <mi...@us...> - 2019-09-18 10:13:02
|
Revision: 8393 http://sourceforge.net/p/docutils/code/8393 Author: milde Date: 2019-09-18 10:13:00 +0000 (Wed, 18 Sep 2019) Log Message: ----------- Future warning for Node.traverse(). Modified Paths: -------------- trunk/docutils/HISTORY.txt trunk/docutils/RELEASE-NOTES.txt trunk/docutils/docutils/nodes.py trunk/docutils/docutils/transforms/universal.py Modified: trunk/docutils/HISTORY.txt =================================================================== --- trunk/docutils/HISTORY.txt 2019-09-17 08:41:21 UTC (rev 8392) +++ trunk/docutils/HISTORY.txt 2019-09-18 10:13:00 UTC (rev 8393) @@ -20,7 +20,7 @@ * General - - Dropped support for Python 2.6, 3.3 and 3.4 (work in progress). + - Dropped support for Python 2.6, 3.3 and 3.4 - Docutils now supports Python 2.7 and Python 3.5+ natively (without conversion by ``2to3``). - Keep `backslash escapes`__ in the document tree. Backslash characters in @@ -30,19 +30,25 @@ __ http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#escaping-mechanism -* docutils/utils/__init__.py +* docutils/nodes.py - - unescape() definition moved to `nodes` to avoid circular import - dependency. Fixes [ 366 ]. + - Speed up Node.next_node(). + - Warn about Node.traverse() returning an iterator instead of a list + in future. +* docutils/statemachine.py + + - Patch [ 158 ]: Speed up patterns by saving compiled versions (eric89gxl) + * docutils/transforms/universal.py - Fix [ 332 ]: Standard backslash escape for smartquotes. - Fix [ 342 ]: No escape in roles descending from `inline literal`. -* docutils/statemachine.py +* docutils/utils/__init__.py - - Patch [ 158 ]: Speed up patterns by saving compiled versions (eric89gxl) + - unescape() definition moved to `nodes` to avoid circular import + dependency. Fixes [ 366 ]. * docutils/writers/latex2e/__init__.py: @@ -79,6 +85,7 @@ - Fix [ 359 ]: Test suite failes on Python 3.8. odt xml sorting. Use ElementTree instead of minidom. + Release 0.15.1 (2019-07-24) =========================== Modified: trunk/docutils/RELEASE-NOTES.txt =================================================================== --- trunk/docutils/RELEASE-NOTES.txt 2019-09-17 08:41:21 UTC (rev 8392) +++ trunk/docutils/RELEASE-NOTES.txt 2019-09-18 10:13:00 UTC (rev 8393) @@ -23,16 +23,18 @@ ============== * The "latex" writer will wrap admonitions in a "DUclass" environment. - If your custom stylesheets modify "\DUadmonition" to style admonitions, - you will need to adapt them after upgrading to versions > 0.16. + Stylesheets modifying "\DUadmonition" will need to adapt. + Styling commands using ``\docutilsrole`` prefix will be ignored in versions > 0.16 (see `Generating LaTeX with Docutils`__). - + __ docs/user/latex.html#classes * Remove the `handle_io_errors` option from io.FileInput/Output. Used by Sphinx up to version 1.3.1, fixed in 1.3.2 (Nov 29, 2015). +* Node.traverse() will return an iterator instead of a list. + * Remove `utils.unique_combinations` (obsoleted by `itertools.combinations`). * The default HTML writer "html" with frontend ``rst2html.py`` may change Modified: trunk/docutils/docutils/nodes.py =================================================================== --- trunk/docutils/docutils/nodes.py 2019-09-17 08:41:21 UTC (rev 8392) +++ trunk/docutils/docutils/nodes.py 2019-09-18 10:13:00 UTC (rev 8393) @@ -33,6 +33,28 @@ unicode = str # noqa basestring = str # noqa + +class _traversal_list(): + # auxiliary class to report a FutureWarning + + def __init__(self, iterable): + self.nodes = list(iterable) + + def __getattr__(self, name): + msg = ("The iterable returned by Node.traverse()\n " + "will become an iterator instead of a list in " + "Docutils > 0.16.") + warnings.warn(msg, FutureWarning, stacklevel=2) + return getattr(self.nodes, name) + + def __iter__(self): + return iter(self.nodes) + + def __len__(self): + # used in Python 2.7 when typecasting to `list` or `tuple` + return len(self.nodes) + + # ============================== # Functional Node Base Classes # ============================== @@ -254,7 +276,7 @@ # value, the implementation returned a list up to v. 0.15. Some 3rd # party code still relies on this (e.g. Sphinx as of 2019-09-07). # Therefore, let's return a list until this is sorted out: - return list(self._traverse(condition, include_self, + return _traversal_list(self._traverse(condition, include_self, descend, siblings, ascend)) def _traverse(self, condition=None, include_self=True, descend=True, Modified: trunk/docutils/docutils/transforms/universal.py =================================================================== --- trunk/docutils/docutils/transforms/universal.py 2019-09-17 08:41:21 UTC (rev 8392) +++ trunk/docutils/docutils/transforms/universal.py 2019-09-18 10:13:00 UTC (rev 8393) @@ -144,7 +144,7 @@ default_priority = 870 def apply(self): - for node in list(self.document.traverse(nodes.system_message)): + for node in tuple(self.document.traverse(nodes.system_message)): if node['level'] < self.document.reporter.report_level: node.parent.remove(node) @@ -176,7 +176,7 @@ def apply(self): if self.document.settings.strip_comments: - for node in list(self.document.traverse(nodes.comment)): + for node in tuple(self.document.traverse(nodes.comment)): node.parent.remove(node) @@ -194,9 +194,9 @@ if self.document.settings.strip_elements_with_classes: self.strip_elements = set( self.document.settings.strip_elements_with_classes) - # Iterate over a list as removing the current node + # Iterate over a tuple as removing the current node # corrupts the iterator returned by `traverse`: - for node in list(self.document.traverse(self.check_classes)): + for node in tuple(self.document.traverse(self.check_classes)): node.parent.remove(node) if not self.document.settings.strip_classes: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |