Skip to content

Commit c096df5

Browse files
committed
Fix Python 3 issues
1 parent bd126b3 commit c096df5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

simpleconfigparser/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
"""
2525

2626
try:
27-
from configparser import configparser, NoOptionError, NoSectionError
27+
from configparser import ConfigParser as configparser, NoOptionError, NoSectionError
2828
except ImportError:
2929
from ConfigParser import SafeConfigParser as configparser, NoOptionError, NoSectionError
3030

3131

32-
class simpleconfigparser(configparser, dict):
32+
class simpleconfigparser(configparser):
3333
class Section(dict):
3434
"""
3535
Contain the section specific items that can be accessed via object properties
@@ -86,15 +86,15 @@ def __init__(self, defaults=None, *args, **kwargs):
8686
configparser.__init__(self, defaults=None, *args, **kwargs)
8787
# Improved defaults handling
8888
if isinstance(defaults, dict):
89-
for section, values in defaults.iteritems():
89+
for section, values in defaults.items():
9090
# Break out original format defaults was passed in
9191
if not isinstance(values, dict):
9292
break
9393

9494
if section not in self.sections():
9595
self.add_section(section)
9696

97-
for name, value in values.iteritems():
97+
for name, value in values.items():
9898
self.set(section, name, str(value))
9999

100100
def __getitem__(self, name):
@@ -126,6 +126,6 @@ def set(self, section, option, value=None):
126126
def get(self, section, option, raw=False, vars=None):
127127
try:
128128
# Strip out quotes from the edges
129-
return configparser.get(self, section, option, raw, vars).strip('"\'')
129+
return configparser.get(self, section, option, raw=raw, vars=vars).strip('"\'')
130130
except NoOptionError:
131131
return None

tests/test_simpleconfigparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ def test_read_items(self):
107107

108108
def test_write(self, tmpdir):
109109
path = join(str(tmpdir), 'new.ini')
110-
text = """[add]
110+
text = b"""[add]
111111
this = woo!
112112
113113
"""
114114

115115
config = simpleconfigparser()
116116
config.add.this = 'woo!'
117-
with open(path, 'wb') as handle:
117+
with open(path, 'w') as handle:
118118
config.write(handle)
119119

120120
assert exists(path) is True

0 commit comments

Comments
 (0)