New submission from Trygve Aaberge <trygv...@gmail.com>:
This issue is a regression in Python 3.9. It was recently fixed in main/3.10, but I'm opening this issue to request that it is fixed in 3.9 as well since it breaks certain Python scripts running in WeeChat. I have a C application which is using the Python/C API and is running multiple python subinterpreters. One of those subinterpreters is running a script which is reading data from a non-blocking ssl socket. When there is no more data to read, trying to read throws `ssl.SSLWantReadError` which is handled by the script. However, if a script in another subinterpreter imports _ssl, the SSLWantReadError exceptions thrown in the first script now have a different class instance, so they are not catched anymore. This is a regression in 3.9. It didn't happen in 3.8. The commit that introduced the issue is https://github.com/python/cpython/commit/82c83bd907409c287a5bd0d0f4598f2c0538f34d The commit that fixes the issue in 3.10 is https://github.com/python/cpython/commit/7f1305ef9ea7234e1a5aacbea17490232e9b7dc2 I have attached a C program to reproduce the issue. It seems I can only attach one file per comment, so the python script that program runs will follow in the next commit. It connects to an ssl socket, so you need to have that running first. That can be started by running this: ``` openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -subj '/' openssl s_server -key key.pem -cert cert.pem -accept 1234 ``` The script will output this when the issue is not present (so in 3.8 and main): ``` no data no data ``` And this when the issue is present (in 3.9): ``` no dataunknown error: The operation did not complete (read) (_ssl.c:2627) exception name: SSLWantReadError SSLWantReadError id: 93893206532320 exception id: 93893207118800 ``` ---------- components: Subinterpreters files: interpreter.c messages: 393011 nosy: trygveaa priority: normal severity: normal status: open title: Exceptions in a subinterpreter are changed by another subinterpreter type: behavior versions: Python 3.9 Added file: https://bugs.python.org/file50015/interpreter.c _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44050> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com