Pythonista-Issues
Pythonista-Issues copied to clipboard
[330018 and prev] Py2: Can not close "sidebar" views using ".close()"
Description:
In 330018 and the previous beta, View.close() does not work in py2 when the view is presented using .present("sidebar"). The same code works when the view is presented with present() instead.
Additionally using an subclased ui.View instead leads to a crash when trying to close the view after .close() has been called.
Tested on: Pythonista 330018 & previous beta, python 2.7.12. Bug not observed with py3.
Expected behavior: The view should close properly regardless of presentation method and python version.
Example code (.close() not working):
"""Run with py2 and wait until "Done" is printed. The view will not be closed."""
import ui
import time
def main():
v = ui.View()
v.present("sidebar")
time.sleep(3) # also tested with raw_input(), as well as from threads (including `@on_main_thread`)
v.close() # does not work
print("Done")
if __name__ == "__main__":
main()
Example code 2 (pythonista crashing):
"""Run with py2 and wait until "Done" is printed. Then close the view manually. Pythonista will crash."""
import ui
import time
class SubclassedView(ui.View):
pass
def main():
v = SubclassedView()
v.present("sidebar")
time.sleep(3) # also tested with raw_input()
v.close() # does not work
print("Done")
if __name__ == "__main__":
main()
Note: Both examples are tested, but manually typed in instead of copy&pasted, so bugs may be present.
Sysinfo:
* Pythonista 3.3 (330018), Default interpreter 2.7.12
* iOS 12.4.1, model iPhone8,1, resolution (portrait) 750.0 x 1334.0 @2.0
Note: The sysinfo.py script reports iPhone8, but I am using an iPhone 6s.
No crash for me with subclass but I'm on iPad Mini 4 iOS 13.2.2
Default interpreter 2.7.12
Do you get the same results if the default interpreter is Python 3?
I forgot to say: I'm in Python 3, good idea
OK, i just tested it with 3.6 (via run with Python 3.6) and was not able to replicate it. After switching back to 2.7 the bug was still observed. So it is probably a py2-specific bug.
54 daze left.
54 daze left.
It will always live on in my heart as the one true version of python. Though i suppose I should start porting to py3 soon...
Also, pypy will continue supporting py2, so there is no hard requirement to switch :stuck_out_tongue_winking_eye: