title: Errors reading a config file with ConfigParser in python 3,4
body: <p>I am having a nagging error in Python 3.4 reading a config set file using the configparser . The Code was originally written for Python 2.7 but i no longer use it and i only use python 3.4 . I don't want any backward compatibility to python 2.7 at all. Only and only python 3.4 </p>
  
  <pre><code>Error reading set file ./sets/diagnostic1.set
  </code></pre>
  
  <p>Above is the Error i am getting , when i run this code</p>
  
  <pre><code>from configparser import *
  import re, os, ctypes, csv, calendar, datetime
  from time import *
  from ctypes import *
  
  # Reads the config set file 
  def readSetFile(file):
     try:
        #config = RawConfigParser()
        #config.readfp(FakeSecHead(open(file)))  #  readfp is deprecated from configparser 
        config = ConfigParser(delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=';',  interpolation=None)
        config.read_file(FakeSecHead(open(file)))
        return config
    except:
      return False
  
  
  # Reads fake or modified Section head in the config file
  class FakeSecHead(object):
    def __init__(self, fp):
        self.fp = fp
        self.sechead = '[main]\n'
  
    def readline(self):
        if self.sechead:
          try:
              return self.sechead
          finally:
              self.sechead = None
        else:
          line = self.fp.readline()
        return re.sub('^SECTION_3.*$', '[additional]', line)
  </code></pre>
  
  <p>The  " diagnostic1.set "  file which contains the configs</p>
  
  <pre><code>  COMMENTS=Click view comments.
    SECTION_1=################# General Settings #################
    FRAMEWORK_CONFIG=./experts/config/TesingConfig.xml
    USE_ORDER_WRAPPER=0
    UI_FONT_SIZE=12
    UI_ERROR_INFO_COLOR=0
    UI_CUSTOM_INFO_COLOR=0
    SECTION_2=############## Common Strategy Settings ##############
    OPERATIONAL_MODE=1
    STRATEGY_INSTANCE_ID=25
    MAX_DRAWDOWN_PERCENT=100.00000000
    MAX_SPREAD_PIPS=100.00000000
    ENABLE_WFO=0
    WFO_WINDOW_SIZE=0
    PARAMETER_SET_POOL=0.00000000
    DISABLE_COMPOUNDING=0
    USE_INSTANCE_BALANCE=0
    INIT_INSTANCE_BALANCE=0.00000000
    TIMED_EXIT_BARS=31
    ATR_AVERAGING_PERIOD=3
    MAX_OPEN_ORDERS=1
    SECTION_3=############## Additional Strategy Settings ##############
    OPEN_ATR_MULTIPLIER=0.41000000
    OPEN_ATR_MULTIPLIER,F=1
    OPEN_ATR_MULTIPLIER,1=0.20
    OPEN_ATR_MULTIPLIER,2=0.01
    OPEN_ATR_MULTIPLIER,3=0.60
    TRADE_CONFIDENCE=2
  </code></pre>
  
  <p>So when i tested Running the code in python 3.4 console i get "False" which indicates it can't read the config set file.</p>
  
  <pre><code> Python 3.4.3 |Anaconda 2.3.0 (64-bit)| (default, Jun  4 2015, 15:29:08) 
   [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
   Type "help", "copyright", "credits" or "license" for more information.
   &gt;&gt;&gt; from configparser import *
   &gt;&gt;&gt; import re, os, ctypes, csv, calendar, datetime
   &gt;&gt;&gt; from time import *
   &gt;&gt;&gt; from ctypes import *
   &gt;&gt;&gt;
   &gt;&gt;&gt; def readSetFile(file):
   ...     try:
   ...         #config = RawConfigParser()
   ...         #config.readfp(FakeSecHead(open(file)))  #  readfp will be deprecated from configparser edited by developer
   ...         config = ConfigParser(delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=';',  interpolation=None)
   ...         config.read_file(FakeSecHead(open(file)))
   ...         return config
   ...     except:
   ...         return False
  
   &gt;&gt;&gt; 
   &gt;&gt;&gt; class FakeSecHead(object):
   ...     def __init__(self, fp):
   ...         self.fp = fp
   ...         self.sechead = '[main]\n'
   ...     def readline(self):
   ...         if self.sechead:
   ...             try:
   ...                 return self.sechead
   ...             finally:
   ...                 self.sechead = None
   ...         else:
   ...             line = self.fp.readline()
   ...         return re.sub('^SECTION_3.*$', '[additional]', line)
   ... 
  
  
   &gt;&gt;&gt; readSetFile('./sets/diagnostics1.set')
   False
   &gt;&gt;&gt; 
  </code></pre>
  
  <p>Any help in being able to read the config set file the way it is. i have hundreds of config set files in the same format. but i can't seem to be able to read the files in Python 3.4</p>
  
  <p>I have managed to modify code snippet from Patrick MAUPIN and it is able to read the config set file but now throws an key error in same part of the code</p>
  
  <pre><code>  numSystemsInPortfolio = len(setFilePaths)
    SettingsArrayType = numSystemsInPortfolio * ctypes.POINTER(c_double)
    settings = SettingsArrayType()
    for i in range(numSystemsInPortfolio):
       settings[i] = SettingsType()
       settings[i][IS_BACKTESTING] = True
       settings[i][DISABLE_COMPOUNDING] = float(sets[i].mainParams["DISABLE_COMPOUNDING"]['value']) if sets[
          i].content.has_option('main', 'DISABLE_COMPOUNDING') else 0
       settings[i][TIMED_EXIT_BARS] = float(sets[i].mainParams["TIMED_EXIT_BARS"]['value']) if sets[
          i].content.has_option('main', 'TIMED_EXIT_BARS') else 0
       settings[i][ORIGINAL_EQUITY] = config.getfloat("account", "balance")
       .....
       .....
       .....
       .....
       .....
  
  
  
      File "mycode.py", line 222, in main
  i].content.has_option('main', "DISABLE_COMPOUNDING") else 0
      KeyError: 'DISABLE_COMPOUNDING'
  </code></pre>