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 lukasz.langa
Recipients lukasz.langa, mickeyju
Date 2011-12-02.01:04:32
SpamBayes Score 4.4237336e-11
Marked as misclassified No
Message-id <1322787873.08.0.962390081255.issue13518@psf.upfronthosting.co.za>
In-reply-to
Content
Hello, Mickey. By doing open('file', 'rb') you're explicitly stating you want the file to be opened in BINARY mode which means it doesn't return strings but bytes. This is not supported anymore in Python 3. This is clearly documented here: http://docs.python.org/dev/library/configparser.html#configparser.ConfigParser.read_file

Same goes for urllib.request.urlopen, it returns bytes because this is all Python knows at the time of reading the URL. If you happen to know the encoding (for instance by parsing the data or headers) you can do something like this: http://docs.python.org/dev/library/urllib.request.html#examples . Your example would become:

config.read_string(urlopen(path_config).read().decode('utf-8'))

Since this is a reasonable mistake to make, I'm leaving this open to adjust the exception raised if read() yields bytes instead of expected strings.
History
Date User Action Args
2011-12-02 01:04:33lukasz.langasetrecipients: + lukasz.langa, mickeyju
2011-12-02 01:04:33lukasz.langasetmessageid: <1322787873.08.0.962390081255.issue13518@psf.upfronthosting.co.za>
2011-12-02 01:04:32lukasz.langalinkissue13518 messages
2011-12-02 01:04:32lukasz.langacreate