Skip to content

Fix CircuitPython compatibility #53

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

Merged
merged 1 commit into from
Nov 14, 2020

Conversation

jepler
Copy link
Contributor

@jepler jepler commented Nov 14, 2020

Closes #52

On CircuitPython, bytearray objects have no split method. Emulate the specific form that we need.

Testing performed: tests still pass, and it works on a device.

On CircuitPython, bytearray objects have no split method.  Emulate
the specific form that we need.

Testing performed: tests still pass, _and_ it works on a device
Copy link
Member

@gamblor21 gamblor21 left a comment

Choose a reason for hiding this comment

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

Tested with:

t = bytearray("abc;def")
_buffer_split0(t, ';')

Output: bytearray(b'abc')

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

Tested successfully with get request. No longer get

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

@jepler jepler merged commit 531e845 into adafruit:master Nov 14, 2020
@jepler
Copy link
Contributor Author

jepler commented Nov 14, 2020

Thanks for the testing!

@d-c-d
Copy link

d-c-d commented Nov 15, 2020

Just ran across this same issue while upgrading my pyportal to CP6.0 and Adafruit_CircuitPython_Requests-1.8.0.zip
thanks to @anecdata on discord for pointing me to this request - fetched and install source .py file solved the problem for me too!

@ladyada
Copy link
Member

ladyada commented Nov 15, 2020

thankx!!

@jepler jepler deleted the circuitpython-compat branch November 15, 2020 02:39
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Nov 15, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.9.4 from 2.9.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#98 from kmatch98/blank_text

Updating https://github.com/adafruit/Adafruit_CircuitPython_MagTag to 1.0.2 from 1.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_MagTag#8 from ladyada/main
  > Merge pull request adafruit/Adafruit_CircuitPython_MagTag#7 from makermelissa/main
  > Merge pull request adafruit/Adafruit_CircuitPython_MagTag#6 from ladyada/main
  > Merge pull request adafruit/Adafruit_CircuitPython_MagTag#3 from makermelissa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.8.1 from 1.8.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#53 from jepler/circuitpython-compat
@anecdata
Copy link
Member

I think there are still some .split methods being used on objects that, at least in some circumstances, are bytearrays:

  File "adafruit_requests.py", line 692, in get
  File "adafruit_requests.py", line 568, in request
  File "adafruit_requests.py", line 277, in close
AttributeError: 'bytearray' object has no attribute 'split'

@askpatrickw
Copy link
Contributor

@anecdata I am seeing this as well. It seems like it works the first call and then not on subsequent calls. But my testing was limited to response = requests.get("https://io.adafruit.com/api/v2/time/seconds"). Were you also using the io time API?

@anecdata
Copy link
Member

@askpatrickw I was GETting from my own server, but like yours it seems to happen on the first call in code.py. I didn't explore it too deeply... it's very intermittent and I wasn't catching it, so I reset.

@askpatrickw
Copy link
Contributor

@anecdata Found it... see PR #56

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.

AttributeError: 'bytearray' object has no attribute 'split'
7 participants