[issue41924] TextWrap's wrap method throws unhelpful error on bytes object

2020-10-03 Thread ThePokestarFan


ThePokestarFan  added the comment:

You're most likely right, so I'll close it. The lesson is most likely to not 
use weird arguments, but modules such as datetime warn against it, so I was 
surprised.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41924] TextWrap's wrap method throws unhelpful error on bytes object

2020-10-03 Thread ThePokestarFan


Change by ThePokestarFan :


--
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41924] TextWrap's wrap method throws unhelpful error on bytes object

2020-10-03 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

It's not textwrap that's doing it, which is why the error is so unhelpful; the 
input is assumed to be a str, and the translate method is called on it with a 
dict argument, which is valid for str.translate, but not for bytes.translate.

You'll get other "unhelpful" error messages for other arguments (e.g. most 
other built-in types die because they lack an expandtabs method). Is it 
necessary to provide specific error messages when an API is given a type it 
never claimed to support? I could see issues with a "check for str" check if 
someone is implementing their own str-like type that matches the API but gets 
rejected for not being str.

--
nosy: +josh.r

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41924] TextWrap's wrap method throws unhelpful error on bytes object

2020-10-03 Thread ThePokestarFan


Change by ThePokestarFan :


--
keywords: +patch
pull_requests: +21537
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22534

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41924] TextWrap's wrap method throws unhelpful error on bytes object

2020-10-03 Thread ThePokestarFan


New submission from ThePokestarFan :

The wrap() method of the TextWrapper class (and the module-level wrap method) 
throws an unhelpful TypeError upon getting a bytes object.

--
components: Library (Lib)
files: traceback.txt
messages: 377910
nosy: ThePokestarFan
priority: normal
severity: normal
status: open
title: TextWrap's wrap method throws unhelpful error on bytes object
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file49489/traceback.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com