1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

python3: statemanager: use open call in binary mode

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
Julien Fortin
2019-10-02 17:10:24 +02:00
parent 97b96fdd22
commit 54de334242

View File

@@ -30,7 +30,7 @@ class pickling():
def save(cls, filename, list_of_objects):
""" pickle a list of iface objects """
try:
with open(filename, 'w') as f:
with open(filename, 'wb') as f:
for obj in list_of_objects:
pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)
except:
@@ -47,7 +47,7 @@ class pickling():
@classmethod
def load(cls, filename):
""" load picked iface object """
with open(filename, 'r') as f:
with open(filename, 'rb') as f:
while True:
try: yield pickle.load(f)
except EOFError: break
@@ -192,7 +192,7 @@ class stateManager():
""" saves state (ifaceobjects) to persistent state file """
try:
with open(self.state_file, 'w') as f:
with open(self.state_file, 'wb') as f:
if not len(self.ifaceobjdict):
f.truncate(0)
return