Serhiy Storchaka added the comment:

The classes can't be *correctly* copied and unpickled because the pickle data 
doesn't contain object's state. "Copied" and "unpickled" objects are not equal 
to original objects, they are non-initialized instances. You can test 
attributes of copied NameAssignment instance to ensure that they are not 
restored. May be copied values are not used in Cython building, except rare 
exclusive cases when using them fails.

Example in the stdlib is csv.Dialect objects:

>>> import csv, pickle
>>> d = csv.get_dialect('excel-tab')
>>> d2 = pickle.loads(pickle.dumps(d))
>>> d.delimiter, d.doublequote, d.escapechar, d.lineterminator, d.quotechar, 
>>> d.quoting, d.skipinitialspace, d.strict
('\t', 1, None, '\r\n', '"', 0, 0, 0)
>>> d2.delimiter, d2.doublequote, d2.escapechar, d2.lineterminator, 
>>> d2.quotechar, d2.quoting, d2.skipinitialspace, d2.strict
(',', 1, None, '\r\n', '"', 0, 0, 0)

You just silently get wrong result. Since it by accident matches the instance 
of most used 'excel' dialect, this error is left unnoticed.

I think we have to left this restriction in 3.6 (and Cython should fix its bug 
by providing either __getnewargs__/ __getnewargs_ex__, __getstate__ or 
__reduce__/__reduce_ex__). But in 2.7 and 3.5 we should allow current Cython to 
work (even obtaining wrong result) by removing the check at all or by making it 
emit only a warning.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22995>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to