Message148748
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. |
|
Date |
User |
Action |
Args |
2011-12-02 01:04:33 | lukasz.langa | set | recipients:
+ lukasz.langa, mickeyju |
2011-12-02 01:04:33 | lukasz.langa | set | messageid: <1322787873.08.0.962390081255.issue13518@psf.upfronthosting.co.za> |
2011-12-02 01:04:32 | lukasz.langa | link | issue13518 messages |
2011-12-02 01:04:32 | lukasz.langa | create | |
|