0001-trivial-remove-conditional-Python-2-code-42003.patch
combo/apps/lingo/manager_views.py | ||
---|---|---|
185 | 185 |
str(transaction.amount)] |
186 | 186 |
for item in transaction.items.all(): |
187 | 187 |
row.extend([item.subject, str(item.amount)]) |
188 |
if six.PY3: |
|
189 |
writer.writerow([x for x in row]) |
|
190 |
else: |
|
191 |
writer.writerow([unicode(x).encode('utf-8') for x in row]) |
|
188 |
writer.writerow([x for x in row]) |
|
192 | 189 |
return response |
193 | 190 |
else: |
194 | 191 |
form = TransactionExportForm() |
combo/apps/pwa/models.py | ||
---|---|---|
144 | 144 |
serialized_entry = json.loads(serializers.serialize('json', [self], |
145 | 145 |
use_natural_foreign_keys=True, use_natural_primary_keys=True))[0] |
146 | 146 |
if self.icon: |
147 |
encode = base64.encodestring if six.PY2 else base64.encodebytes |
|
148 |
serialized_entry['icon:base64'] = force_text(encode(self.icon.read())) |
|
147 |
serialized_entry['icon:base64'] = force_text(base64.encodebytes(self.icon.read())) |
|
149 | 148 |
del serialized_entry['model'] |
150 | 149 |
del serialized_entry['pk'] |
151 | 150 |
return serialized_entry |
... | ... | |
170 | 169 |
entry = next(serializers.deserialize('json', json.dumps([json_entry]), ignorenonexistent=True)) |
171 | 170 |
entry.save() |
172 | 171 |
if json_entry.get('icon:base64'): |
173 |
decode = base64.decodestring if six.PY2 else base64.decodebytes |
|
174 |
decoded_icon = decode(force_bytes(json_entry['icon:base64'])) |
|
172 |
decoded_icon = base64.decodebytes(force_bytes(json_entry['icon:base64'])) |
|
175 | 173 |
if not default_storage.exists(entry.object.icon.name) or entry.object.icon.read() != decoded_icon: |
176 | 174 |
# save new file |
177 | 175 |
entry.object.icon.save(entry.object.icon.name, ContentFile(decoded_icon)) |
combo/utils/signature.py | ||
---|---|---|
100 | 100 |
continue |
101 | 101 |
res = 0 |
102 | 102 |
# constant time compare |
103 |
if six.PY3: |
|
104 |
for a, b in zip(signature, signature2): |
|
105 |
res |= a ^ b |
|
106 |
else: |
|
107 |
for a, b in zip(signature, signature2): |
|
108 |
res |= ord(a) ^ ord(b) |
|
103 |
for a, b in zip(signature, signature2): |
|
104 |
res |= a ^ b |
|
109 | 105 |
if res == 0: |
110 | 106 |
return True |
111 | 107 |
return False |
setup.py | ||
---|---|---|
145 | 145 |
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', |
146 | 146 |
'Operating System :: OS Independent', |
147 | 147 |
'Programming Language :: Python', |
148 |
'Programming Language :: Python :: 2', |
|
149 | 148 |
'Programming Language :: Python :: 3', |
150 | 149 |
], |
151 | 150 |
install_requires=['django>=1.11, <2.3', |
tests/test_public.py | ||
---|---|---|
88 | 88 |
assert urlparse.urlparse(resp.location).path == '/accounts/mellon/login/' |
89 | 89 |
resp = app.get('/login/?next=whatever') |
90 | 90 |
assert urlparse.urlparse(resp.location).query == 'next=whatever' |
91 |
if six.PY2: |
|
92 |
resp = app.get('/login/?next=%e0%40', status=400) |
|
91 | ||
93 | 92 | |
94 | 93 |
def test_page_contents_group_presence(app, normal_user): |
95 | 94 |
group = Group(name='plop') |
96 |
- |