Message258000
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. |
|
Date |
User |
Action |
Args |
2016-01-11 19:20:49 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, barry, pitrou, alexandre.vassalotti, nadeem.vawda, Arfrever, kitterma, python-dev, josh.r |
2016-01-11 19:20:49 | serhiy.storchaka | set | messageid: <1452540049.79.0.0210008431407.issue22995@psf.upfronthosting.co.za> |
2016-01-11 19:20:49 | serhiy.storchaka | link | issue22995 messages |
2016-01-11 19:20:49 | serhiy.storchaka | create | |
|