Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
pypxe/dhcp.py: avoid exception when invoking export_leases
Browse files Browse the repository at this point in the history
Fixes the following crash:

Traceback (most recent call last):

  [...]

  File "/usr/lib/python3.10/site-packages/pypxe/dhcp.py", line 145, in export_leases
    json.dump(export_safe, leases_file)
  File "/usr/lib/python3.10/json/__init__.py", line 180, in dump
    fp.write(chunk)
TypeError: a bytes-like object is required, not str
  • Loading branch information
Andres Gomez authored and icb- committed Apr 3, 2022
1 parent 16fff30 commit 89e75e2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pypxe/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def export_leases(self, signum, frame):
for lease in self.leases:
# translate the key to json safe (and human readable) mac
export_safe[self.get_mac(lease)] = self.leases[lease]
leases_file = open(self.save_leases_file, 'wb')
leases_file = open(self.save_leases_file, 'w')
json.dump(export_safe, leases_file)
self.logger.info('Exported leases to {0}'.format(self.save_leases_file))

Expand Down

0 comments on commit 89e75e2

Please sign in to comment.