Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cdd9fec

Browse files
committed
Fix os.environb
1 parent fbfb02a commit cdd9fec

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lib/os.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,10 @@ def refresh(self):
790790
data[encodekey(key)] = value
791791
else:
792792
data = environ
793-
self._data = data
793+
794+
# modify in-place to keep os.environb in sync
795+
self._data.clear()
796+
self._data.update(data)
794797

795798
def _create_environ_mapping():
796799
if name == 'nt':

Lib/test/test_os.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,9 +1310,13 @@ def test_refresh(self):
13101310
os.environ['test_env'] = 'python_value'
13111311
putenv("test_env", "new_value")
13121312
self.assertEqual(os.environ['test_env'], 'python_value')
1313+
if hasattr(os, 'environb'):
1314+
self.assertEqual(os.environb[b'test_env'], b'python_value')
13131315

13141316
os.environ.refresh()
13151317
self.assertEqual(os.environ['test_env'], 'new_value')
1318+
if hasattr(os, 'environb'):
1319+
self.assertEqual(os.environb[b'test_env'], b'new_value')
13161320

13171321

13181322
class WalkTests(unittest.TestCase):

0 commit comments

Comments
 (0)