New submission from pnugues: The sorted() function does not work properly with macosx. Here is a script to reproduce the issue:
import locale locale.setlocale(locale.LC_ALL, "fr_FR.UTF-8") a = ["A", "E", "Z", "a", "e", "é", "z"] sorted(a) sorted(a, key=locale.strxfrm) The execution on MacOsX produces: pierre:Flaubert pierre$ sw_vers -productVersion 10.10.1 pierre:Flaubert pierre$ python3 Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import locale >>> locale.setlocale(locale.LC_ALL, "fr_FR.UTF-8") 'fr_FR.UTF-8' >>> a = ["A", "E", "Z", "a", "e", "é", "z"] >>> sorted(a) ['A', 'E', 'Z', 'a', 'e', 'z', 'é'] >>> sorted(a, key=locale.strxfrm) ['A', 'E', 'Z', 'a', 'e', 'z', 'é'] >>> while it produces this on you interactive shell (python.org): In [10]: import locale In [11]: locale.setlocale(locale.LC_ALL, "fr_FR.UTF-8") Out[11]: 'fr_FR.UTF-8' In [12]: a = ["A", "E", "Z", "a", "e", "é", "z"] In [13]: sorted(a) Out[13]: ['A', 'E', 'Z', 'a', 'e', 'z', 'é'] In [14]: sorted(a, key=locale.strxfrm) Out[14]: ['a', 'A', 'e', 'E', 'é', 'z', 'Z'] which is correct. ---------- messages: 2927 nosy: pnugues priority: urgent status: unread title: Sorting with locale does not work properly with Python3 on Macos _______________________________________________________ PSF Meta Tracker <metatrac...@psf.upfronthosting.co.za> <http://psf.upfronthosting.co.za/roundup/meta/issue561> _______________________________________________________ _______________________________________________ Tracker-discuss mailing list Tracker-discuss@python.org https://mail.python.org/mailman/listinfo/tracker-discuss