[New-bugs-announce] [issue13518] configparser

Mickey Ju report at bugs.python.org
Fri Dec 2 00:42:56 CET 2011

New submission from Mickey Ju <mickeyju at gmail.com>:

If this issue has raised previously, then I am sorry for repeating.  I did a search but did not find related reports.

Below is the thing I did.

  config = configparser.RawConfigParser()
  config.read_file(open('jkl.ini', 'rb'))

The line commented out was the thing I wanted to do originally.  I wanted to parse a configuration file stored on some web server.  And I got this error "TypeError: startswith first arg must be bytes or a tuple of bytes, not str."  But after I tried, with this line "config.read_file(open('jkl.ini', 'rb'))", the same error can be reproduced.  Therefore, I think the error message should be stated another way around as "startswith first arg must be str instead of bytes or a tuple of bytes."  I have checked this by adding the lines below to configparser.py after the for-loop at line 994.

  line = str(line, 'utf-8')

That made the code work.

components: Build
messages: 148747
nosy: mickeyju
priority: normal
severity: normal
status: open
title: configparser
type: behavior
versions: Python 3.2

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list