summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-03-21 19:51:22 +0000
committerwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-03-21 19:51:22 +0000
commitad64cdfcfadce2ff0045a49575dc94e79abbdbeb (patch)
treeaccac10c78e04c854957b7f506c88929db2dc71b
parent03bf7675814fdd2228856bc7958509933bb5f4a8 (diff)
downloaddocutils-ad64cdfcfadce2ff0045a49575dc94e79abbdbeb.tar.gz
reverted r5032; breaks Python 2.2 compatibility
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@5033 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--docutils/core.py2
-rw-r--r--docutils/nodes.py2
-rw-r--r--test/DocutilsTestSupport.py8
-rwxr-xr-xtest/test_language.py4
-rwxr-xr-xtest/test_nodes.py2
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_raw.py6
-rwxr-xr-xtest/test_parsers/test_rst/test_enumerated_lists.py2
7 files changed, 13 insertions, 13 deletions
diff --git a/docutils/core.py b/docutils/core.py
index 82547f386..f68f74cea 100644
--- a/docutils/core.py
+++ b/docutils/core.py
@@ -245,7 +245,7 @@ class Publisher:
if self.settings.dump_pseudo_xml:
print >>sys.stderr, '\n::: Pseudo-XML:'
print >>sys.stderr, self.document.pformat().encode(
- 'ascii', 'backslashreplace')
+ 'raw_unicode_escape')
def report_Exception(self, error):
if isinstance(error, utils.SystemMessage):
diff --git a/docutils/nodes.py b/docutils/nodes.py
index 7d1fbc4da..ffb679b17 100644
--- a/docutils/nodes.py
+++ b/docutils/nodes.py
@@ -62,7 +62,7 @@ class Node:
return 1
def __str__(self):
- return self.__unicode__().encode('ascii', 'backslashreplace')
+ return self.__unicode__().encode('raw_unicode_escape')
def __unicode__(self):
# Override in subclass.
diff --git a/test/DocutilsTestSupport.py b/test/DocutilsTestSupport.py
index 5339c9213..24858c624 100644
--- a/test/DocutilsTestSupport.py
+++ b/test/DocutilsTestSupport.py
@@ -191,11 +191,11 @@ class CustomTestCase(StandardTestCase):
def compare_output(self, input, output, expected):
"""`input`, `output`, and `expected` should all be strings."""
if isinstance(input, UnicodeType):
- input = input.encode('ascii', 'backslashreplace')
+ input = input.encode('raw_unicode_escape')
if isinstance(output, UnicodeType):
- output = output.encode('ascii', 'backslashreplace')
+ output = output.encode('raw_unicode_escape')
if isinstance(expected, UnicodeType):
- expected = expected.encode('ascii', 'backslashreplace')
+ expected = expected.encode('raw_unicode_escape')
try:
self.assertEquals(output, expected)
except AssertionError, error:
@@ -807,7 +807,7 @@ class HtmlWriterPublishPartsTestCase(WriterPublishTestCase):
output = []
for key in keys:
output.append("%r: '''%s'''"
- % (key, parts[key].encode('ascii', 'backslashreplace')))
+ % (key, parts[key].encode('raw_unicode_escape')))
if output[-1].endswith("\n'''"):
output[-1] = output[-1][:-4] + "\\n'''"
return '{' + ',\n '.join(output) + '}\n'
diff --git a/test/test_language.py b/test/test_language.py
index 49f70e8a5..3f929bd05 100755
--- a/test/test_language.py
+++ b/test/test_language.py
@@ -146,7 +146,7 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase):
text = ('Module docutils.parsers.rst.languages.%s:\n %s'
% (self.language, '\n '.join(failures)))
if type(text) == UnicodeType:
- text = text.encode('ascii', 'backslashreplace')
+ text = text.encode('raw_unicode_escape')
self.fail(text)
def test_roles(self):
@@ -181,7 +181,7 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase):
text = ('Module docutils.parsers.rst.languages.%s:\n %s'
% (self.language, '\n '.join(failures)))
if type(text) == UnicodeType:
- text = text.encode('ascii', 'backslashreplace')
+ text = text.encode('raw_unicode_escape')
self.fail(text)
diff --git a/test/test_nodes.py b/test/test_nodes.py
index 6ad2f19d6..5c419f09b 100755
--- a/test/test_nodes.py
+++ b/test/test_nodes.py
@@ -31,7 +31,7 @@ class TextTests(unittest.TestCase):
def test_unicode(self):
self.assertEquals(unicode(self.unicode_text), u'Möhren')
- self.assertEquals(str(self.unicode_text), 'M\\xf6hren')
+ self.assertEquals(str(self.unicode_text), 'M\xf6hren')
def test_astext(self):
self.assertEquals(self.text.astext(), 'Line 1.\nLine 2.')
diff --git a/test/test_parsers/test_rst/test_directives/test_raw.py b/test/test_parsers/test_rst/test_directives/test_raw.py
index 80b45d1fb..63cee274f 100755
--- a/test/test_parsers/test_rst/test_directives/test_raw.py
+++ b/test/test_parsers/test_rst/test_directives/test_raw.py
@@ -96,10 +96,10 @@ totest['raw'] = [
<document source="test data">
<raw format="html" source="%s" xml:space="preserve">
"Treat", "Quantity", "Description"
- "Albatr\\xb0\\xdf", 2.99, "\\xa1On a \\u03c3\\u03c4\\u03b9\\u03ba!"
- "Crunchy Frog", 1.49, "If we took the b\\xf6nes out, it wouldn\\u2019t be
+ "Albatr\xb0\xdf", 2.99, "\xa1On a \\u03c3\\u03c4\\u03b9\\u03ba!"
+ "Crunchy Frog", 1.49, "If we took the b\xf6nes out, it wouldn\\u2019t be
crunchy, now would it?"
- "Gannet Ripple", 1.99, "\\xbfOn a \\u03c3\\u03c4\\u03b9\\u03ba?"
+ "Gannet Ripple", 1.99, "\xbfOn a \\u03c3\\u03c4\\u03b9\\u03ba?"
""" % utf_16_file_rel],
["""\
Raw input file is UTF-16-encoded, and is not valid ASCII.
diff --git a/test/test_parsers/test_rst/test_enumerated_lists.py b/test/test_parsers/test_rst/test_enumerated_lists.py
index f5177122f..38bf2268c 100755
--- a/test/test_parsers/test_rst/test_enumerated_lists.py
+++ b/test/test_parsers/test_rst/test_enumerated_lists.py
@@ -679,7 +679,7 @@ Princeton, NJ.
<paragraph>
Using a non-breaking space as a workaround:
<paragraph>
- A.\\xa0Einstein was a great influence on
+ A.\xa0Einstein was a great influence on
B. Physicist, who was a colleague of
C. Chemist. They all worked in
Princeton, NJ.