Kaydet (Commit) 3d75d0cc authored tarafından Victor Stinner's avatar Victor Stinner

Issue #8603: Environ.data is now protected -> Environ._data

os.environ.data was a str dict in Python 3.1. In Python 3.2 on UNIX/BSD,
os.environ.data is now a bytes dict: mark it as protected to avoid confusion.
üst 00ebe2cd
......@@ -420,34 +420,34 @@ class _Environ(MutableMapping):
self.decodevalue = decodevalue
self.putenv = putenv
self.unsetenv = unsetenv
self.data = data
self._data = data
def __getitem__(self, key):
value = self.data[self.encodekey(key)]
value = self._data[self.encodekey(key)]
return self.decodevalue(value)
def __setitem__(self, key, value):
key = self.encodekey(key)
value = self.encodevalue(value)
self.putenv(key, value)
self.data[key] = value
self._data[key] = value
def __delitem__(self, key):
key = self.encodekey(key)
self.unsetenv(key)
del self.data[key]
del self._data[key]
def __iter__(self):
for key in self.data:
for key in self._data:
yield self.decodekey(key)
def __len__(self):
return len(self.data)
return len(self._data)
def __repr__(self):
return 'environ({{{}}})'.format(', '.join(
('{!r}: {!r}'.format(self.decodekey(key), self.decodevalue(value))
for key, value in self.data.items())))
for key, value in self._data.items())))
def copy(self):
return dict(self)
......@@ -521,7 +521,7 @@ if supports_bytes_environ:
return value
# bytes environ
environb = _Environ(environ.data,
environb = _Environ(environ._data,
_check_bytes, bytes,
_check_bytes, bytes,
_putenv, _unsetenv)
......
......@@ -422,7 +422,6 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
def test___repr__(self):
"""Check that the repr() of os.environ looks like environ({...})."""
env = os.environ
self.assertTrue(isinstance(env.data, dict))
self.assertEqual(repr(env), 'environ({{{}}})'.format(', '.join(
'{!r}: {!r}'.format(key, value)
for key, value in env.items())))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment