Error with recursive Python curses.wrapper() functions on Alpine 3.19/edge (older versions unaffected)
First and foremost I must acknowledge that my example code is not code anyone should be writing, however it is code I have found to work on all platforms apart from Alpine Linux 3.19/edge (3.18 and below are unaffected).
The following code results in an error (_curses.error: endwin() returned ERR) when run on Alpine 3.19/edge, but it runs successfully on every other platform I have tested:
#!/usr/bin/env python3
import curses
def main(i):
if i < 2:
i += 1
# recursively call this function with curses.wrapper()
curses.wrapper(lambda test: main(i))
if __name__ == "__main__":
main(0)
print("This script runs perfectly fine on this platform!")
I noticed this breaking a personal project of mine, the sshyp password manager (the error would appear after closing the initial setup curses menu). I should not have used a recursive wrapper function like this in the first place (Alpine 3.19's behavior helped me find and fix my sub-optimal code) and I was able to work around it for my project, however, I thought I should still report this as a bug since I am unable to reproduce this behavior on any other platform, including older versions of Alpine.
I have successfully reproduced the bug in three of the three Alpine Linux 3.19 configurations I tried:
- x86_64 VM Image (running with kvm/qemu/libvirt)
- x86_64 Standard Image (running with kvm/qemu/libvirt)
- Raspberry Pi (armhf) image (Pi Zero W, bare-metal)
If this is not a bug and is instead now intended behavior, please let me know! Though I have fixed my own code and no longer need this fixed, I am genuinely curious as to why this behaves differently on Alpine 3.19. I do not believe the python3
package is at fault, as I tried installing the python3
package from 3.18 onto 3.19 and it resulted in the same error.