Message253421
| Author |
maatt |
| Recipients |
maatt |
| Date |
2015年10月25日.03:09:32 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1445742573.23.0.0225018159767.issue25472@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
If I try to pickle and unpickle an object of a class that has specialized a generic superclass, when I try to unpickle I get this error:
TypeError: descriptor '__dict__' for 'A' objects doesn't apply to 'B' object
Test case:
from typing import Generic, TypeVar
import pickle
T = TypeVar("T")
class A(Generic[T]):
def __init__(self, x: T):
self.x = x
class B(A[str]):
def __init__(self, x: str):
self.x = x
b = B("hello")
z = pickle.dumps(b)
print(z)
_ = pickle.loads(z) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2015年10月25日 03:09:33 | maatt | set | recipients:
+ maatt |
| 2015年10月25日 03:09:33 | maatt | set | messageid: <1445742573.23.0.0225018159767.issue25472@psf.upfronthosting.co.za> |
| 2015年10月25日 03:09:33 | maatt | link | issue25472 messages |
| 2015年10月25日 03:09:32 | maatt | create |
|