homepage

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.

Author Antony.Lee
Recipients Antony.Lee
Date 2014年11月27日.06:33:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1417069983.84.0.769912375651.issue22955@psf.upfronthosting.co.za>
In-reply-to
Content
methodcaller and attrgetter objects seem to be picklable, but in fact the pickling is erroneous:
>>> import operator, pickle
>>> pickle.loads(pickle.dumps(operator.methodcaller("foo")))
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
TypeError: methodcaller needs at least one argument, the method name
>>> pickle.loads(pickle.dumps(operator.attrgetter("foo")))
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
TypeError: attrgetter expected 1 arguments, got 0
When looking at the pickle disassembly, it seems that the argument to the constructor is indeed not pickled.
>>> import pickletools; pickletools.dis(pickle.dumps(operator.methodcaller("foo")))
 0: \x80 PROTO 3
 2: c GLOBAL 'operator methodcaller'
 25: q BINPUT 0
 27: ) EMPTY_TUPLE
 28: \x81 NEWOBJ
 29: q BINPUT 1
 31: . STOP
highest protocol among opcodes = 2
History
Date User Action Args
2014年11月27日 06:33:03Antony.Leesetrecipients: + Antony.Lee
2014年11月27日 06:33:03Antony.Leesetmessageid: <1417069983.84.0.769912375651.issue22955@psf.upfronthosting.co.za>
2014年11月27日 06:33:03Antony.Leelinkissue22955 messages
2014年11月27日 06:33:03Antony.Leecreate

AltStyle によって変換されたページ (->オリジナル) /