[Python-checkins] r68390 - peps/trunk/pep0/pep.py

benjamin.peterson python-checkins at python.org
Thu Jan 8 04:49:25 CET 2009


Author: benjamin.peterson
Date: Thu Jan  8 04:49:25 2009
New Revision: 68390

Log:
use a more robust form of normalization to make sorting correct

Modified:
   peps/trunk/pep0/pep.py

Modified: peps/trunk/pep0/pep.py
==============================================================================
--- peps/trunk/pep0/pep.py	(original)
+++ peps/trunk/pep0/pep.py	Thu Jan  8 04:49:25 2009
@@ -2,6 +2,7 @@
 """Code for handling object representation of a PEP."""
 import re
 import textwrap
+import unicodedata
 
 from email.parser import HeaderParser
 
@@ -88,17 +89,14 @@
 
     @property
     def sort_by(self):
-        if u' ' not in self.last:
-            return self.last
         name_parts = self.last.split()
         for index, part in enumerate(name_parts):
             if part[0].isupper():
                 break
         else:
             raise ValueError("last name missing a capital letter")
-        # This replace() hack is so people with an umlaut will sort in the right
-        # letter.
-        return u' '.join(name_parts[index:]).replace(u"ö", u"o")
+        base = u' '.join(name_parts[index:]).lower()
+        return unicodedata.normalize('NFKD', base).encode('ASCII', 'ignore')
 
     def _last_name(self, full_name):
         """Find the last name (or nickname) of a full name.


More information about the Python-checkins mailing list