adafruit / Adafruit_CircuitPython_Requests

Requests-like interface for web interfacing
MIT License
51 stars 36 forks source link

AttributeError: 'bytearray' object has no attribute 'split' #52

Closed jepler closed 3 years ago

jepler commented 3 years ago

This seems to be a CircuitPython vs Standard Python difference which makes the changes in #46 not work on CircuitPython:

Traceback (most recent call last):
  File "code.py", line 49, in <module>
  File "/lib/adafruit_requests.py", line 351, in json
  File "/lib/adafruit_requests.py", line 347, in json
  File "/lib/adafruit_requests.py", line 75, in readinto
  File "/lib/adafruit_requests.py", line 223, in _readinto
AttributeError: 'bytearray' object has no attribute 'split'

Desktop Python says:

>>> bytearray().split(b';')
[bytearray(b'')]

while CircuitPython says:

>>> bytearray().split(b';')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'bytearray' object has no attribute 'split'
tannewt commented 3 years ago

I had a similar issue with find. https://github.com/adafruit/circuitpython/pull/3161

https://github.com/adafruit/Adafruit_CircuitPython_Requests/blob/master/adafruit_requests.py#L132-L147

DougBurke commented 3 years ago

Thanks for reporting this - we're new to CircuitPython and so it's nice to know we're not the only ones seeing this! I rolled back to https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/tag/20201107 and was able to run my code.

martymcguire commented 3 years ago

hi :wave: just adding that i also ran into this issue with the 20201114 bundle and this guide.

Traceback (most recent call last):
  File "code.py", line 106, in <module>
  File "adafruit_matrixportal/matrixportal.py", line 312, in get_local_time
  File "adafruit_matrixportal/network.py", line 207, in get_local_time
  File "adafruit_matrixportal/network.py", line 198, in get_local_time
  File "adafruit_requests.py", line 330, in text
  File "adafruit_requests.py", line 319, in content
  File "adafruit_requests.py", line 365, in iter_content
  File "adafruit_requests.py", line 223, in _readinto
AttributeError: 'bytearray' object has no attribute 'split'

rolling back to the version of Requests in the 20201113 bundle sorted it.