Skip to content

Commit

Permalink
read config with regard to encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Digenis committed Apr 22, 2019
1 parent 5298f9b commit 21135a0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions scrapyd/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import glob
from io import StringIO
import io
from pkgutil import get_data
from six.moves.configparser import SafeConfigParser, NoSectionError, NoOptionError
from os.path import expanduser
Expand All @@ -17,10 +17,14 @@ def __init__(self, values=None, extra_sources=()):
sources = self._getsources()
default_config = get_data(__package__, 'default_scrapyd.conf').decode('utf8')
self.cp = SafeConfigParser()
self.cp.readfp(StringIO(default_config))
self.cp.read(sources)
for fp in extra_sources:
self.cp.readfp(fp)
self.cp.readfp(io.StringIO(default_config))
sources.extend(extra_sources)
for fname in sources:
try:
with io.open(fname) as fp:
self.cp.readfp(fp)
except (IOError, OSError):
pass
else:
self.cp = SafeConfigParser(values)
self.cp.add_section(self.SECTION)
Expand Down

0 comments on commit 21135a0

Please sign in to comment.