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.

classification
Title: configparser
Type: Stage:
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: exe, georg.brandl
Priority: normal Keywords:

Created on 2009-09-22 13:45 by exe, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg92993 - (view) Author: Kandalintsev Alexandre (exe) Date: 2009-09-22 13:45
Hello! Seems configparser is broken in recent versions of py3k. Please also check older 
versions of python.

$ python3 ./cfgexample.py 
Traceback (most recent call last):
  File "./cfgexample.py", line 9, in <module>
    config.write(configfile)
  File "/usr/local/py3k/lib/python3.2/configparser.py", line 394, in write
    fp.write("[%s]\n" % section)
TypeError: must be bytes or buffer, not str
$ cat ./cfgexample.py 
import configparser

config = configparser.RawConfigParser()

config.add_section('Section1')
config.set('Section1', 'int', '15')

with open('example.cfg', 'wb') as configfile:
    config.write(configfile)
$ python3 --version
Python 3.2a0


I've built this version of python:
$ hg head
changeset:   4765:488e143fad23
branch:      py3k
tag:         tip
user:        tarek.ziade
date:        Tue Sep 22 12:08:13 2009 +0200
summary:     [svn r75013] Merged revisions 74812 via svnmerge from
msg92995 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-09-22 13:54
It seems that nobody updated the documentation to say that configparser
operates on text files.  The example is also wrong, it should open the
file in 'w' mode, not 'wb'.

Fixed in r75016.

PS: please use more expressive titles for issues in the future.
History
Date User Action Args
2022-04-11 14:56:53adminsetgithub: 51218
2009-10-11 19:24:08r.david.murraylinkissue7103 superseder
2009-09-22 13:54:02georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg92995

resolution: fixed
2009-09-22 13:45:09execreate