Article 5T6WF [SOLVED] python3: TypeError: a bytes-like object is required, not 'str'

[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!latest?d=yIl2AUoC8zA latest?i=0m41ukoYTTc:sez_M5dzDHE:F7zBnMy latest?i=0m41ukoYTTc:sez_M5dzDHE:V_sGLiP latest?d=qj6IDK7rITs latest?i=0m41ukoYTTc:sez_M5dzDHE:gIN9vFw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments