Commits

Gael Pasgrimaud committed 01a936f

bug fix 2.X/3.X

Comments (0)

Files changed (2)

ConfigObject/__init__.py

 import tempfile
 try:
     from ConfigParser import ConfigParser
+    PY3 = False
 except:
     from configparser import ConfigParser
+    PY3 = True
 
 __doc__ = """
 :class:`~ConfigObject.ConfigObject` is a wrapper to the python ConfigParser_ to
 
 Here is how list are stored::
 
-    >>> config.section.value1 = range(2)
+    >>> config.section.value1 = list(range(2))
     >>> print(config.section.value1)
     0
     1
         '0.1'
         >>> _ConfigValue(True)
         'true'
-        >>> print(_ConfigValue(range(2)))
+        >>> print(_ConfigValue(list(range(2))))
         0
         1
     """
         value = value and 'true' or 'false'
     elif isinstance(value, set) or \
          isinstance(value, list) or \
-         isinstance(value, range) or \
          isinstance(value, tuple):
         value = '\n'.join([str(v) for v in value])
     return ConfigValue(value)
         """Save to ``ConfigObject.filename`` if no fd is provided"""
         if fd is None:
             fd = open(self.filename, 'w')
-            ConfigParser.write(self, fd,
+            if PY3:
+                ConfigParser.write(self, fd,
                     space_around_delimiters=space_around_delimiters)
+            else:
+                ConfigParser.write(self, fd)
             fd.close()
         else:
-            ConfigParser.write(self, fd,
+            if PY3:
+                ConfigParser.write(self, fd,
                     space_around_delimiters=space_around_delimiters)
+            else:
+                ConfigParser.write(self, fd)
 
     def __getattr__(self, attr):
         return ConfigDict(self, attr)
 from setuptools import setup, find_packages
 import sys, os
 
-version = '1.2.1'
+version = '1.2.2'
 
 setup(name='ConfigObject',
       version=version,