[Python-checkins] r84690 - in python/branches/py3k/Lib: os.py test/test_os.py
victor.stinner
python-checkins at python.org
Sat Sep 11 00:18:17 CEST 2010
Author: victor.stinner
Date: Sat Sep 11 00:18:16 2010
New Revision: 84690
Log:
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.
Modified:
python/branches/py3k/Lib/os.py
python/branches/py3k/Lib/test/test_os.py
Modified: python/branches/py3k/Lib/os.py
==============================================================================
--- python/branches/py3k/Lib/os.py (original)
+++ python/branches/py3k/Lib/os.py Sat Sep 11 00:18:16 2010
@@ -420,34 +420,34 @@
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 @@
return value
# bytes environ
- environb = _Environ(environ.data,
+ environb = _Environ(environ._data,
_check_bytes, bytes,
_check_bytes, bytes,
_putenv, _unsetenv)
Modified: python/branches/py3k/Lib/test/test_os.py
==============================================================================
--- python/branches/py3k/Lib/test/test_os.py (original)
+++ python/branches/py3k/Lib/test/test_os.py Sat Sep 11 00:18:16 2010
@@ -422,7 +422,6 @@
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())))
More information about the Python-checkins
mailing list