-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python 3 fixes for 'files' #10589
Python 3 fixes for 'files' #10589
Conversation
@@ -457,13 +458,9 @@ def test_unicode(self): | |||
res = self.client.get(self.file_url(u'\u1109\u1161\u11a9')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was fixed by changing the zip file to set the relevant encoding flag in it, because Python 3 behavior for zipfiles without that flag is different now.
Before, it used to return the filenames as bytes, and we'd decode that using utf-8 ourselves. Now, if the flag is absent it uses cp437
, which the the "legacy" encoding for zipfiles, and otherwise falls back to utf-8. The end result for zip files without the flag set is the filenames may look weird in some circumstances, but ultimately should still be coherent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Especially since we don't really touch or modify or extract them anymore. I think that should work, might be worth getting QA trying to break it though.
src/olympia/files/forms.py
Outdated
@@ -38,8 +38,7 @@ def render_options(self, context): | |||
def option(files, label=None, deleted=False, channel=None): | |||
# Make sure that if there's a non-disabled version, | |||
# that's the one we use for the ID. | |||
files.sort(lambda a, b: ((a.status == amo.STATUS_DISABLED) - | |||
(b.status == amo.STATUS_DISABLED))) | |||
sorted(files, key=lambda a: a.status == amo.STATUS_DISABLED) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
The test is confusing but was right all along, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Python 3 fixes for 'files'
mozilla/addons#6324
I'll add a commit that moves them back into
main
(or maybeaddons
? Seems more logical) but first want to see travis pass, confirming what I'm seeing locally.