MkAssignment function doesn't work #1

Open
opened 2021-04-14 17:04:31 -05:00 by wp · 0 comments
Owner

Problem is here: c3c125fe19/vendortools/nfutil.py (L210)

In Python2, chr must have provided a binary object, but in Python 3 it's returned as a string. If ip_type is sent as 0 (integer type), chr(0) returns '\x00', which is a string. Struct expects b'\x00'.

>>> msg = nfutil.MkAssignment(seq, device['eth_addr'], device['ip_type'], '192.168.0.123', '255.255.255.0', '192.168.0.1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/wolfpack/Downloads/progpib/vendortools/nfutil.py", line 213, in MkAssignment
    socket.inet_aton(gateway)
struct.error: char format requires a bytes object of length 1
Problem is here: http://git.groesz.org/wp/progpib/src/commit/c3c125fe19481ed2d831aaa85864d1ff212011ba/vendortools/nfutil.py#L210 In Python2, chr must have provided a binary object, but in Python 3 it's returned as a string. If ip_type is sent as 0 (integer type), chr(0) returns '\x00', which is a string. Struct expects b'\x00'. ```python >>> msg = nfutil.MkAssignment(seq, device['eth_addr'], device['ip_type'], '192.168.0.123', '255.255.255.0', '192.168.0.1') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/wolfpack/Downloads/progpib/vendortools/nfutil.py", line 213, in MkAssignment socket.inet_aton(gateway) struct.error: char format requires a bytes object of length 1 ```
wp added the
bug
label 2021-04-14 19:35:48 -05:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Groesz.org/progpib#1
No description provided.