REGR: mypyc 0.971 seems to not handle keyword-only arguments when unpickling (and shallow copying)
Open
Nobody has claimed this yet.
bug
topic-mypyc
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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
from typing import Any
class Test:
def __init__(self, *, x: Any) -> None:
...
save_load.py
import pickle
from test import Test
test = Test(x=1)
with open("test.pickle", mode="w+b") as file:
pickle.dump(test, file)
with open("test.pickle", mode="r+b") as file:
pickle.load(file)
$ mypyc test.py
$ python save_load.py
Traceback (most recent call last):
File "save_load.py", line 9, in <module>
pickle.load(file)
TypeError: __init__() missing required keyword-only argument 'x'
Expected Behavior
No TypeError
Actual Behavior
TypeError
Your Environment
- Mypy version used: 0.971
- Python version used: 3.10.4
- Operating system and version: Fedora Silverblue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the mypyc test.py and save_load.py reproduction with Python 3.10.4, then compare the generated behavior with the reported 0.961 and 0.971 versions. Done means the pickled Test instance with the keyword-only x argument loads successfully without TypeError, including the shallow-copy case mentioned in the title.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100