-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
PyPortal: board.DISPLAY is None returns wrong value #6227
Comments
The way we make the board.DISPLAY object "be None" is not quite correct, because it doesn't make it obey an "is" test. We need to define a proper way to check for the display being deinitialized that doesn't have this problem. For now, it is possible to use |
How about |
Unfortunately this fake-None is also treated as a true value in truthy contexts :-( |
Well, maybe that's what we should fix then. |
We don't even need to call it None, as long as it's false-y. |
Maybe we could make it an int zero instead of a pointer? |
We could change this by having a custom unary op for NoneType.
Make what an int zero? We can't modify the pointer because it is in a ROM table. That's why it changes the object type now. |
Wouldn't it be just as simple as having a |
Not thinking well. But we could make it an empty list or tuple or bytearray, all of which are False-y? |
None should be False-y too? Not sure why this doesn't work? |
Because |
Ideally, it should be |
Using a list (or function) board.DISPLAYS does help with the problem, because the list would reside in RAM and thus the object pointer could actually be updated. It would also help with the rare boards that have more than one display. There's still the problem of what if you write I have an incomplete and non-working branch that introduces the Deinitialized object, which might be of interest. It tries to solve the problem generally for other types of objects as well: https://github.com/adafruit/circuitpython/compare/main...jepler:circuitpython:deinited-type?expand=1 This needs to be elaborated on so that it builds and works. The object would always act False in a truthy context (so you could say 'if not board.DISPLAY`, unlike currently). |
CircuitPython version
Code/REPL
Behavior
After displayio.release_displays() the attribute board.DISPLAY is None but "is None" returns False.
Note that I know I should not call this method for boards with integrated displays, but errors happen. But I expect "isNone" to always return True for variables of type 'NoneType'.
Description
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: