-
Notifications
You must be signed in to change notification settings - Fork 116
Closed
Description
After this change in pydantic-core
: pydantic/pydantic-core#1616
How to reproduce:
model-write.py
:
from cloudpickle import dumps
from pydantic import BaseModel
class MyModel(BaseModel):
name: str = ""
serialized = dumps(MyModel)
with open("model.pkl", "wb") as f:
f.write(serialized)
model-read.py
from cloudpickle import loads
with open("model.pkl", "rb") as f:
serialized = f.read()
MyModel = loads(serialized)
model = MyModel(name="bar")
assert model.name == "bar"
$ uv pip install cloudpickle pydantic
Using Python 3.13.2 environment at: /Users/vlad/.virtualenvs/test-pydantic
Resolved 6 packages in 131ms
Installed 6 packages in 5ms
+ annotated-types==0.7.0
+ cloudpickle==3.1.1
+ pydantic==2.11.1
+ pydantic-core==2.33.0
+ typing-extensions==4.13.0
+ typing-inspection==0.4.0
$ python model-write.py
$ python model-read.py
Traceback (most recent call last):
File "/Users/vlad/playground/model-read.py", line 9, in <module>
assert model.name == "bar"
^^^^^^^^^^
File "/Users/vlad/.virtualenvs/test-pydantic/lib/python3.13/site-packages/pydantic/main.py", line 984, in __getattr__
raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'MyModel' object has no attribute 'name'
$
dmpetrov
Metadata
Metadata
Assignees
Labels
No labels