79 lines
2.3 KiB
Diff
79 lines
2.3 KiB
Diff
From 035c67105f3cbd12ccf6a708f38f1f7f5a17c699 Mon Sep 17 00:00:00 2001
|
|
From: Stephen Finucane <stephen@that.guru>
|
|
Date: Wed, 20 Nov 2019 00:11:04 +0700
|
|
Subject: [PATCH 20/26] py3: Handle 'StringIO' to 'io' transition.
|
|
|
|
This isn't so much a rename as a migration, since things don't do the
|
|
same thing.
|
|
|
|
Based on patch by: Stephen Finucane <stephen@that.guru>
|
|
|
|
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8368 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
|
|
Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>
|
|
---
|
|
docutils/writers/docutils_xml.py | 7 ++++++-
|
|
test/test_utils.py | 1 +
|
|
test/test_writers/test_docutils_xml.py | 7 ++++++-
|
|
3 files changed, 13 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/docutils/writers/docutils_xml.py b/docutils/writers/docutils_xml.py
|
|
index 60ee07b..51ad6bd 100644
|
|
--- a/docutils/writers/docutils_xml.py
|
|
+++ b/docutils/writers/docutils_xml.py
|
|
@@ -25,11 +25,16 @@ if "_xmlplus" in xml.__path__[0]: # PyXML sub-module
|
|
xml.__path__.reverse() # If both are available, prefer stdlib over PyXML
|
|
|
|
import xml.sax.saxutils
|
|
-from StringIO import StringIO
|
|
|
|
import docutils
|
|
from docutils import frontend, writers, nodes
|
|
|
|
+if sys.version_info >= (3, 0):
|
|
+ from io import StringIO # noqa
|
|
+else:
|
|
+ from StringIO import StringIO # noqa
|
|
+
|
|
+
|
|
if sys.version_info >= (3, 0):
|
|
unicode = str # noqa
|
|
|
|
diff --git a/test/test_utils.py b/test/test_utils.py
|
|
index 59e29c8..cb1ec9e 100755
|
|
--- a/test/test_utils.py
|
|
+++ b/test/test_utils.py
|
|
@@ -13,6 +13,7 @@ import unittest
|
|
import sys
|
|
import os
|
|
from DocutilsTestSupport import docutils, utils, nodes
|
|
+
|
|
try:
|
|
from io import StringIO
|
|
except ImportError: # io is new in Python 2.6
|
|
diff --git a/test/test_writers/test_docutils_xml.py b/test/test_writers/test_docutils_xml.py
|
|
index 5a6cda3..ced3473 100755
|
|
--- a/test/test_writers/test_docutils_xml.py
|
|
+++ b/test/test_writers/test_docutils_xml.py
|
|
@@ -15,12 +15,17 @@ Test for docutils XML writer.
|
|
"""
|
|
from __future__ import absolute_import
|
|
|
|
-from StringIO import StringIO
|
|
+import sys
|
|
|
|
from . import DocutilsTestSupport # must be imported before docutils
|
|
import docutils
|
|
import docutils.core
|
|
|
|
+if sys.version_info >= (3, 0):
|
|
+ from io import StringIO
|
|
+else:
|
|
+ from StringIO import StringIO
|
|
+
|
|
# sample strings
|
|
# --------------
|
|
|
|
--
|
|
2.24.0.375.geb5ae68d41
|
|
|