Message387676
| Author |
eryksun |
| Recipients |
eryksun, larry, loewis, paul.moore, r.david.murray, steve.dower, tim.golden, tzickel, zach.ware |
| Date |
2021年02月25日.15:11:01 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1614265861.98.0.181685468733.issue28824@roundup.psfhosted.org> |
| In-reply-to |
| Content |
In Windows, maybe the os.environ mapping could use a case-insensitive subclass of str for its keys, such as the following:
@total_ordering
class _CaseInsensitiveString(str):
def __eq__(self, other):
if not isinstance(other, str):
return NotImplemented
return self.upper() == other.upper()
def __lt__(self, other):
if not isinstance(other, str):
return NotImplemented
return self.upper() < other.upper()
def __hash__(self):
return hash(self.upper())
Change encodekey() to use this type. For example:
def encodekey(key):
return _CaseInsensitiveString(encode(key))
in which encode() is still check_str(). |
|