Message155843
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')) |
|
| Date |
User |
Action |
Args |
| 2012-03-15 02:24:52 | Sean.Wang | set | recipients:
+ Sean.Wang |
| 2012-03-15 02:24:52 | Sean.Wang | set | messageid: <1331778292.28.0.574531846286.issue14311@psf.upfronthosting.co.za> |
| 2012-03-15 02:24:51 | Sean.Wang | link | issue14311 messages |
| 2012-03-15 02:24:51 | Sean.Wang | create | |
|