Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configparser #51218

Closed
exe mannequin opened this issue Sep 22, 2009 · 2 comments
Closed

configparser #51218

exe mannequin opened this issue Sep 22, 2009 · 2 comments
Labels
stdlib Python modules in the Lib dir

Comments

@exe
Copy link
Mannequin

exe mannequin commented Sep 22, 2009

BPO 6969
Nosy @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2009-09-22.13:54:02.858>
created_at = <Date 2009-09-22.13:45:09.750>
labels = ['library']
title = 'configparser'
updated_at = <Date 2009-09-22.13:54:02.856>
user = 'https://bugs.python.org/exe'

bugs.python.org fields:

activity = <Date 2009-09-22.13:54:02.856>
actor = 'georg.brandl'
assignee = 'none'
closed = True
closed_date = <Date 2009-09-22.13:54:02.858>
closer = 'georg.brandl'
components = ['Library (Lib)']
creation = <Date 2009-09-22.13:45:09.750>
creator = 'exe'
dependencies = []
files = []
hgrepos = []
issue_num = 6969
keywords = []
message_count = 2.0
messages = ['92993', '92995']
nosy_count = 2.0
nosy_names = ['georg.brandl', 'exe']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue6969'
versions = ['Python 3.2']

@exe
Copy link
Mannequin Author

exe mannequin commented Sep 22, 2009

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

@exe exe mannequin added the stdlib Python modules in the Lib dir label Sep 22, 2009
@birkenfeld
Copy link
Member

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant