New submission from Sean Wang <wangxiao8...@gmail.com>: 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')) ---------- components: Library (Lib) messages: 155843 nosy: Sean.Wang priority: normal severity: normal status: open title: ConfigParser does not parse utf-8 files with BOM bytes type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue14311> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com