Skip to contentSkip to conversation

sshcontrol: Use os.environ.copy() instead of copy.copy()

PATCH New Richard Purdie 1 participant 1 message Jul 29, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sshcontrol: Use os.environ.copy() instead of copy.copy()

os.environ is special and copy.copy() doesn't do what we'd expect, changes in the child object change the parent. copy.deepcopy() is also known to have issues with it.

Use the dedicated .copy() method which will not influence the parent. This fixes selftest failures where the DISPLAY variable disappears.

meta/lib/oeqa/utils/sshcontrol.py +1 -2
index 4f8d3d2..6ed48ba 100644
@@ -10,7 +10,6 @@ import subprocess
 import time
 import os
 import select
-import copy
 
 
 class SSHProcess(object):
@@ -33,7 +32,7 @@ class SSHProcess(object):
         self.logfile = None
 
         # Unset DISPLAY which means we won't trigger SSH_ASKPASS
-        env = copy.copy(os.environ)
+        env = os.environ.copy()
         if "DISPLAY" in env:
             del env['DISPLAY']
         self.options['env'] = env