Skip to content

Commit

Permalink
In Python3, file needs to be in binary mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
sophron committed Dec 10, 2019
1 parent 0562b17 commit bc0dce3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyric/utils/rfkill.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def rfkill_block(idx):
try:
rfke = rfkh.rfkill_event(idx,rfkh.RFKILL_TYPE_ALL,rfkh.RFKILL_OP_CHANGE,1,0)
if _PY3_: rfke = rfke.decode('ascii')
fout = open(dpath, 'w')
fout = open(dpath, 'wb')
fout.write(rfke)
except struct.error as e:
raise pyric.error(pyric.EUNDEF,"Error packing rfkill event {0}".format(e))
Expand Down Expand Up @@ -131,7 +131,7 @@ def rfkill_unblock(idx):
fout = None
try:
rfke = rfkh.rfkill_event(idx,rfkh.RFKILL_TYPE_ALL,rfkh.RFKILL_OP_CHANGE,0,0)
fout = open(dpath, 'w')
fout = open(dpath, 'wb')
fout.write(rfke)
except struct.error as e:
raise pyric.error(pyric.EUNDEF,"Error packing rfkill event {0}".format(e))
Expand Down Expand Up @@ -231,4 +231,4 @@ def gettype(idx):
except IOError:
raise pyric.error(errno.ENODEV,"No device at {0}".format(idx))
finally:
if fin: fin.close()
if fin: fin.close()

0 comments on commit bc0dce3

Please sign in to comment.