Skip to content

Fix for Issue #50 Python3 Fix in _build_command()#51

Merged
mattdodge merged 5 commits intomasterfrom
issue50-at-fix
Jun 13, 2017
Merged

Fix for Issue #50 Python3 Fix in _build_command()#51
mattdodge merged 5 commits intomasterfrom
issue50-at-fix

Conversation

@jamesleesaunders
Copy link
Copy Markdown
Collaborator

Running code:

zigbee = ZigBee(serial)
zigbee.send('at', command='MY')

Running on python3 causes error:

  File "../pyalertme/base.py", line 119, in read_addresses
    self._xbee.send('at', command='MY')
  File "/usr/local/lib/python3.5/site-packages/xbee/base.py", line 394, in send
    self._write(self._build_command(cmd, **kwargs))
  File "/usr/local/lib/python3.5/site-packages/xbee/base.py", line 212, in _build_command
    packet += data
TypeError: can't concat bytes to str

Caused because _build_command() tries to concat bytes with at command 'MY' of type string.
This solution proposes checking data type and converting to bytes.

Also written a small unit test to make sure now works. I am not totally sure if test_zigbee.py is the most appropriate place for it.

Fixes Issue #50

@jamesleesaunders
Copy link
Copy Markdown
Collaborator Author

@hansmosh @mattdodge Please could one of you give this a check over? I didn't want to merge this in until at least one of you had given it a look. I have written a test (albeit not sure in the right place?)

Copy link
Copy Markdown
Collaborator

@mattdodge mattdodge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @jamesleesaunders

@mattdodge mattdodge merged commit f8cbcfd into master Jun 13, 2017
@mattdodge mattdodge deleted the issue50-at-fix branch June 13, 2017 00:52
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

Successfully merging this pull request may close these issues.

2 participants