|
From: <mi...@us...> - 2021-06-30 07:47:33
|
Revision: 8782
http://sourceforge.net/p/docutils/code/8782
Author: milde
Date: 2021-06-30 07:47:30 +0000 (Wed, 30 Jun 2021)
Log Message:
-----------
Do not use deprecated "rawsource" argument when creating node.Text instances.
The "rawsource" argument of ``nodes.Text.__init__`` is ignored and deprecated.
Fix the documentation of nodes.Text.__new__().
Modified Paths:
--------------
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/test/test_nodes.py
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2021-06-26 22:17:04 UTC (rev 8781)
+++ trunk/docutils/docutils/nodes.py 2021-06-30 07:47:30 UTC (rev 8782)
@@ -381,18 +381,16 @@
if sys.version_info > (3, 0):
def __new__(cls, data, rawsource=None):
- """Prevent the rawsource argument from propagating to str."""
+ """Assert that `data` is not an array of bytes."""
if isinstance(data, bytes):
raise TypeError('expecting str data, not bytes')
return reprunicode.__new__(cls, data)
else:
def __new__(cls, data, rawsource=None):
- """Prevent the rawsource argument from propagating to str."""
return reprunicode.__new__(cls, data)
- def __init__(self, data, rawsource=''):
- self.rawsource = rawsource
- """The raw text from which this element was constructed."""
+ def __init__(self, data, rawsource=None):
+ """The `rawsource` argument is ignored and deprecated."""
def shortrepr(self, maxlen=18):
data = self
@@ -419,7 +417,7 @@
# an infinite loop
def copy(self):
- return self.__class__(reprunicode(self), rawsource=self.rawsource)
+ return self.__class__(reprunicode(self))
def deepcopy(self):
return self.copy()
@@ -444,10 +442,10 @@
# taken care of by UserString.
def rstrip(self, chars=None):
- return self.__class__(reprunicode.rstrip(self, chars), self.rawsource)
+ return self.__class__(reprunicode.rstrip(self, chars))
def lstrip(self, chars=None):
- return self.__class__(reprunicode.lstrip(self, chars), self.rawsource)
+ return self.__class__(reprunicode.lstrip(self, chars))
class Element(Node):
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2021-06-26 22:17:04 UTC (rev 8781)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2021-06-30 07:47:30 UTC (rev 8782)
@@ -346,7 +346,7 @@
node += nodes.inline(value, value, classes=classes)
else:
# insert as Text to decrease the verbosity of the output
- node += nodes.Text(value, value)
+ node += nodes.Text(value)
return [node], []
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2021-06-26 22:17:04 UTC (rev 8781)
+++ trunk/docutils/docutils/parsers/rst/states.py 2021-06-30 07:47:30 UTC (rev 8782)
@@ -1043,7 +1043,7 @@
self.implicit_inline(text[match.end():], lineno))
except MarkupMismatch:
pass
- return [nodes.Text(text, unescape(text, True))]
+ return [nodes.Text(text)]
dispatch = {'*': emphasis,
'**': strong,
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2021-06-26 22:17:04 UTC (rev 8781)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2021-06-30 07:47:30 UTC (rev 8782)
@@ -523,8 +523,7 @@
if len(authornames) > 1:
break
authornames = (name.strip() for name in authornames)
- authors = [[nodes.Text(name, utils.unescape(name, True))]
- for name in authornames if name]
+ authors = [[nodes.Text(name)] for name in authornames if name]
return authors
def authors_from_bullet_list(self, field):
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2021-06-26 22:17:04 UTC (rev 8781)
+++ trunk/docutils/docutils/transforms/universal.py 2021-06-30 07:47:30 UTC (rev 8782)
@@ -321,7 +321,6 @@
attr=self.smartquotes_action, language=lang)
for txtnode, newtext in zip(txtnodes, teacher):
- txtnode.parent.replace(txtnode, nodes.Text(newtext,
- rawsource=txtnode.rawsource))
+ txtnode.parent.replace(txtnode, nodes.Text(newtext))
self.unsupported_languages = set() # reset
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2021-06-26 22:17:04 UTC (rev 8781)
+++ trunk/docutils/test/test_nodes.py 2021-06-30 07:47:30 UTC (rev 8782)
@@ -58,7 +58,7 @@
self.assertEqual(self.text.pformat(), u'Line 1.\nLine 2.\n')
def test_strip(self):
- text = nodes.Text(' was noch ', r' \was\ noch \\ ')
+ text = nodes.Text(' was noch ')
stripped = text.lstrip().rstrip()
stripped2 = text.lstrip(' wahn').rstrip(' wahn')
self.assertEqual(stripped, u'was noch')
@@ -330,7 +330,7 @@
self.assertEqual(len(parent), 5)
def test_unicode(self):
- node = nodes.Element(u'Möhren', nodes.Text(u'Möhren', u'Möhren'))
+ node = nodes.Element(u'Möhren', nodes.Text(u'Möhren'))
self.assertEqual(unicode(node), u'<Element>Möhren</Element>')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|