Martin v. Löwis <mar...@v.loewis.de> 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 returns a null
> pointer and the program’s locale is not changed."
> 
> Note that neither C or POSIX defines any errors or sets errno or the
> likes. It simply returns a null pointer.

Still, this is considered as an error case.

> #include <locale.h>
> 
> int main(int argc, char *argv[]) {
>       setlocale(LC_CTYPE, "");
> 
>       ...
> }
> 
> This will try to set the locale to what the native environment
> specifies, but will not error out if the value

Yes, but that's a bug in the C code, which fails to check the
return value of setlocale. The fact that the bug is wide-spread
doesn't make it any better.

> As such I think PyLocale_setlocale() in Modules/_localemodule.c needs to
> be adjusted

-1. Errors should never pass silently. That's the whole point of exceptions.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1443504>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to