-
Notifications
You must be signed in to change notification settings - Fork 11
turtle constructor incompatible with CPython: tuple expected at most 1 argument, got 2 #30
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
Comments
@shulltronics does the original library work and then when you change things in your fork it doesnt? if so is there a PR with your changes? |
Thanks for getting around to this :) My original post could have been more clear. Obviously the library works on CircuitPython devices. I want to use is on generic computers, and so the first thing I changed was to wrap the However, once I made that change, I encountered the error mentioned above about "tuple expected at most 1 argument, got 2." After I did some research I tried changing the This allowed me to use the library on my laptop, but unfortunately broke it on CircuitPython. I would love to make a PR so this library can work out-of-the-box on CPython with Blinka, but first I need to figure out how to sort out this constructor issue. Thanks for your help, Adafruit! |
There does appear to be a difference in behavior between CPython and CircuitPython with regards to subclassing tuple. I've created an issue to track that: (#6677). The same difference is present in Micropython as well. I'm checking into whether this difference is intentional or not. If not, there may be some possibility to PR micropython to change it and that would eventually make it into circuitpython. If there is a reason for the difference then it may be kept as-is. In any case the simplest solution in the short term for this turtle library is probably to refactor Vec2D so that it doesn't extend tuple. As for your ultimate goal of running the turtle library on CPython. How are you intending to display it from CPython? using Blink_DisplayIO? or something different? |
I think I ran into an issue like that in the past, let me check the project I think it happened in when I get a chance sometime this week. Specifically, I noticed it for built-in types only, I believe, when subclassing from them, but I'll double-check. |
I checked, I actually think it may be related to any class defined in C - I believe a similar instance happened when I tried to subclass |
Thank you everyone for you interest and help with this. I will be following 6677 to see the discussion there, and also keeping up here. @FoamyGuy yes I used Adafruit_Blinka_Displayio to show the graphics in a I'm going on a two week vacation starting Thursday so this might sit a bit stagnant until then. But I will revisit and try to get a working solution then. Cheers! |
Hi all, I believe I have fixed this issue. The solution, as @FoamyGuy previously mentioned, was to remove the Basically, in addition to removing the subclass, I changed See here for my code. I have tested this on my linux machine, and on a Feather nRF52840 with CircuitPython 7.3.1, so I believe it works properly. I'm going to open a PR for this fix. Let me know if you all have any questions. Thanks! |
#31 Pull Request open :) |
resolved by #31 |
I'm working on adopting this library to use with CPython on Generic x86 computers. When I try to use this library I get the following error:
After some Googleing, I found that for child classes of Tuple, one should use the new constructor instead of init. I implemented this and got it working for CPython (see my fork here), but that breaks it on CircuitPython! When I test my changes on a Feather nRF52840 Express from CircuitPython 7.3.1, I get this error:
Is this an incompatibility of CircuitPython and CPython? I would love to get my changes merged in here, but obviously that can't happen if my changes break this on the CircuitPython interpreter.
I would appreciate any comments or direction on how this might be resolved. Thanks! :)
The text was updated successfully, but these errors were encountered: