-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
REGR: mypyc 0.971 seems to not handle keyword-only arguments when unpickling (and shallow copying) #13227
Comments
slightly smaller reproducer: test.py: class Test:
def __init__(self, *, x: int) -> None:
... $ mypyc test.py
$ python -c "from test import Test; from copy import copy; copy(Test(x=1))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python3.10/copy.py", line 102, in copy
return _reconstruct(x, None, *rv)
File "/usr/lib64/python3.10/copy.py", line 265, in _reconstruct
y = func(*args)
File "/usr/lib64/python3.10/copyreg.py", line 101, in __newobj__
return cls.__new__(cls, *args)
TypeError: __init__() missing required keyword-only argument 'x' |
Sounds like this might be https://github.com/python/mypy/pull/12600/files#r873178396 |
Looks like mypyc docs isn't up to date cc @JukkaL mypyc/mypyc#920 |
If you make me an RTD admin (like you did for mypy), I can get the docs working again |
Thank you @hauntsaninja, using this decorator leads to a new issue without pickle/copy (and without keyword-only arguments): from mypy_extensions import mypyc_attr
@mypyc_attr(serializable=True)
class Test:
def __init__(self, x: int) -> None:
self.x = x
def test(self) -> int:
return self.x $ mypyc test.py
$ python -c "from test import Test; Test(x=1).test()"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "test.py", line 11, in test
return self.x
AttributeError: attribute 'Test' of 'x' undefined |
Is there any news regarding this issue? |
Bug Report
The following worked with 0.961: object's whose
__init__
has a keyword-only argument can no longer be unpickled.To Reproduce
test.py
save_load.py
Expected Behavior
No
TypeError
Actual Behavior
TypeError
Your Environment
The text was updated successfully, but these errors were encountered: