[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2007-11-29 Thread Heikki Toivonen
Heikki Toivonen added the comment: We noticed this too in Chandler. We worked around this issue with the patch I am attaching. Maybe not a correct fix, though. -- nosy: +heikki versions: +Python 2.5 Added file: http://bugs.python.org/file8833/patches-2.5.1-Linux

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-04-06 Thread Daniel Diniz
Changes by Daniel Diniz : -- keywords: +patch stage: -> test needed type: -> behavior versions: +Python 2.6, Python 3.0 -Python 2.4, Python 2.5 ___ Python tracker ___ ___

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-04-30 Thread Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven added the comment: Shouldn't the fallback be to setlocale(LC_CTYPE, "C") instead of silently passing, though? -- nosy: +asmodai ___ Python tracker __

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-04-30 Thread Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven added the comment: You don't want to completely nix the setlocale(LC_CTYPE, "") call though. The "" denotes to grab the native environment, in other words, to grab whatever the current user's LC_CTYPE environment variable is set to (see `locale -a`) and then set the

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-01 Thread Martin v. Löwis
Martin v. Löwis added the comment: The patch looks fine to me. -- nosy: +loewis ___ Python tracker ___ ___ Python-bugs-list mailing

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-01 Thread Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven added the comment: OK, then I'll apply it. But I am curious about your thoughts about the _parse_localename() method being called from setlocale() raising a ValueError, whereas a setlocale(LC_CTYPE, "") should not fail at all, which it currently does if the locale

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-01 Thread Martin v. Löwis
Martin v. Löwis added the comment: > But I am curious about your thoughts about the _parse_localename() > method being called from setlocale() raising a ValueError, whereas a > setlocale(LC_CTYPE, "") should not fail at all, which it currently does > if the locale in the environment is not valid

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-01 Thread Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven added the comment: Sorry, I was actually off by a method last night. It turns out the problem lies in _localemodule.c. Let me start with the basic question: is our setlocale() supposed to mirror POSIX' operations/semantics? -- ___

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-01 Thread Martin v. Löwis
Martin v. Löwis added the comment: > Let me start with the basic question: is our setlocale() supposed to > mirror POSIX' operations/semantics? Yes, it is. -- ___ Python tracker

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-02 Thread Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven added the comment: I will first point out where our current implementation is broken, in my opinion of course, after which I propose a small patch. Both C90 (7.4.1.1) and C99 (7.11.1.1) state: "A value of "C" for locale specifies the minimal environment for C tran

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-02 Thread Martin v. Löwis
Martin v. Löwis added the comment: > If a pointer to a string is given for locale and the selection can be > honored, the setlocale function returns a pointer to the string > associated with the specified category for the new locale. If the > selection cannot be honored, the setlocale function r

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-03 Thread Georg Brandl
Georg Brandl added the comment: Interestingly, my setlocale(3p) man page says: """ ERRORS No errors are defined. """ So isn't it debatable if returning the NULL pointer really is an error? -- nosy: +georg.brandl ___ Python tracker

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-03 Thread Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven added the comment: On the subject whether or not returning a null pointer should be considered he said: -> On the subject whether or not returning a null pointer should be considered an error he said: -- ___ Python tra

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-03 Thread Jeroen Ruigrok van der Werven
Changes by Jeroen Ruigrok van der Werven : Removed file: http://bugs.python.org/file13843/locale.diff ___ Python tracker ___ ___ Python-bugs

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-03 Thread Jeroen Ruigrok van der Werven
Changes by Jeroen Ruigrok van der Werven : Removed file: http://bugs.python.org/file13849/locale.diff ___ Python tracker ___ ___ Python-bugs

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-03 Thread Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven added the comment: Really correct this time. -- Added file: http://bugs.python.org/file13850/locale.diff ___ Python tracker ___ _

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-03 Thread Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven added the comment: Georg pointed out a mistake I introduced in my patch, updated now. -- Added file: http://bugs.python.org/file13849/locale.diff ___ Python tracker

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-03 Thread Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven added the comment: I asked that as well on the POSIX/SUS list and Don Cragun responded with: "If you make the last argument to setlocale() be a pointer to unallocated memory, implementations would be allowed to set errno to EFAULT and terminate the process with a c

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-03 Thread Martin v. Löwis
Martin v. Löwis added the comment: > """ > ERRORS >No errors are defined. > """ > > So isn't it debatable if returning the NULL pointer really is an error? As Jeroen reports, this really means two different things a) "no errors" really means "no errno codes". Whether or not an error

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-03 Thread Martin v. Löwis
Martin v. Löwis added the comment: > I am just wondering why we want to be quite different from how many > other languages are approaching the issue. Because we have exceptions, and they don't. Would you also propose that open() should return None, just because fopen(3) returns NULL? While it

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-03 Thread R. David Murray
R. David Murray added the comment: On Sun, 3 May 2009 at 08:55, Jeroen Ruigrok van der Werven wrote: > I am just wondering why we want to be quite different from how many > other languages are approaching the issue. Sure enough, we can use a > try: construct, but it kind of defeats the principle

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-05 Thread Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven added the comment: Committed the initial patch in r72375 for trunk and r72376 for py3k. Any other branches that would need the merge? 3.0? -- resolution: -> accepted stage: test needed -> committed/rejected status: open -> pending ___

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-06 Thread Martin v. Löwis
Martin v. Löwis added the comment: It looks like a bug fix to me - so it would apply to all four active branches. -- status: pending -> open ___ Python tracker ___ ___

[issue1443504] locale.getpreferredencoding() dies when setlocale fails

2009-05-06 Thread Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven added the comment: Committed in r72381 and r72395. -- status: open -> closed ___ Python tracker ___ _