Eryk Sun <eryk...@gmail.com> added the comment:

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().

----------
components: +Library (Lib)
type:  -> behavior
versions: +Python 3.10, Python 3.9 -Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue28824>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to