Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct.error: pack_into expected 6 items for packing (got 7) #4

Open
nevercast opened this issue Nov 20, 2018 · 2 comments
Open

struct.error: pack_into expected 6 items for packing (got 7) #4

nevercast opened this issue Nov 20, 2018 · 2 comments

Comments

@nevercast
Copy link

nevercast commented Nov 20, 2018

https://github.com/nickovs/slimDNS/blob/master/slimDNS.py#L326-L327

I'm trying to create a Server object in Python 3.6 on my Windows machine for testing, and I get a pack_into error, it seems there are 7 arguments for the 6 unsigned shorts that pack_into is expecting.

>>> server = SlimDNSServer('192.168.221.131', 'mp')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\REDACTED\slimDNS.py", line 197, in __init__
    self.advertise_hostname(hostname)
  File "C:\Users\REDACTED\slimDNS.py", line 226, in advertise_hostname
    addr = self.resolve_mdns_address(hostname, True)
  File "C:\Users\REDACTED\slimDNS.py", line 359, in resolve_mdns_address
    self.handle_question(q, _answer_handler, fast)
  File "C:\Users\REDACTED\slimDNS.py", line 327, in handle_question
    1, 0, 1, 0, 0, 0, 0)
struct.error: pack_into expected 6 items for packing (got 7)

I'm using master at the time of this issue (https://github.com/nickovs/slimDNS/tree/aac0c2f4c60900f5e213f1002f933b3444c260c3)

@nickovs
Copy link
Owner

nickovs commented Nov 20, 2018

Oops. That's a straightforward bug. There is one too many zeros in that list. I usually only use the code to serve a responder rather than send out questions, which is why I hadn't picked that up. I will fix the code but in the mean time you can just delete the last zero on line 327.

@nickovs
Copy link
Owner

nickovs commented Nov 20, 2018

FWIW, I just checked and it seems that the reason that I had not spotted this bug before is that the micropython implementation of struct.pack_into() ignores extra arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants