Message277311
| Author |
mark.dickinson |
| Recipients |
Kurt, levkivskyi, mark.dickinson |
| Date |
2016年09月24日.07:43:35 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1474703015.72.0.601767050982.issue28250@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I don't think this has anything to do with namedtuple; it's true whenever you create a class in an inner scope (rather than at module level). This is by design, and these restrictions are documented: https://docs.python.org/3.6/library/pickle.html#what-can-be-pickled-and-unpickled
For example, running this script:
import pickle
def my_func():
class A:
pass
a = A()
return a
a = my_func()
pickle.dumps(a)
produces:
Traceback (most recent call last):
File "test.py", line 11, in <module>
pickle.dumps(a)
AttributeError: Can't pickle local object 'my_func.<locals>.A' |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年09月24日 07:43:35 | mark.dickinson | set | recipients:
+ mark.dickinson, levkivskyi, Kurt |
| 2016年09月24日 07:43:35 | mark.dickinson | set | messageid: <1474703015.72.0.601767050982.issue28250@psf.upfronthosting.co.za> |
| 2016年09月24日 07:43:35 | mark.dickinson | link | issue28250 messages |
| 2016年09月24日 07:43:35 | mark.dickinson | create |
|