[Python-Dev] Standardize error message for non-pickleable types (original) (raw)
Terry Reedy tjreedy at udel.edu
Mon Oct 29 17:58:32 EDT 2018
- Previous message (by thread): [Python-Dev] Standardize error message for non-pickleable types
- Next message (by thread): [Python-Dev] Standardize error message for non-pickleable types
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10/29/2018 5:17 PM, MRAB wrote:
On 2018-10-29 19:38, Serhiy Storchaka wrote:
When you try to to pickle or copy a non-pickleable object, you will get an error. In most cases this will be a TypeError with one of few similar, but different variants:
"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) "cannot serialize {} object" (proposed for SSLContext) Perhaps some of them where added without deep thinking and then were replicated in different places. I'm going to replace all of them with a standardized error message.
Great idea.
But I'm unsure what variant is better.
1. "pickle" or "serialize"? 2. "can't", "Cannot", "can not" or "cannot"? 3. "object" or "objects"? 4. Use the "a" article or not? 5. Use quotes around type name or not? Please help me to choose the best variant. 1. If you're pickling, then saying "pickle" is more helpful. 2. In English the usual long form is "cannot". Error messages tend to avoid abbreviations,
Agree x 3
and also tend to have lowercase after the colon, e.g.:
"ZeroDivisionError: division by zero" "ValueError: invalid literal for int() with base 10: 'foo'"
I had not noticed, but
IndexError: list index out of range NameError: name 'sqrt' is not defined
3. If it's failing on an object (singular), then it's clearer to say "object".
4. Articles tend to be omitted.
Grammatically, the two examples above could/should start with 'The'. But that is routinely omitted. Matching a/an to 'xxx' would be a terrible nuisance. "a 'str'" (a string)?, "an 'str'" (an ess tee ar)?
5. Error messages tend to have quotes around the type name.
Therefore, my preference is for: "cannot pickle 'XXX' object" +1
-- Terry Jan Reedy
- Previous message (by thread): [Python-Dev] Standardize error message for non-pickleable types
- Next message (by thread): [Python-Dev] Standardize error message for non-pickleable types
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]