This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年12月06日 12:28 by Claudiu.Popa, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| daemon.py | Claudiu.Popa, 2011年12月06日 12:28 | |||
| Messages (3) | |||
|---|---|---|---|
| msg148912 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2011年12月06日 12:28 | |
On Unix world, in a daemonized process, any namedtuple instance can't be pickled, failing with error: _pickle.PicklingError: Can't pickle class X: attribute lookup __main__.t failed. This can't be reproduced with the attached code. If I add the created class inside the globals dict, the pickling will work. |
|||
| msg148913 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年12月06日 12:35 | |
As far as I can tell, this has nothing to do with daemon processes and all to do with the fact that user-defined classes have to be globally visible for their instances to be pickled. It is because pickles reference classes by name, and local names obviously don't work for that. In other words, this is not a bug. |
|||
| msg149162 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年12月10日 15:57 | |
Confirmed (3.2):
>>> def func():
... t = collections.namedtuple('t', 'a')
... instance = t(1)
... print(instance)
... return pickle.dumps(instance)
>>> func()
t(a=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in func
_pickle.PicklingError: Can't pickle <class '__main__.t'>: attribute lookup __main__.t failed
We may open an enhancement request to suggest that the error message include the qualname, but otherwise this is not a bug.
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:24 | admin | set | github: 57746 |
| 2011年12月10日 15:57:47 | eric.araujo | set | status: pending -> closed nosy: + eric.araujo messages: + msg149162 stage: resolved |
| 2011年12月06日 12:35:38 | pitrou | set | status: open -> pending versions: - Python 3.4 nosy: + alexandre.vassalotti, pitrou messages: + msg148913 resolution: not a bug |
| 2011年12月06日 12:28:22 | Claudiu.Popa | create | |