Petri Lehtinen pe...@digip.org added the comment:
If *locale* is specified, it may be a None, a string, or an iterable of two
strings, language code and encoding. String pairs are converted to a single
string using the locale aliasing engine.
What about the possible None value then? Do you
Terry J. Reedy tjre...@udel.edu added the comment:
Yes, parentheses would be better.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3067
___
___
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset 34c9465f5023 by Petri Lehtinen in branch '2.7':
Issue #3067: Enhance the documentation and docstring of locale.setlocale()
http://hg.python.org/cpython/rev/34c9465f5023
New changeset 98806dd03506 by Petri Lehtinen
Petri Lehtinen pe...@digip.org added the comment:
I decided to restructure the documentation of setlocale() a bit and I think
it's better now overall. It includes Terry's suggestions.
I think this issue can now be closed. Thanks for the report and patches!
--
status: open - closed
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset 931ae170e51c by Petri Lehtinen in branch '3.2':
Issue #3067: Fix the error raised by locale.setlocale()
http://hg.python.org/cpython/rev/931ae170e51c
New changeset d90d88380aca by Petri Lehtinen in branch 'default':
Petri Lehtinen pe...@digip.org added the comment:
Terry: Do you still think there's need for a doc update?
--
resolution: - fixed
status: open - pending
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3067
Terry J. Reedy tjre...@udel.edu added the comment:
Yes. I think in locale.rst (assuming that is the name)
'''
exception locale.Error
Exception raised when setlocale() fails.
locale.setlocale(category, locale=None)
If *locale* is specified, it may be a string, a tuple of the form (language
Changes by Petri Lehtinen pe...@digip.org:
--
nosy: +petri.lehtinen
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3067
___
___
Python-bugs-list
Jyrki Pulliainen jy...@dywypi.org added the comment:
Added a patch that implements two things:
setlocale now raises locale.Error('Locale must be None, a string, or an
iterable of two strings -- language code, encoding.'). I decided to remove the
proposed .format(locale), as it wasa a bit
Éric Araujo mer...@netwok.org added the comment:
Thanks for the patch. Exception messages are considered implementation
details, so I would not test them. Testing that an exception is raised is good
enough IMO.
--
nosy: +eric.araujo
___
Python
Jyrki Pulliainen jy...@dywypi.org added the comment:
I modified the patch not to contain the tests against exception messages
--
Added file: http://bugs.python.org/file23447/issue3067_v2.patch
___
Python tracker rep...@bugs.python.org
Martin v. Löwis mar...@v.loewis.de added the comment:
I think the reported exception type is incorrect. Given that the error message
is 'Locale must be None, a string, or an iterable of two strings -- language
code, encoding.', it very much sounds like a TypeError is being reported here.
So I
Jyrki Pulliainen jy...@dywypi.org added the comment:
Maybe we should return TypeError with the same message then? That would require
some modification of documentation though, as it states: If the modification
of the locale fails, the exception Error is raised..
I don't really understand the
Martin v. Löwis mar...@v.loewis.de added the comment:
Maybe we should return TypeError with the same message then? That
would require some modification of documentation though, as it
states: If the modification of the locale fails, the exception Error
is raised..
No, any operation can
Jyrki Pulliainen jy...@dywypi.org added the comment:
Thanks for clarification! I see the problem now. So if I get this correctly we
should change the _build_localename to raise TypeError? If the given locale is
in wrong format, we'll get TypeError, but if it's valid type but otherwise
invalid
Martin v. Löwis mar...@v.loewis.de added the comment:
Thanks for clarification! I see the problem now. So if I get this
correctly we should change the _build_localename to raise TypeError?
Yes, that's what I'm proposing.
If the given locale is in wrong format, we'll get TypeError, but if
Jyrki Pulliainen jy...@dywypi.org added the comment:
Uploaded a new patch that raises TypeError
--
Added file: http://bugs.python.org/file23452/issue3067_v3.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3067
vincent.chute vincent.ch...@onelan.co.uk added the comment:
Since the module predates unicode strings (it is in 1.5) and since the locale
string is passed to a C function, 'string' in the doc can just as well be taken
to mean ascii byte string only, as the code requires.
My only comment is
STINNER Victor victor.stin...@haypocalc.com added the comment:
On Py3, locale.setlocale() should allow only unicode strings
and reject byte strings.
I agree and it is the current behaviour (of Python 3.3). I don't see any use
case of a byte strings in locale.setlocale() with Python 3.3, so I
Roundup Robot devnull@devnull added the comment:
New changeset d370d609d09b by Victor Stinner in branch '2.7':
Close #3067: locale.setlocale() accepts a Unicode locale.
http://hg.python.org/cpython/rev/d370d609d09b
--
nosy: +python-dev
resolution: - fixed
stage: test needed -
STINNER Victor victor.stin...@haypocalc.com added the comment:
I fixed locale.setlocale() of Python 2.7 to accept Unicode string because it
helps porting to Python 3...
But I think that the commit is just useless because we will have to wait until
Python 2.7.3 is released, and if you want to
Terry J. Reedy tjre...@udel.edu added the comment:
Victor, the issue for 3.x, which remains, is to improve the error message. I
also suggested a doc change, though I would like Mark or Martin's comments
before I would make it.
But I think that the commit is just useless because we will have
Roundup Robot devnull@devnull added the comment:
New changeset e72a2a60316f by Victor Stinner in branch '2.7':
Revert d370d609d09b as requested by Terry Jan Reedy:
http://hg.python.org/cpython/rev/e72a2a60316f
--
___
Python tracker
Changes by STINNER Victor victor.stin...@haypocalc.com:
--
nosy: +haypo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3067
___
___
Terry J. Reedy tjre...@udel.edu added the comment:
After more thought and investigation, I have changed my opinions on this issue.
Allowing unicode string for locale in 2.7:
Since the module predates unicode strings (it is in 1.5) and since the locale
string is passed to a C function,
25 matches
Mail list logo