create_feed silently fails when feed opened in text mode #393
gmweinberg
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was having a hard time getting create_feed to work. Eventually I discovered you have to open the feed file in binary mode.
The code as it exists will silently fail if the file is opened in text mode.
The problem is thsi:
try:
upload_data = file.read().decode('iso-8859-1')
except AttributeError:
upload_data = file.read()
The "read" inside the try block will succeed, so when the AttributeError: 'str' object has no attribute 'decode' is thrown, the second read comes up empty.
Here's my modified code:
Beta Was this translation helpful? Give feedback.
All reactions