Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Scheme.for_cell fails with TypeError if optional argument is not passed #56

Open
leokoppel opened this issue Jan 17, 2015 · 2 comments
Open

Comments

@leokoppel
Copy link

(This was reported on StackOverflow here).

An uncaught TypeError is raised when Scheme.for_cell is called for an encrypted cell, without the optional passkey argument.

When no passkey is supplied, for_cell calls configuration with passkey=None , which, if the encryption happens to be 'wpa', fails on len(passkey) in scheme.py:23:

TypeError: object of type 'NoneType' has no len()
@rockymeza
Copy link
Owner

Hi @leokoppel,

This is not a very friendly error message now is it.

I think that Scheme.for_cell could check if the cell is encrypted and then throw a TypeError about the missing passkey. Do you think that is appropriate? It would still result in an error, but at least we could control the error message.

@leokoppel
Copy link
Author

Not sure about TypeError as the arguments given do match the function definition; they only go awry of the business logic. A custom exception like InterfaceError seems more appropriate.

I would have submitted a pull request to do this but the intended behaviour was not clear. For example, if the encryption type is 'wep', it would just return with 'wireless-key' : None and presumably fail upon trying to connect, but not before. So it's a design decision, up to you.

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

No branches or pull requests

2 participants