neo gurb added the comment:
In file ConfigParser.py, def write, replace line
key = " = ".join((key, str(value).replace('\n', '\n\t')))
by
key = " = ".join((key, str(value).decode('utf-8').replace('\n', '\n\t')))
Tested in Windows7 and Ubuntu 15.04.
--
nosy: +neo gurb
Eugene Klimov added the comment:
some workaround
import configparser
import codecs
cfg = configparser.ConfigParser()
cfg.write(codecs.open('filename','wb+','utf-8'))
--
nosy: +Eugene.Klimov
___
Python tracker rep...@bugs.python.org
Łukasz Langa luk...@langa.pl added the comment:
the_isz, for serious Unicode support you might try using the configparser 3.2
backport:
http://pypi.python.org/pypi/configparser
--
___
Python tracker rep...@bugs.python.org
the_isz the_...@gmx.de added the comment:
Thanks for the hint, Łukasz, but like I stated earlier, I already worked around
this problem by using the json module instead.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11597
the_isz the_...@gmx.de added the comment:
Well, the only thing I can add to this is that the json module (which I ended up
using) supports unicode with no problem. So I think the argument that most of
the standard library in 2.x assumes bytestrings is a bit... shaky.
Other than that, I can
Łukasz Langa luk...@langa.pl added the comment:
As another core dev aptly said, most standard library Unicode support is
probably accidental. As for `json`, this is one of the newest additions to
stdlib, introduced in Python 2.6 (released at the same time as Python 3.0). Not
the best example
STINNER Victor victor.stin...@haypocalc.com added the comment:
I think it is more a question of is this an easy fix?
or would it require extensive changes to support unicode properly.
First of all, the question is: who would like to develop it. You can vote for
an issue, but it doesn't
STINNER Victor victor.stin...@haypocalc.com added the comment:
Anyway, try to use Python everywhere in Python 2 is a waste of time.
Oh... I mean use Unicode in Python 2
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11597
Łukasz Langa luk...@langa.pl added the comment:
In my opinion we should unfortunately close this with WONTFIX because:
* adding a feature in a point release is not an option
* this may be poorly documented but most of the standard library in 2.x assumes
bytestrings (and fails with Unicode
R. David Murray rdmur...@bitdance.com added the comment:
No, the need for an encoding parameter for read/write makes it unambiguous that
it is indeed a feature.
--
resolution: - wont fix
status: open - closed
___
Python tracker
New submission from the_isz the_...@gmx.de:
Hey everyone,
I'm having issues writing unicode strings with ConfigParser.write. I don't know
if this is python's fault or my own but I couldn't find help on this, neither by
googling, nor by asking on the python irc channels.
Attached to this
R. David Murray rdmur...@bitdance.com added the comment:
str(u\u0411)
Traceback (most recent call last):
File stdin, line 1, in module
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0411' in position
0: ordinal not in range(128)
So, clearly configparser in 2.x doesn't support
Raymond Hettinger raymond.hettin...@gmail.com added the comment:
Now the question is, is this a bug
or would adding support be a feature?
That may be a good question for python-dev.
Since ConfigParser is a very old module,
if there were a pressing need, we probably
would have heard about it
R. David Murray rdmur...@bitdance.com added the comment:
Well, python3 is probably pushing some people to try to add better unicode
support to their python2 versions. I think it is more a question of is this
an easy fix? or would it require extensive changes to support unicode
properly. If
Raymond Hettinger raymond.hettin...@gmail.com added the comment:
It's also a question of adding a feature to a point release. If dev's relied
on the new feature, they would also have to test for version 2.7.1. We
usually try to avoid that (after a minor fiasco with booleans many years ago).
R. David Murray rdmur...@bitdance.com added the comment:
I understand what you are saying, and I thought about that, too; but you could
say the same thing about any bug fix that makes code work that didn't work
before, yet we don't. So I guess you are right that it should be discussed on
Georg Brandl ge...@python.org added the comment:
My vote would be that this is a new feature and therefore uneligible for 2.x.
--
nosy: +georg.brandl
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11597
17 matches
Mail list logo