diff -r 677a9326b4d4 Lib/os.py --- a/Lib/os.py Mon Jul 09 18:16:11 2012 -0700 +++ b/Lib/os.py Mon Jul 16 22:35:47 2012 +0300 @@ -695,6 +695,9 @@ def copy(self): return dict(self) + def __copy__(self): + return self.copy() + def setdefault(self, key, value): if key not in self: self[key] = value diff -r 677a9326b4d4 Lib/test/test_os.py --- a/Lib/test/test_os.py Mon Jul 09 18:16:11 2012 -0700 +++ b/Lib/test/test_os.py Mon Jul 16 22:35:47 2012 +0300 @@ -24,6 +24,7 @@ import stat import locale import codecs +import copy try: import threading except ImportError: @@ -592,6 +593,16 @@ self.assertSequenceEqual(os.get_exec_path({'PATH': b'abc'}), ['abc']) + def test_copy(self): + env_copy = os.environ.copy() + env_copy_module = copy.copy(os.environ) + + env_copy['TEST_COPY'] = 'abc' + env_copy_module['TEST_COPY_MODULE'] = 'abc' + + self.assertNotIn('TEST_COPY', os.environ) + self.assertNotIn('TEST_COPY_MODULE', os.environ) + @unittest.skipUnless(os.supports_bytes_environ, "os.environb required for this test.") def test_environb(self):