You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dataclass takes no arguments in a subinterpreter in 3.12 #110279
In 3.12, when I construct an instance of a dataclass in a subinterpreter, I get an "X takes no arguments" error, for cases that work fine in the main interpreter.
Compiled with gcc -o py_dataclass py_dataclass.c -I /usr/include/python3.11 -lpython3.11 I get the expected:
Python version: 3.11.5 (main, Aug 25 2023, 13:19:50) [GCC 11.4.0]
In main interpreter:
MyClass(id='abc')
In subinterpreter:
MyClass(id='abc')
Compiled with gcc -o py_dataclass py_dataclass.c -I /usr/include/python3.12 -lpython3.12 I get:
Python version: 3.12.0 (main, Oct 2 2023, 15:04:50) [GCC 11.4.0]
In main interpreter:
MyClass(id='abc')
In subinterpreter:
Traceback (most recent call last):
File "<string>", line 8, in <module>
TypeError: MyClass() takes no arguments
This is using the python3.11-dev and python3.12-dev packages from the deadsnakes PPA.
I'm a little lost about what the interaction between the subinterpreter and the dataclass is that would cause this. The non-mangled Python code is just
Ah nice, I didn't know that test module was available to try it out in pure Python.
Also working for me at head, same for our internal usage (which is a bit more complex than the reduced example here - there's something else going wrong there which I'm still digging through).
I have no idea what's going on there. I don't have handy access to my dev box right now, but maybe inspecting the signature for MyClass.__init__ will shed some light.
For what it's worth, this has broken using Flask in Apache with mod_wsgi, meaning I cannot upgrade to Python 3.12 until this is fixed. So please consider getting this into 3.12.1.
Activity
peterebden commentedon Oct 3, 2023
An interesting datapoint; the following code does work as expected in the subinterpreter:
AA-Turner commentedon Oct 3, 2023
cc: @ericsnowcurrently
ericsnowcurrently commentedon Oct 4, 2023
Any ideas, @ericvsmith?
ericsnowcurrently commentedon Oct 4, 2023
FWIW, it seems to work fine on main. I was able to reproduce the failure on 3.12:
peterebden commentedon Oct 4, 2023
Ah nice, I didn't know that test module was available to try it out in pure Python.
Also working for me at head, same for our internal usage (which is a bit more complex than the reduced example here - there's something else going wrong there which I'm still digging through).
ericvsmith commentedon Oct 4, 2023
I have no idea what's going on there. I don't have handy access to my dev box right now, but maybe inspecting the signature for
MyClass.__init__will shed some light.graingert commentedon Oct 4, 2023
bisected to ba65a06 on 3.12
looks like it was fixed again on main in b72947a
ericvsmith commentedon Oct 4, 2023
Do you know if that made it to the 3.12 branch (so would be in 3.12.1)?
ericsnowcurrently commentedon Oct 4, 2023
I had decided not to backport it. Clearly I need to revisit that decision. 😄
graingert commentedon Oct 4, 2023
I just tried e658413 (the head of 3.12) and I still reproduce the failure
anthonyfk commentedon Nov 3, 2023
For what it's worth, this has broken using Flask in Apache with mod_wsgi, meaning I cannot upgrade to Python 3.12 until this is fixed. So please consider getting this into 3.12.1.
ericsnowcurrently commentedon Nov 28, 2023
I've merged the backport fix. Could someone verify whether or not this is fixed now. Thanks!
thierryba commentedon Dec 6, 2023
@ericsnowcurrently if you point me to the patch to try, I can do it. I have the same problems with mod_wsgi in a Django application.
uckelman commentedon Dec 8, 2023
I reported this in Fedora's bug tracker: https://bugzilla.redhat.com/show_bug.cgi?id=2252567
They made a build with the patch; I tested their build and confirmed that Flask apps no longer fail with the patch.
thierryba commentedon Dec 8, 2023
Does anyone know if this fix in included in 3.12.1?
ericsnowcurrently commentedon Dec 8, 2023
The fix is indeed part of 3.12.1.
peterebden commentedon Dec 13, 2023
Thanks, also fixed for me!
uckelman commentedon Dec 19, 2023
The fix is in Fedora 39 as of a day or two ago.