This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Sean.Wang
Recipients Sean.Wang
Date 2012-03-15.02:24:51
SpamBayes Score 0.0039800275
Marked as misclassified No
Message-id <1331778292.28.0.574531846286.issue14311@psf.upfronthosting.co.za>
In-reply-to
Content
ConfigParser failed to parse a utf-8 file with BOM bytes('\xef\xbb\xbf'),
it would raise ConfigParser.MissingSectionHeaderError.

I think that other files with BOM would have the same problem; because the argument "SECTCRE" does not consider the BOM conditions.

Now the workaround is like below:

cp=ConfigParser.ConfigParser()
cfgfile=os.path.join(curpath,'config.cfg')
cp.readfp(codecs.open(cfgfile, 'r','utf-8-sig'))
History
Date User Action Args
2012-03-15 02:24:52Sean.Wangsetrecipients: + Sean.Wang
2012-03-15 02:24:52Sean.Wangsetmessageid: <1331778292.28.0.574531846286.issue14311@psf.upfronthosting.co.za>
2012-03-15 02:24:51Sean.Wanglinkissue14311 messages
2012-03-15 02:24:51Sean.Wangcreate