New submission from Alex Zaslavskis <[email protected]>:
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 <module>
byte_message.split(",")
TypeError: a bytes-like object is required, not 'str'
The problem here is that object should be string and in if I convert it to
string the error is going. So that mean that there are error in mistake .
Correct variant should be :
Traceback (most recent call last):
File "C:/Users/ProAdmin/Desktop/bug_in_python.py", line 6, in <module>
byte_message.split(",")
TypeError: str is required, not a bytes-like object
message = 'Python is fun'
byte_message = bytes(message, 'utf-8')
print(byte_message)
#byte_message.split(",") causes error
str(byte_message).split(",") # works
----------
components: Argument Clinic
files: bug_in_python.py
messages: 400948
nosy: larry, sahsariga111
priority: normal
severity: normal
status: open
title: Confusing error message when trying split bytes.
type: compile error
versions: Python 3.9
Added file: https://bugs.python.org/file50257/bug_in_python.py
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45087>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com