Py3: Fix error handling in download plugin#1081
Conversation
While trying to store an error page, the plugin returned: TypeError: write() argument must be str, not bytes
|
|
flexget/plugins/output/download.py
Outdated
| if not os.path.isdir(received): | ||
| os.makedirs(received) | ||
| filename = os.path.join(received, '%s.error' % entry['title'].encode(sys.getfilesystemencoding(), 'replace')) | ||
| filename = os.path.join(received, '%s.error' % entry['title'].encode(sys.getfilesystemencoding(), 'replace').decode(sys.getfilesystemencoding())) |
There was a problem hiding this comment.
Hmm, we are encoding then decoding?? that does not sound right?
what error did you get?
There was a problem hiding this comment.
The error came below. For this line, I noticed that the filename shows up as:
path/to/b'entry title'.error
as opposed to (in Py2)
path/to/entry title.error
Encode then decode in this case would at least drop characters that are not valid in the file system encoding, which I'm guessing at some point fixed a bug. I do wonder though if maybe we shouldn't change the way the file name is generated. Perhaps using pathscrub?
|
hmm yeah i think we can just do entry['title'] now as we enforce it to be text here Lines 189 to 194 in 646d6ed do you want to update the PR? |
|
Maybe we should use path.py for these filename operations rather than raw text |
|
How's this? |
|
hmm looks ok to me.. @gazpachoking ? |
|
Looks fine to me. |
|
@jeroenl Wanna sync this so we can merge? |
While trying to store an error page, the plugin returned:
TypeError: write() argument must be str, not bytes