Skip to content
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

Merged
merged 4 commits into from
Feb 5, 2019
Merged

Python 3 fixes for 'files' #10589

merged 4 commits into from
Feb 5, 2019

Conversation

diox
Copy link
Member

@diox diox commented Feb 4, 2019

mozilla/addons#6324

I'll add a commit that moves them back into main (or maybe addons ? Seems more logical) but first want to see travis pass, confirming what I'm seeing locally.

@@ -457,13 +458,9 @@ def test_unicode(self):
res = self.client.get(self.file_url(u'\u1109\u1161\u11a9'))
Copy link
Member Author

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.

Copy link
Contributor

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.

@@ -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.

This comment was marked as resolved.

@diox diox requested a review from EnTeQuAk February 4, 2019 18:04
Copy link
Contributor

@EnTeQuAk EnTeQuAk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@diox diox merged commit a325c97 into mozilla:master Feb 5, 2019
MelissaAutumn pushed a commit to thunderbird/addons-server that referenced this pull request Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants