Skip to content

Commit bb92c0a

Browse files
committed
Added a patch for django issue #28772, a check action to apply the patch, and a setting that lists patches to be applied.
- Legacy-Id: 14474
1 parent 9e82bb3 commit bb92c0a

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

ietf/checks.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import patch
23
import sys
34
import time
45
from textwrap import dedent
@@ -155,7 +156,7 @@ def check_yang_model_directories(app_configs, **kwargs):
155156
" %s = %s" % (s, p),
156157
hint = ("Please either update your local settings to point at the correct\n"
157158
"\tdirectory, or if the setting is correct, create the indicated directory.\n"),
158-
id = "datatracker.E0006",
159+
id = "datatracker.E0017",
159160
))
160161
return errors
161162

@@ -285,6 +286,7 @@ def cache_error(msg, errnum):
285286
if not cache.get(key) == val:
286287
errors.append(cache_error("Cache didn't accept session cookie age", "E0016"))
287288
return errors
289+
288290

289291
def maybe_create_svn_symlinks(settings):
290292
site_packages_dir = None
@@ -307,7 +309,7 @@ def maybe_create_svn_symlinks(settings):
307309
" %s\n" % path,
308310
hint = "Please provide the correct python system site-package paths for\n"
309311
"\tsvn and libsvn in SVN_PACKAGES.\n",
310-
id = "datatracker.E0015",))
312+
id = "datatracker.E0018",))
311313
return errors
312314

313315
@checks.register('cache')
@@ -344,10 +346,30 @@ def check_svn_import(app_configs, **kwargs):
344346
available at https://trac.edgewall.org/wiki/TracSubversion.
345347
346348
""").replace('\n', '\n ').rstrip(),
347-
id = "datatracker.E0014",
349+
id = "datatracker.E0019",
348350
))
349351
return errors
350352

353+
@checks.register('files')
354+
def maybe_patch_django_db_model_fields_unicode_comparison(app_configs, **kwargs):
355+
errors = []
356+
for patch_file in settings.CHECKS_PATCHES_TO_APPLY:
357+
patch_set = patch.fromfile(patch_file)
358+
if patch_set:
359+
if not patch_set.apply():
360+
errors.append(checks.Warning(
361+
"Could not apply patch from file '%s'"%patch_file,
362+
hint="Make sure that the patch file contains a unified diff and has valid file paths",
363+
id="datatracker.W0002",
364+
))
365+
else:
366+
errors.append(checks.Warning(
367+
"Could not parse patch file '%s'"%patch_file,
368+
hint="Make sure that the patch file contains a unified diff",
369+
id="datatracker.W0001",
370+
))
371+
return errors
372+
351373
@checks.register('security')
352374
def check_api_key_in_local_settings(app_configs, **kwargs):
353375
errors = []
@@ -366,7 +388,7 @@ def check_api_key_in_local_settings(app_configs, **kwargs):
366388
extract the public key with 'openssl rsa -in apikey.pem -pubout > apikey.pub'.
367389
368390
""").replace('\n', '\n ').rstrip(),
369-
id = "datatracker.E0015",
391+
id = "datatracker.E0020",
370392
))
371393
elif not ( settings_local.API_PUBLIC_KEY_PEM == settings.API_PUBLIC_KEY_PEM
372394
and settings_local.API_PRIVATE_KEY_PEM == settings.API_PRIVATE_KEY_PEM ):
@@ -379,7 +401,7 @@ def check_api_key_in_local_settings(app_configs, **kwargs):
379401
Please check if you have multiple settings_local.py files.
380402
381403
""").replace('\n', '\n ').rstrip(),
382-
id = "datatracker.E0016",
404+
id = "datatracker.E0021",
383405
))
384406

385407
return errors

ietf/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,10 @@ def skip_unreadable_post(record):
927927
"fields.W342", # Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
928928
]
929929

930+
CHECKS_PATCHES_TO_APPLY = [
931+
'patch/fix-django-unicode-comparison-bug.patch',
932+
]
933+
930934
STATS_NAMES_LIMIT = 25
931935

932936
UTILS_TEST_RANDOM_STATE_FILE = '.factoryboy_random_state'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- ./../yang/env/lib/python2.7/site-packages/django/db/models/fields/__init__.py 2017-06-14 08:43:21.665812000 -0700
2+
+++ env/lib/python2.7/site-packages/django/db/models/fields/__init__.py 2017-12-17 14:34:03.023976702 -0800
3+
@@ -2323,7 +2323,7 @@
4+
if self.has_default() and not callable(self.default):
5+
return self.default
6+
default = super(BinaryField, self).get_default()
7+
- if default == '':
8+
+ if isinstance(default, six.text_type) and default == '':
9+
return b''
10+
return default
11+

0 commit comments

Comments
 (0)