Tim Lauridsen c48e3f
Index: iniparse/__init__.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- iniparse/__init__.py	(revision 146)
Tim Lauridsen c48e3f
+++ iniparse/__init__.py	(working copy)
Tim Lauridsen c48e3f
@@ -3,17 +3,17 @@
Tim Lauridsen c48e3f
 # Copyright (c) 2007 Tim Lauridsen <tla@rasmil.dk>
Tim Lauridsen c48e3f
 # All Rights Reserved.  See LICENSE-PSF & LICENSE for details.
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
-from ini import INIConfig, change_comment_syntax
Tim Lauridsen c48e3f
-from config import BasicConfig, ConfigNamespace
Tim Lauridsen c48e3f
-from compat import RawConfigParser, ConfigParser, SafeConfigParser
Tim Lauridsen c48e3f
-from utils import tidy
Tim Lauridsen c48e3f
+from .ini import INIConfig, change_comment_syntax
Tim Lauridsen c48e3f
+from .config import BasicConfig, ConfigNamespace
Tim Lauridsen c48e3f
+from .compat import RawConfigParser, ConfigParser, SafeConfigParser
Tim Lauridsen c48e3f
+from .utils import tidy
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
-from ConfigParser import DuplicateSectionError,    \
Tim Lauridsen c48e3f
-                  NoSectionError, NoOptionError,   \
Tim Lauridsen c48e3f
-                  InterpolationMissingOptionError, \
Tim Lauridsen c48e3f
-                  InterpolationDepthError,         \
Tim Lauridsen c48e3f
-                  InterpolationSyntaxError,        \
Tim Lauridsen c48e3f
-                  DEFAULTSECT, MAX_INTERPOLATION_DEPTH
Tim Lauridsen c48e3f
+from .configparser import DuplicateSectionError,    \
Tim Lauridsen c48e3f
+                   NoSectionError, NoOptionError,   \
Tim Lauridsen c48e3f
+                   InterpolationMissingOptionError, \
Tim Lauridsen c48e3f
+                   InterpolationDepthError,         \
Tim Lauridsen c48e3f
+                   InterpolationSyntaxError,        \
Tim Lauridsen c48e3f
+                   DEFAULTSECT, MAX_INTERPOLATION_DEPTH
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 __all__ = [
Tim Lauridsen c48e3f
     'BasicConfig', 'ConfigNamespace',
Tim Lauridsen c48e3f
Index: iniparse/compat.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- iniparse/compat.py	(revision 146)
Tim Lauridsen c48e3f
+++ iniparse/compat.py	(working copy)
Tim Lauridsen c48e3f
@@ -12,20 +12,22 @@
Tim Lauridsen c48e3f
 """
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 import re
Tim Lauridsen c48e3f
-from ConfigParser import DuplicateSectionError,    \
Tim Lauridsen c48e3f
-                  NoSectionError, NoOptionError,   \
Tim Lauridsen c48e3f
-                  InterpolationMissingOptionError, \
Tim Lauridsen c48e3f
-                  InterpolationDepthError,         \
Tim Lauridsen c48e3f
-                  InterpolationSyntaxError,        \
Tim Lauridsen c48e3f
-                  DEFAULTSECT, MAX_INTERPOLATION_DEPTH
Tim Lauridsen c48e3f
+from .configparser import DuplicateSectionError,    \
Tim Lauridsen c48e3f
+                   NoSectionError, NoOptionError,   \
Tim Lauridsen c48e3f
+                   InterpolationMissingOptionError, \
Tim Lauridsen c48e3f
+                   InterpolationDepthError,         \
Tim Lauridsen c48e3f
+                   InterpolationSyntaxError,        \
Tim Lauridsen c48e3f
+                   DEFAULTSECT, MAX_INTERPOLATION_DEPTH
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 # These are imported only for compatiability.
Tim Lauridsen c48e3f
 # The code below does not reference them directly.
Tim Lauridsen c48e3f
-from ConfigParser import Error, InterpolationError, \
Tim Lauridsen c48e3f
-                  MissingSectionHeaderError, ParsingError
Tim Lauridsen c48e3f
+from .configparser import Error, InterpolationError, \
Tim Lauridsen c48e3f
+                   MissingSectionHeaderError, ParsingError
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
-import ini
Tim Lauridsen c48e3f
+import six
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
+from . import ini
Tim Lauridsen c48e3f
+
Tim Lauridsen c48e3f
 class RawConfigParser(object):
Tim Lauridsen c48e3f
     def __init__(self, defaults=None, dict_type=dict):
Tim Lauridsen c48e3f
         if dict_type != dict:
Tim Lauridsen c48e3f
@@ -56,7 +58,7 @@
Tim Lauridsen c48e3f
         # The default section is the only one that gets the case-insensitive
Tim Lauridsen c48e3f
         # treatment - so it is special-cased here.
Tim Lauridsen c48e3f
         if section.lower() == "default":
Tim Lauridsen c48e3f
-            raise ValueError, 'Invalid section name: %s' % section
Tim Lauridsen c48e3f
+            raise ValueError('Invalid section name: %s' % section)
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
         if self.has_section(section):
Tim Lauridsen c48e3f
             raise DuplicateSectionError(section)
Tim Lauridsen c48e3f
@@ -88,7 +90,7 @@
Tim Lauridsen c48e3f
         filename may also be given.
Tim Lauridsen c48e3f
         """
Tim Lauridsen c48e3f
         files_read = []
Tim Lauridsen c48e3f
-        if isinstance(filenames, basestring):
Tim Lauridsen c48e3f
+        if isinstance(filenames, six.string_types):
Tim Lauridsen c48e3f
             filenames = [filenames]
Tim Lauridsen c48e3f
         for filename in filenames:
Tim Lauridsen c48e3f
             try:
Tim Lauridsen c48e3f
@@ -143,7 +145,7 @@
Tim Lauridsen c48e3f
     def getboolean(self, section, option):
Tim Lauridsen c48e3f
         v = self.get(section, option)
Tim Lauridsen c48e3f
         if v.lower() not in self._boolean_states:
Tim Lauridsen c48e3f
-            raise ValueError, 'Not a boolean: %s' % v
Tim Lauridsen c48e3f
+            raise ValueError('Not a boolean: %s' % v)
Tim Lauridsen c48e3f
         return self._boolean_states[v.lower()]
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     def has_option(self, section, option):
Tim Lauridsen c48e3f
@@ -234,7 +236,7 @@
Tim Lauridsen c48e3f
             if "%(" in value:
Tim Lauridsen c48e3f
                 try:
Tim Lauridsen c48e3f
                     value = value % vars
Tim Lauridsen c48e3f
-                except KeyError, e:
Tim Lauridsen c48e3f
+                except KeyError as e:
Tim Lauridsen c48e3f
                     raise InterpolationMissingOptionError(
Tim Lauridsen c48e3f
                         option, section, rawval, e.args[0])
Tim Lauridsen c48e3f
             else:
Tim Lauridsen c48e3f
@@ -283,7 +285,7 @@
Tim Lauridsen c48e3f
     _badpercent_re = re.compile(r"%[^%]|%$")
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     def set(self, section, option, value):
Tim Lauridsen c48e3f
-        if not isinstance(value, basestring):
Tim Lauridsen c48e3f
+        if not isinstance(value, six.string_types):
Tim Lauridsen c48e3f
             raise TypeError("option values must be strings")
Tim Lauridsen c48e3f
         # check for bad percent signs:
Tim Lauridsen c48e3f
         # first, replace all "good" interpolations
Tim Lauridsen c48e3f
Index: iniparse/config.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- iniparse/config.py	(revision 146)
Tim Lauridsen c48e3f
+++ iniparse/config.py	(working copy)
Tim Lauridsen c48e3f
@@ -143,7 +143,7 @@
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     >>> n.aaa = 42
Tim Lauridsen c48e3f
     >>> del n.x
Tim Lauridsen c48e3f
-    >>> print n
Tim Lauridsen c48e3f
+    >>> print(n)
Tim Lauridsen c48e3f
     aaa = 42
Tim Lauridsen c48e3f
     name.first = paramjit
Tim Lauridsen c48e3f
     name.last = oberoi
Tim Lauridsen c48e3f
@@ -152,7 +152,7 @@
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     >>> isinstance(n.name, ConfigNamespace)
Tim Lauridsen c48e3f
     True
Tim Lauridsen c48e3f
-    >>> print n.name
Tim Lauridsen c48e3f
+    >>> print(n.name)
Tim Lauridsen c48e3f
     first = paramjit
Tim Lauridsen c48e3f
     last = oberoi
Tim Lauridsen c48e3f
     >>> sorted(list(n.name))
Tim Lauridsen c48e3f
@@ -160,7 +160,7 @@
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     Finally, values can be read from a file as follows:
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
-    >>> from StringIO import StringIO
Tim Lauridsen c48e3f
+    >>> from six import StringIO
Tim Lauridsen c48e3f
     >>> sio = StringIO('''
Tim Lauridsen c48e3f
     ... # comment
Tim Lauridsen c48e3f
     ... ui.height = 100
Tim Lauridsen c48e3f
@@ -171,7 +171,7 @@
Tim Lauridsen c48e3f
     ... ''')
Tim Lauridsen c48e3f
     >>> n = BasicConfig()
Tim Lauridsen c48e3f
     >>> n._readfp(sio)
Tim Lauridsen c48e3f
-    >>> print n
Tim Lauridsen c48e3f
+    >>> print(n)
Tim Lauridsen c48e3f
     complexity = medium
Tim Lauridsen c48e3f
     data.secret.password = goodness=gracious me
Tim Lauridsen c48e3f
     have_python
Tim Lauridsen c48e3f
@@ -199,7 +199,7 @@
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     def __str__(self, prefix=''):
Tim Lauridsen c48e3f
         lines = []
Tim Lauridsen c48e3f
-        keys = self._data.keys()
Tim Lauridsen c48e3f
+        keys = list(self._data.keys())
Tim Lauridsen c48e3f
         keys.sort()
Tim Lauridsen c48e3f
         for name in keys:
Tim Lauridsen c48e3f
             value = self._data[name]
Tim Lauridsen c48e3f
@@ -258,7 +258,7 @@
Tim Lauridsen c48e3f
     >>> n.ui.display_clock = True
Tim Lauridsen c48e3f
     >>> n.ui.display_qlength = True
Tim Lauridsen c48e3f
     >>> n.ui.width = 150
Tim Lauridsen c48e3f
-    >>> print n
Tim Lauridsen c48e3f
+    >>> print(n)
Tim Lauridsen c48e3f
     playlist.expand_playlist = True
Tim Lauridsen c48e3f
     ui.display_clock = True
Tim Lauridsen c48e3f
     ui.display_qlength = True
Tim Lauridsen c48e3f
@@ -267,7 +267,7 @@
Tim Lauridsen c48e3f
     >>> from iniparse import ini
Tim Lauridsen c48e3f
     >>> i = ini.INIConfig()
Tim Lauridsen c48e3f
     >>> update_config(i, n)
Tim Lauridsen c48e3f
-    >>> print i
Tim Lauridsen c48e3f
+    >>> print(i)
Tim Lauridsen c48e3f
     [playlist]
Tim Lauridsen c48e3f
     expand_playlist = True
Tim Lauridsen c48e3f
     <blankline>
Tim Lauridsen c48e3f
@@ -277,7 +277,7 @@
Tim Lauridsen c48e3f
     width = 150
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     """
Tim Lauridsen c48e3f
-    for name in source:
Tim Lauridsen c48e3f
+    for name in sorted(source):
Tim Lauridsen c48e3f
         value = source[name]
Tim Lauridsen c48e3f
         if isinstance(value, ConfigNamespace):
Tim Lauridsen c48e3f
             if name in target:
Tim Lauridsen c48e3f
Index: iniparse/configparser.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- iniparse/configparser.py	(revision 0)
Tim Lauridsen c48e3f
+++ iniparse/configparser.py	(working copy)
Tim Lauridsen c48e3f
@@ -0,0 +1,7 @@
Tim Lauridsen c48e3f
+try:
Tim Lauridsen c48e3f
+    from ConfigParser import *
Tim Lauridsen c48e3f
+    # not all objects get imported with __all__
Tim Lauridsen c48e3f
+    from ConfigParser import Error, InterpolationMissingOptionError
Tim Lauridsen c48e3f
+except ImportError:
Tim Lauridsen c48e3f
+    from configparser import *
Tim Lauridsen c48e3f
+    from configparser import Error, InterpolationMissingOptionError
Tim Lauridsen c48e3f
Index: iniparse/ini.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- iniparse/ini.py	(revision 146)
Tim Lauridsen c48e3f
+++ iniparse/ini.py	(working copy)
Tim Lauridsen c48e3f
@@ -7,7 +7,7 @@
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 Example:
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
-    >>> from StringIO import StringIO
Tim Lauridsen c48e3f
+    >>> from six import StringIO
Tim Lauridsen c48e3f
     >>> sio = StringIO('''# configure foo-application
Tim Lauridsen c48e3f
     ... [foo]
Tim Lauridsen c48e3f
     ... bar1 = qualia
Tim Lauridsen c48e3f
@@ -16,14 +16,14 @@
Tim Lauridsen c48e3f
     ... special = 1''')
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     >>> cfg = INIConfig(sio)
Tim Lauridsen c48e3f
-    >>> print cfg.foo.bar1
Tim Lauridsen c48e3f
+    >>> print(cfg.foo.bar1)
Tim Lauridsen c48e3f
     qualia
Tim Lauridsen c48e3f
-    >>> print cfg['foo-ext'].special
Tim Lauridsen c48e3f
+    >>> print(cfg['foo-ext'].special)
Tim Lauridsen c48e3f
     1
Tim Lauridsen c48e3f
     >>> cfg.foo.newopt = 'hi!'
Tim Lauridsen c48e3f
     >>> cfg.baz.enabled = 0
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
-    >>> print cfg
Tim Lauridsen c48e3f
+    >>> print(cfg)
Tim Lauridsen c48e3f
     # configure foo-application
Tim Lauridsen c48e3f
     [foo]
Tim Lauridsen c48e3f
     bar1 = qualia
Tim Lauridsen c48e3f
@@ -42,10 +42,12 @@
Tim Lauridsen c48e3f
 # Backward-compatiable with ConfigParser
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 import re
Tim Lauridsen c48e3f
-from ConfigParser import DEFAULTSECT, ParsingError, MissingSectionHeaderError
Tim Lauridsen c48e3f
+from .configparser import DEFAULTSECT, ParsingError, MissingSectionHeaderError
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
-import config
Tim Lauridsen c48e3f
+import six
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
+from . import config
Tim Lauridsen c48e3f
+
Tim Lauridsen c48e3f
 class LineType(object):
Tim Lauridsen c48e3f
     line = None
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
@@ -278,6 +280,8 @@
Tim Lauridsen c48e3f
     value = property(get_value, set_value)
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     def __str__(self):
Tim Lauridsen c48e3f
+        for c in self.contents:
Tim Lauridsen c48e3f
+            pass#print(c.__str__())
Tim Lauridsen c48e3f
         s = [x.__str__() for x in self.contents]
Tim Lauridsen c48e3f
         return '\n'.join(s)
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
@@ -465,7 +469,7 @@
Tim Lauridsen c48e3f
         self._sections = {}
Tim Lauridsen c48e3f
         if defaults is None: defaults = {}
Tim Lauridsen c48e3f
         self._defaults = INISection(LineContainer(), optionxformsource=self)
Tim Lauridsen c48e3f
-        for name, value in defaults.iteritems():
Tim Lauridsen c48e3f
+        for name, value in defaults.items():
Tim Lauridsen c48e3f
             self._defaults[name] = value
Tim Lauridsen c48e3f
         if fp is not None:
Tim Lauridsen c48e3f
             self._readfp(fp)
Tim Lauridsen c48e3f
@@ -551,7 +555,7 @@
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
         for line in readline_iterator(fp):
Tim Lauridsen c48e3f
             # Check for BOM on first line
Tim Lauridsen c48e3f
-            if linecount == 0 and isinstance(line, unicode):
Tim Lauridsen c48e3f
+            if linecount == 0 and isinstance(line, six.text_type):
Tim Lauridsen c48e3f
                 if line[0] == u'\ufeff':
Tim Lauridsen c48e3f
                     line = line[1:]
Tim Lauridsen c48e3f
                     self._bom = True
Tim Lauridsen c48e3f
Index: iniparse/utils.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- iniparse/utils.py	(revision 146)
Tim Lauridsen c48e3f
+++ iniparse/utils.py	(working copy)
Tim Lauridsen c48e3f
@@ -1,5 +1,5 @@
Tim Lauridsen c48e3f
-import compat
Tim Lauridsen c48e3f
-from ini import LineContainer, EmptyLine
Tim Lauridsen c48e3f
+from . import compat
Tim Lauridsen c48e3f
+from .ini import LineContainer, EmptyLine
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 def tidy(cfg):
Tim Lauridsen c48e3f
     """Clean up blank lines.
Tim Lauridsen c48e3f
Index: tests/__init__.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- tests/__init__.py	(revision 146)
Tim Lauridsen c48e3f
+++ tests/__init__.py	(working copy)
Tim Lauridsen c48e3f
@@ -1,12 +1,12 @@
Tim Lauridsen c48e3f
 import unittest, doctest
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
-import test_ini
Tim Lauridsen c48e3f
-import test_misc
Tim Lauridsen c48e3f
-import test_fuzz
Tim Lauridsen c48e3f
-import test_compat
Tim Lauridsen c48e3f
-import test_unicode
Tim Lauridsen c48e3f
-import test_tidy
Tim Lauridsen c48e3f
-import test_multiprocessing
Tim Lauridsen c48e3f
+from . import test_ini
Tim Lauridsen c48e3f
+from . import test_misc
Tim Lauridsen c48e3f
+from . import test_fuzz
Tim Lauridsen c48e3f
+from . import test_compat
Tim Lauridsen c48e3f
+from . import test_unicode
Tim Lauridsen c48e3f
+from . import test_tidy
Tim Lauridsen c48e3f
+from . import test_multiprocessing
Tim Lauridsen c48e3f
 from iniparse import config
Tim Lauridsen c48e3f
 from iniparse import ini
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
Index: tests/test_compat.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- tests/test_compat.py	(revision 146)
Tim Lauridsen c48e3f
+++ tests/test_compat.py	(working copy)
Tim Lauridsen c48e3f
@@ -1,9 +1,16 @@
Tim Lauridsen c48e3f
 from iniparse import compat as ConfigParser
Tim Lauridsen c48e3f
-import StringIO
Tim Lauridsen c48e3f
+from six import StringIO
Tim Lauridsen c48e3f
+try:
Tim Lauridsen c48e3f
+    import UserDict
Tim Lauridsen c48e3f
+except ImportError:
Tim Lauridsen c48e3f
+    import collections as UserDict
Tim Lauridsen c48e3f
 import unittest
Tim Lauridsen c48e3f
-import UserDict
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
-from test import test_support
Tim Lauridsen c48e3f
+import sys
Tim Lauridsen c48e3f
+if sys.version_info[0] < 3:
Tim Lauridsen c48e3f
+    from test import test_support
Tim Lauridsen c48e3f
+else:
Tim Lauridsen c48e3f
+    from test import support as test_support
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 class SortedDict(UserDict.UserDict):
Tim Lauridsen c48e3f
     def items(self):
Tim Lauridsen c48e3f
@@ -35,7 +42,7 @@
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     def fromstring(self, string, defaults=None):
Tim Lauridsen c48e3f
         cf = self.newconfig(defaults)
Tim Lauridsen c48e3f
-        sio = StringIO.StringIO(string)
Tim Lauridsen c48e3f
+        sio = StringIO(string)
Tim Lauridsen c48e3f
         cf.readfp(sio)
Tim Lauridsen c48e3f
         return cf
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
@@ -161,7 +168,7 @@
Tim Lauridsen c48e3f
                          "No Section!\n")
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     def parse_error(self, exc, src):
Tim Lauridsen c48e3f
-        sio = StringIO.StringIO(src)
Tim Lauridsen c48e3f
+        sio = StringIO(src)
Tim Lauridsen c48e3f
         self.assertRaises(exc, self.cf.readfp, sio)
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     def test_query_errors(self):
Tim Lauridsen c48e3f
@@ -181,7 +188,7 @@
Tim Lauridsen c48e3f
     def get_error(self, exc, section, option):
Tim Lauridsen c48e3f
         try:
Tim Lauridsen c48e3f
             self.cf.get(section, option)
Tim Lauridsen c48e3f
-        except exc, e:
Tim Lauridsen c48e3f
+        except exc as e:
Tim Lauridsen c48e3f
             return e
Tim Lauridsen c48e3f
         else:
Tim Lauridsen c48e3f
             self.fail("expected exception type %s.%s"
Tim Lauridsen c48e3f
@@ -227,7 +234,7 @@
Tim Lauridsen c48e3f
             "foo: another very\n"
Tim Lauridsen c48e3f
             " long line"
Tim Lauridsen c48e3f
             )
Tim Lauridsen c48e3f
-        output = StringIO.StringIO()
Tim Lauridsen c48e3f
+        output = StringIO()
Tim Lauridsen c48e3f
         cf.write(output)
Tim Lauridsen c48e3f
         self.assertEqual(
Tim Lauridsen c48e3f
             output.getvalue(),
Tim Lauridsen c48e3f
@@ -465,7 +472,7 @@
Tim Lauridsen c48e3f
                         "o1=4\n"
Tim Lauridsen c48e3f
                         "[a]\n"
Tim Lauridsen c48e3f
                         "k=v\n")
Tim Lauridsen c48e3f
-        output = StringIO.StringIO()
Tim Lauridsen c48e3f
+        output = StringIO()
Tim Lauridsen c48e3f
         self.cf.write(output)
Tim Lauridsen c48e3f
         self.assertEquals(output.getvalue(),
Tim Lauridsen c48e3f
                           "[a]\n"
Tim Lauridsen c48e3f
Index: tests/test_fuzz.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- tests/test_fuzz.py	(revision 146)
Tim Lauridsen c48e3f
+++ tests/test_fuzz.py	(working copy)
Tim Lauridsen c48e3f
@@ -1,9 +1,10 @@
Tim Lauridsen c48e3f
 import re
Tim Lauridsen c48e3f
 import os
Tim Lauridsen c48e3f
 import random
Tim Lauridsen c48e3f
+import sys
Tim Lauridsen c48e3f
 import unittest
Tim Lauridsen c48e3f
-import ConfigParser
Tim Lauridsen c48e3f
-from StringIO import StringIO
Tim Lauridsen c48e3f
+from six import StringIO
Tim Lauridsen c48e3f
+from six.moves import configparser
Tim Lauridsen c48e3f
 from iniparse import compat, ini, tidy
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 # TODO:
Tim Lauridsen c48e3f
@@ -96,24 +97,25 @@
Tim Lauridsen c48e3f
                 s = '\n'.join(good_lines)
Tim Lauridsen c48e3f
                 cc = compat.RawConfigParser()
Tim Lauridsen c48e3f
                 cc.readfp(StringIO(s))
Tim Lauridsen c48e3f
-                cc_py = ConfigParser.RawConfigParser()
Tim Lauridsen c48e3f
+                cc_py = configparser.RawConfigParser()
Tim Lauridsen c48e3f
                 cc_py.readfp(StringIO(s))
Tim Lauridsen c48e3f
                 # compare the two configparsers
Tim Lauridsen c48e3f
                 self.assertEqualConfig(cc_py, cc)
Tim Lauridsen c48e3f
                 # check that tidy does not change semantics
Tim Lauridsen c48e3f
                 tidy(cc)
Tim Lauridsen c48e3f
-                cc_tidy = ConfigParser.RawConfigParser()
Tim Lauridsen c48e3f
+                cc_tidy = configparser.RawConfigParser()
Tim Lauridsen c48e3f
                 cc_tidy.readfp(StringIO(str(cc.data)))
Tim Lauridsen c48e3f
                 self.assertEqualConfig(cc_py, cc_tidy)
Tim Lauridsen c48e3f
             except AssertionError:
Tim Lauridsen c48e3f
                 fname = 'fuzz-test-iter-%d.ini' % fuzz_iter
Tim Lauridsen c48e3f
-                print 'Fuzz test failed at iteration', fuzz_iter
Tim Lauridsen c48e3f
-                print 'Writing out failing INI file as', fname
Tim Lauridsen c48e3f
+                print('Fuzz test failed at iteration', fuzz_iter)
Tim Lauridsen c48e3f
+                print('Writing out failing INI file as', fname)
Tim Lauridsen c48e3f
                 f = open(fname, 'w')
Tim Lauridsen c48e3f
                 f.write(s)
Tim Lauridsen c48e3f
                 f.close()
Tim Lauridsen c48e3f
                 raise
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
+    @unittest.skipIf(sys.version_info[0] > 2, 'http://code.google.com/p/iniparse/issues/detail?id=22#c9')
Tim Lauridsen c48e3f
     def assertEqualConfig(self, c1, c2):
Tim Lauridsen c48e3f
         self.assertEqualSorted(c1.sections(), c2.sections())
Tim Lauridsen c48e3f
         self.assertEqualSorted(c1.defaults().items(), c2.defaults().items())
Tim Lauridsen c48e3f
@@ -123,9 +125,7 @@
Tim Lauridsen c48e3f
                 self.assertEqual(c1.get(sec, opt), c2.get(sec, opt))
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     def assertEqualSorted(self, l1, l2):
Tim Lauridsen c48e3f
-        l1.sort()
Tim Lauridsen c48e3f
-        l2.sort()
Tim Lauridsen c48e3f
-        self.assertEqual(l1, l2)
Tim Lauridsen c48e3f
+        self.assertEqual(sorted(l1), sorted(l2))
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 class suite(unittest.TestSuite):
Tim Lauridsen c48e3f
     def __init__(self):
Tim Lauridsen c48e3f
Index: tests/test_ini.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- tests/test_ini.py	(revision 146)
Tim Lauridsen c48e3f
+++ tests/test_ini.py	(working copy)
Tim Lauridsen c48e3f
@@ -1,5 +1,5 @@
Tim Lauridsen c48e3f
 import unittest
Tim Lauridsen c48e3f
-from StringIO import StringIO
Tim Lauridsen c48e3f
+from six import StringIO
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 from iniparse import ini
Tim Lauridsen c48e3f
 from iniparse import compat
Tim Lauridsen c48e3f
@@ -196,13 +196,13 @@
Tim Lauridsen c48e3f
         self.assertEqual(p._data.find('section2').find('just').value, 'kidding')
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
         itr = p._data.finditer('section1')
Tim Lauridsen c48e3f
-        v = itr.next()
Tim Lauridsen c48e3f
+        v = next(itr)
Tim Lauridsen c48e3f
         self.assertEqual(v.find('help').value, 'yourself')
Tim Lauridsen c48e3f
         self.assertEqual(v.find('but').value, 'also me')
Tim Lauridsen c48e3f
-        v = itr.next()
Tim Lauridsen c48e3f
+        v = next(itr)
Tim Lauridsen c48e3f
         self.assertEqual(v.find('help').value, 'me')
Tim Lauridsen c48e3f
         self.assertEqual(v.find('I\'m').value, 'desperate')
Tim Lauridsen c48e3f
-        self.assertRaises(StopIteration, itr.next)
Tim Lauridsen c48e3f
+        self.assertRaises(StopIteration, next, itr)
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
         self.assertRaises(KeyError, p._data.find, 'section')
Tim Lauridsen c48e3f
         self.assertRaises(KeyError, p._data.find('section2').find, 'ahem')
Tim Lauridsen c48e3f
Index: tests/test_misc.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- tests/test_misc.py	(revision 146)
Tim Lauridsen c48e3f
+++ tests/test_misc.py	(working copy)
Tim Lauridsen c48e3f
@@ -1,9 +1,9 @@
Tim Lauridsen c48e3f
 import re
Tim Lauridsen c48e3f
 import unittest
Tim Lauridsen c48e3f
 import pickle
Tim Lauridsen c48e3f
-import ConfigParser
Tim Lauridsen c48e3f
+from six.moves import configparser
Tim Lauridsen c48e3f
+from six import StringIO
Tim Lauridsen c48e3f
 from textwrap import dedent
Tim Lauridsen c48e3f
-from StringIO import StringIO
Tim Lauridsen c48e3f
 from iniparse import compat, ini
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 class CaseSensitiveConfigParser(compat.ConfigParser):
Tim Lauridsen c48e3f
Index: tests/test_tidy.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- tests/test_tidy.py	(revision 146)
Tim Lauridsen c48e3f
+++ tests/test_tidy.py	(working copy)
Tim Lauridsen c48e3f
@@ -1,6 +1,6 @@
Tim Lauridsen c48e3f
 import unittest
Tim Lauridsen c48e3f
 from textwrap import dedent
Tim Lauridsen c48e3f
-from StringIO import StringIO
Tim Lauridsen c48e3f
+from six import StringIO
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 from iniparse import tidy,INIConfig
Tim Lauridsen c48e3f
 from iniparse.ini import  EmptyLine
Tim Lauridsen c48e3f
Index: tests/test_unicode.py
Tim Lauridsen c48e3f
===================================================================
Tim Lauridsen c48e3f
--- tests/test_unicode.py	(revision 146)
Tim Lauridsen c48e3f
+++ tests/test_unicode.py	(working copy)
Tim Lauridsen c48e3f
@@ -1,5 +1,5 @@
Tim Lauridsen c48e3f
 import unittest
Tim Lauridsen c48e3f
-from StringIO import StringIO
Tim Lauridsen c48e3f
+import six
Tim Lauridsen c48e3f
 from iniparse import compat, ini
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
 class test_unicode(unittest.TestCase):
Tim Lauridsen c48e3f
@@ -17,14 +17,14 @@
Tim Lauridsen c48e3f
     """
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     def basic_tests(self, s, strable):
Tim Lauridsen c48e3f
-        f = StringIO(s)
Tim Lauridsen c48e3f
+        f = six.StringIO(s)
Tim Lauridsen c48e3f
         i = ini.INIConfig(f)
Tim Lauridsen c48e3f
-        self.assertEqual(unicode(i), s)
Tim Lauridsen c48e3f
-        self.assertEqual(type(i.foo.bar), unicode)
Tim Lauridsen c48e3f
+        self.assertEqual(six.text_type(i), s)
Tim Lauridsen c48e3f
+        self.assertEqual(type(i.foo.bar), six.text_type)
Tim Lauridsen c48e3f
         if strable:
Tim Lauridsen c48e3f
             self.assertEqual(str(i), str(s))
Tim Lauridsen c48e3f
         else:
Tim Lauridsen c48e3f
-            self.assertRaises(UnicodeEncodeError, lambda: str(i))
Tim Lauridsen c48e3f
+            self.assertRaises(UnicodeEncodeError, lambda: six.text_type(i).encode('ascii'))
Tim Lauridsen c48e3f
         return i
Tim Lauridsen c48e3f
 
Tim Lauridsen c48e3f
     def test_ascii(self):