[issue7103] Error in config parser example (w/ Patch)

Thomas Courbon report at bugs.python.org
Sun Oct 11 15:09:36 CEST 2009


New submission from Thomas Courbon <harthie at yahoo.fr>:

When ran in python 3.1.1 (hand compiled, fedora 11), the first example
of configparser module fail with :
Traceback (most recent call last):
  File "test1.py", line 22, in <module>
    config.write(configfile)
  File "/usr/local/lib/python3.1/configparser.py", line 394, in write
    fp.write("[%s]\n" % section)
TypeError: write() argument 1 must be bytes or buffer, not str

This can be solved by replacing :
with open('example.cfg', 'wb') as configfile:

by :
with open('example.cfg', 'w') as configfile:

Patch attached.

Cheer !
Thomas

----------
assignee: georg.brandl
components: Documentation
messages: 93858
nosy: georg.brandl, tcourbon
severity: normal
status: open
title: Error in config parser example (w/ Patch)
versions: Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7103>
_______________________________________


More information about the Python-bugs-list mailing list