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

"Martin v. Löwis" <report@bugs.python.org> at psf.upfronthosting.co.za "Martin v. Löwis" <report@bugs.python.org> at psf.upfronthosting.co.za
Sun May 3 19:20:24 CEST 2009

Martin v. Löwis <martin at v.loewis.de> 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 may be debatable whether applications care about the error
when passing "" as the locale, there is also the second case where
applications pass an explicit locale

  setlocale(locale.LC_ALL, "de_DE at euro")

When they do that, they surely want to be told if this actually

> Sure enough, we can use a
> try: construct, but it kind of defeats the principle of least
> astonishment by being different from the rest on this issue.

There is also the backwards compatibility issue: your change
will break existing code.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list