Message155843
| 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: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 |
|