MCPcopy Index your code
hub / github.com/RustPython/RustPython / _create_environ_mapping

Function _create_environ_mapping

Lib/os.py:769–796  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

767 return new
768
769def _create_environ_mapping():
770 if name == 'nt':
771 # Where Env Var Names Must Be UPPERCASE
772 def check_str(value):
773 if not isinstance(value, str):
774 raise TypeError("str expected, not %s" % type(value).__name__)
775 return value
776 encode = check_str
777 decode = str
778 def encodekey(key):
779 return encode(key).upper()
780 data = {}
781 for key, value in environ.items():
782 data[encodekey(key)] = value
783 else:
784 # Where Env Var Names Can Be Mixed Case
785 encoding = sys.getfilesystemencoding()
786 def encode(value):
787 if not isinstance(value, str):
788 raise TypeError("str expected, not %s" % type(value).__name__)
789 return value.encode(encoding, 'surrogateescape')
790 def decode(value):
791 return value.decode(encoding, 'surrogateescape')
792 encodekey = encode
793 data = environ
794 return _Environ(data,
795 encodekey, decode,
796 encode, decode)
797
798# unicode environ
799environ = _create_environ_mapping()

Callers 1

os.pyFile · 0.85

Calls 3

encodekeyFunction · 0.85
_EnvironClass · 0.85
itemsMethod · 0.45

Tested by

no test coverage detected