[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Eric V. Smith
Eric V. Smith added the comment: I (and many others) think the error message is fine the way it is. Also, it's hard for the error to be more specific about the method it's being called on. But if you have some concrete suggestions that can be implemented, you can add them to this issue.

[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Alex Zaslavskis
Alex Zaslavskis added the comment: What about adding alert message for beginners that can stuck with that in docs? To warn others , is that good idea you think. Or it is redundant ? -- ___ Python tracker

[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Alex Zaslavskis
Alex Zaslavskis added the comment: Thanks that really works. So as I understand that b''.split() != ''.split() -- resolution: -> not a bug ___ Python tracker ___

[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Eric V. Smith
Eric V. Smith added the comment: You said: """ b''.split(',') # gives strange error message. TypeError: a bytes-like object is required, not 'str' """ It is not a strange error message. You passed in a str (the ','), and you should have passed in bytes. --

[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Alex Zaslavskis
Alex Zaslavskis added the comment: Moreover according Python docs : This exception may be raised by user code to indicate that an attempted operation on an object is not supported. But also the Python interpreter gives that a bytes-like object is required, not 'str' that I am already

[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Alex Zaslavskis
Alex Zaslavskis added the comment: ''.split(',') # works as it should be b''.split(',') # gives strange error message. TypeError: a bytes-like object is required, not 'str' The problem here is that message is saying that for fix error you should use bytes-like object that not a true. In

[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Alex Zaslavskis
Alex Zaslavskis added the comment: I am not really sure that it is working as it should be. Even with your example it gives : TypeError: a bytes-like object is required, not 'str' The problem is why error message says that bytes-like is required , when the string is required. --

[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Eric V. Smith
Eric V. Smith added the comment: This is working as designed. The error is telling you that the argument to bytes.split() must be a string: >>> b''.split(',') Traceback (most recent call last): File "", line 1, in TypeError: a bytes-like object is required, not 'str' >>> b''.split(b',')

[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Alex Zaslavskis
Change by Alex Zaslavskis : Removed file: https://bugs.python.org/file50257/bug_in_python.py ___ Python tracker ___ ___ Python-bugs-list

[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Alex Zaslavskis
Change by Alex Zaslavskis : Added file: https://bugs.python.org/file50258/bug_in_python.py ___ Python tracker ___ ___ Python-bugs-list

[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Alex Zaslavskis
Change by Alex Zaslavskis : -- type: compile error -> behavior ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue45087] Confusing error message when trying split bytes.

2021-09-02 Thread Alex Zaslavskis
New submission from Alex Zaslavskis : If we will try to split bytes we will got quite strange error in console. Traceback (most recent call last): File "C:/Users/ProAdmin/Desktop/bug_in_python.py", line 6, in byte_message.split(",") TypeError: a bytes-like object is required, not 'str'