[SOLVED] python3: TypeError: a bytes-like object is required, not 'str'
by kaz2100 from LinuxQuestions.org on (#5T6WF)
To whom it may concern:
When you see the error, "a bytes-like object is required, not 'str'", it may be confusing.
Situation:
Code:import tarfile
tarf = tarfile.open(/path/to/tarfile', mode='w')
tarf.add('/path/to/file.name', b'file.name')gives you the error.
When 2nd argument is binary (not string)!!!
When 2nd argument is string, no error!
I ran into this situation with somebody else's code. (not my code!)
System:
Debian amd64, testing, with python3
Happy penguins!
When you see the error, "a bytes-like object is required, not 'str'", it may be confusing.
Situation:
Code:import tarfile
tarf = tarfile.open(/path/to/tarfile', mode='w')
tarf.add('/path/to/file.name', b'file.name')gives you the error.
When 2nd argument is binary (not string)!!!
When 2nd argument is string, no error!
I ran into this situation with somebody else's code. (not my code!)
System:
Debian amd64, testing, with python3
Happy penguins!