Message387676
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(). |
|
Date |
User |
Action |
Args |
2021-02-25 15:11:02 | eryksun | set | recipients:
+ eryksun, loewis, paul.moore, larry, tim.golden, r.david.murray, zach.ware, steve.dower, tzickel |
2021-02-25 15:11:01 | eryksun | set | messageid: <1614265861.98.0.181685468733.issue28824@roundup.psfhosted.org> |
2021-02-25 15:11:01 | eryksun | link | issue28824 messages |
2021-02-25 15:11:01 | eryksun | create | |
|