diff mbox

[U-Boot,v2,07/10] patman: Fix doctest StringIO import for python 3.x

Message ID 20160927150358.6248-8-paul.burton@imgtec.com
State Accepted
Commit f5d44b9bae64d4fc347c537e6d5f13d630eb858d
Delegated to: Simon Glass
Headers show

Commit Message

Paul Burton Sept. 27, 2016, 3:03 p.m. UTC
In python 3.x StringIO is no longer a module, and the class can instead
be found in the io module. Adjust the code in the doctest input to
account for both.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>

---

Changes in v2:
- New patch, need found by running --test.

 tools/patman/settings.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Simon Glass Sept. 27, 2016, 5:55 p.m. UTC | #1
On 27 September 2016 at 09:03, Paul Burton <paul.burton@imgtec.com> wrote:
> In python 3.x StringIO is no longer a module, and the class can instead
> be found in the io module. Adjust the code in the doctest input to
> account for both.
>
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
>
> ---
>
> Changes in v2:
> - New patch, need found by running --test.
>
>  tools/patman/settings.py | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>
Simon Glass Oct. 6, 2016, 2:03 a.m. UTC | #2
On 27 September 2016 at 11:55, Simon Glass <sjg@chromium.org> wrote:
> On 27 September 2016 at 09:03, Paul Burton <paul.burton@imgtec.com> wrote:
>> In python 3.x StringIO is no longer a module, and the class can instead
>> be found in the io module. Adjust the code in the doctest input to
>> account for both.
>>
>> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
>>
>> ---
>>
>> Changes in v2:
>> - New patch, need found by running --test.
>>
>>  tools/patman/settings.py | 13 ++++++++-----
>>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!
diff mbox

Patch

diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 7ef0ab0..5f207f5 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -36,7 +36,10 @@  class _ProjectConfigParser(ConfigParser.SafeConfigParser):
     - Merge general default settings/aliases with project-specific ones.
 
     # Sample config used for tests below...
-    >>> import StringIO
+    >>> try:
+    ...     from StringIO import StringIO
+    ... except ImportError:
+    ...     from io import StringIO
     >>> sample_config = '''
     ... [alias]
     ... me: Peter P. <likesspiders@example.com>
@@ -54,25 +57,25 @@  class _ProjectConfigParser(ConfigParser.SafeConfigParser):
 
     # Check to make sure that bogus project gets general alias.
     >>> config = _ProjectConfigParser("zzz")
-    >>> config.readfp(StringIO.StringIO(sample_config))
+    >>> config.readfp(StringIO(sample_config))
     >>> config.get("alias", "enemies")
     'Evil <evil@example.com>'
 
     # Check to make sure that alias gets overridden by project.
     >>> config = _ProjectConfigParser("sm")
-    >>> config.readfp(StringIO.StringIO(sample_config))
+    >>> config.readfp(StringIO(sample_config))
     >>> config.get("alias", "enemies")
     'Green G. <ugly@example.com>'
 
     # Check to make sure that settings get merged with project.
     >>> config = _ProjectConfigParser("linux")
-    >>> config.readfp(StringIO.StringIO(sample_config))
+    >>> config.readfp(StringIO(sample_config))
     >>> sorted(config.items("settings"))
     [('am_hero', 'True'), ('process_tags', 'False')]
 
     # Check to make sure that settings works with unknown project.
     >>> config = _ProjectConfigParser("unknown")
-    >>> config.readfp(StringIO.StringIO(sample_config))
+    >>> config.readfp(StringIO(sample_config))
     >>> sorted(config.items("settings"))
     [('am_hero', 'True')]
     """