diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-09-10 22:18:16 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-09-10 22:18:16 (GMT) |
commit | 3d75d0cc9244a8c2c1f31deb47f097409d36fefb (patch) | |
tree | 0e25d20474af98446aafe31e191a691305032771 | |
parent | 00ebe2cdc46ea759209ccea1c96d6b75fd3c07c5 (diff) | |
download | cpython-3d75d0cc9244a8c2c1f31deb47f097409d36fefb.zip cpython-3d75d0cc9244a8c2c1f31deb47f097409d36fefb.tar.gz cpython-3d75d0cc9244a8c2c1f31deb47f097409d36fefb.tar.bz2 |
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.
-rw-r--r-- | Lib/os.py | 16 | ||||
-rw-r--r-- | Lib/test/test_os.py | 1 |
2 files changed, 8 insertions, 9 deletions
@@ -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) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index f42290f..7ce9959 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -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()))) |