MCPcopy Index your code
hub / github.com/python/cpython / _create_environ_mapping

Function _create_environ_mapping

Lib/os.py:788–815  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

786
787
788def _create_environ_mapping():
789 if name == 'nt':
790 # Where Env Var Names Must Be UPPERCASE
791 def check_str(value):
792 if not isinstance(value, str):
793 raise TypeError("str expected, not %s" % type(value).__name__)
794 return value
795 encode = check_str
796 decode = str
797 def encodekey(key):
798 return encode(key).upper()
799 data = {}
800 for key, value in environ.items():
801 data[encodekey(key)] = value
802 else:
803 # Where Env Var Names Can Be Mixed Case
804 encoding = sys.getfilesystemencoding()
805 def encode(value):
806 if not isinstance(value, str):
807 raise TypeError("str expected, not %s" % type(value).__name__)
808 return value.encode(encoding, 'surrogateescape')
809 def decode(value):
810 return value.decode(encoding, 'surrogateescape')
811 encodekey = encode
812 data = environ
813 return _Environ(data,
814 encodekey, decode,
815 encode, decode)
816
817# unicode environ
818environ = _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

Used in the wild real call sites across dependent graphs

searching dependent graphs…