pimoroni / bme680-python

Python library for the BME680 gas, temperature, humidity and pressure sensor.
https://shop.pimoroni.com/products/bme680
MIT License
271 stars 96 forks source link

Fix TypeError preventing script to launch #31

Closed melvinmajor closed 4 years ago

melvinmajor commented 4 years ago

Hi, I followed a fix for the error encountered when launching this script. Everything is based on https://docs.python.org/3/library/subprocess.html#subprocess.Popen.communicate and while checking to fix: TypeError: argument should be integer or bytes-like object, not 'str'

coveralls commented 4 years ago

Pull Request Test Coverage Report for Build 33


Totals Coverage Status
Change from base Build 31: 0.0%
Covered Lines: 396
Relevant Lines: 459

💛 - Coveralls
Gadgetoid commented 4 years ago

Good catch!

However using b'=' instead of ord('=') would also be more Pythonic and would work, I believe, in Python 2.x and 3.x.

Python 3.6:

>>> b"hello world".index("l")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'

>>> b"hello world".index(b"l")
2

And 2.7:

>>> b"hello world".index("l")
2
>>> b"hello world".index(b"l")
2