New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:

The proposed PR improves error messages in bytes and bytearray constructors.

1. When pass only encoding or errors to the bytes or bytearray constructor, it 
raises a TypeError with the message "encoding or errors without sequence 
argument". But the required argument is not a sequence, it is a string. 
"sequence argument" will be replaced with "a string argument".

2. Also "encoding or errors" will be replaced with just "encoding" or "errors", 
as in bytes(0, 'utf-8') and bytes(0, errors='utf-8').

3. When pass an unsupported type to the bytearray constructor, it raises  a 
TypeError with the message like "'float' object is not iterable". It will be 
replaced with "cannot convert 'float' object to bytearray" (similar to the 
message raised in the bytes constructor).

4. When pass an unsupported type to the bytearray's extend() method, it raises  
a TypeError with the message like "'float' object is not iterable". It will be 
replaced with "can't extend bytearray with float".

----------
assignee: serhiy.storchaka
components: Interpreter Core
messages: 327715
nosy: r.david.murray, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Improve error messages in bytes and bytearray constructors
type: enhancement
versions: Python 3.8

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

Reply via email to