Issue 33138: Improve standard error for uncopyable types (original) (raw)

Issue33138

Created on 2018-03-25 16:21 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6239 merged serhiy.storchaka,2018-03-25 20:55
Messages (5)
msg314418 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-25 16:21
Currently most extension types are not pickleable and copyable. The default error messages is "can't pickle XXX objects". This is confusing in case of copying because not all know that copying falls back to the pickle protocol (see for example ). The proposed PR changes the default error messages to more neutral "cannot serialize 'XXX' object". This or similar error messages are already used in some classes (files, sockets, compressors/decompressors). It also removes __getstate__ methods raising an error from non-pickleable extension types. They where added when extension types were pickleable by default (fixed in ). Now they are not needed.
msg318902 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-07 07:04
Current error messages for different classes: "can't pickle XXX objects" (default) "Cannot serialize XXX object" (socket, BZ2Compressor, BZ2Decompressor) "can not serialize a 'XXX' object" (buffered files in _pyio) "cannot serialize 'XXX' object" (FileIO, TextWrapperIO, WinConsoleIO, buffered files in _io, LZMACompressor, LZMADecompressor) Yest one error message is proposed by PR 6099 in for SSLContext: "cannot serialize {} object" PR 6239 replaces them with unified "cannot serialize 'XXX' object" which already is used in some extension classes. This is the most popular error message except the default error message. I'm not sure this is the best error message. "can't"/"Cannot"/"cannot"/"can not", using an article and quotes -- what is better?
msg325621 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-18 07:06
Does anybody have opinion about this issue? Is this option the best of possible? I'm going to merge the PR soon.
msg328962 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-31 00:28
New changeset 0353b4eaaf451ad463ce7eb3074f6b62d332f401 by Serhiy Storchaka in branch 'master': bpo-33138: Change standard error message for non-pickleable and non-copyable types. (GH-6239) https://github.com/python/cpython/commit/0353b4eaaf451ad463ce7eb3074f6b62d332f401
msg328979 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-31 09:18
Changed to "cannot pickle 'XXX' object" after discussing on Python-Dev: https://mail.python.org/pipermail/python-dev/2018-October/155599.html
History
Date User Action Args
2022-04-11 14:58:59 admin set github: 77319
2018-10-31 09🔞54 serhiy.storchaka set messages: +
2018-10-31 00:28:36 serhiy.storchaka set status: open -> closedresolution: fixedstage: patch review -> resolved
2018-10-31 00:28:10 serhiy.storchaka set messages: +
2018-09-18 09:29:08 xtreak set nosy: + xtreak
2018-09-18 07:06:28 serhiy.storchaka set assignee: serhiy.storchakamessages: +
2018-06-07 07:04:46 serhiy.storchaka set messages: +
2018-03-25 20:55:11 serhiy.storchaka set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest5978>
2018-03-25 16:21:38 serhiy.storchaka create