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
This commit is contained in:
parent
9e82bb3d90
commit
bb92c0a076
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import patch
|
||||
import sys
|
||||
import time
|
||||
from textwrap import dedent
|
||||
|
@ -155,7 +156,7 @@ def check_yang_model_directories(app_configs, **kwargs):
|
|||
" %s = %s" % (s, p),
|
||||
hint = ("Please either update your local settings to point at the correct\n"
|
||||
"\tdirectory, or if the setting is correct, create the indicated directory.\n"),
|
||||
id = "datatracker.E0006",
|
||||
id = "datatracker.E0017",
|
||||
))
|
||||
return errors
|
||||
|
||||
|
@ -286,6 +287,7 @@ def check_cache(app_configs, **kwargs):
|
|||
errors.append(cache_error("Cache didn't accept session cookie age", "E0016"))
|
||||
return errors
|
||||
|
||||
|
||||
def maybe_create_svn_symlinks(settings):
|
||||
site_packages_dir = None
|
||||
errors = []
|
||||
|
@ -307,7 +309,7 @@ def maybe_create_svn_symlinks(settings):
|
|||
" %s\n" % path,
|
||||
hint = "Please provide the correct python system site-package paths for\n"
|
||||
"\tsvn and libsvn in SVN_PACKAGES.\n",
|
||||
id = "datatracker.E0015",))
|
||||
id = "datatracker.E0018",))
|
||||
return errors
|
||||
|
||||
@checks.register('cache')
|
||||
|
@ -344,10 +346,30 @@ def check_svn_import(app_configs, **kwargs):
|
|||
available at https://trac.edgewall.org/wiki/TracSubversion.
|
||||
|
||||
""").replace('\n', '\n ').rstrip(),
|
||||
id = "datatracker.E0014",
|
||||
id = "datatracker.E0019",
|
||||
))
|
||||
return errors
|
||||
|
||||
@checks.register('files')
|
||||
def maybe_patch_django_db_model_fields_unicode_comparison(app_configs, **kwargs):
|
||||
errors = []
|
||||
for patch_file in settings.CHECKS_PATCHES_TO_APPLY:
|
||||
patch_set = patch.fromfile(patch_file)
|
||||
if patch_set:
|
||||
if not patch_set.apply():
|
||||
errors.append(checks.Warning(
|
||||
"Could not apply patch from file '%s'"%patch_file,
|
||||
hint="Make sure that the patch file contains a unified diff and has valid file paths",
|
||||
id="datatracker.W0002",
|
||||
))
|
||||
else:
|
||||
errors.append(checks.Warning(
|
||||
"Could not parse patch file '%s'"%patch_file,
|
||||
hint="Make sure that the patch file contains a unified diff",
|
||||
id="datatracker.W0001",
|
||||
))
|
||||
return errors
|
||||
|
||||
@checks.register('security')
|
||||
def check_api_key_in_local_settings(app_configs, **kwargs):
|
||||
errors = []
|
||||
|
@ -366,7 +388,7 @@ def check_api_key_in_local_settings(app_configs, **kwargs):
|
|||
extract the public key with 'openssl rsa -in apikey.pem -pubout > apikey.pub'.
|
||||
|
||||
""").replace('\n', '\n ').rstrip(),
|
||||
id = "datatracker.E0015",
|
||||
id = "datatracker.E0020",
|
||||
))
|
||||
elif not ( settings_local.API_PUBLIC_KEY_PEM == settings.API_PUBLIC_KEY_PEM
|
||||
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):
|
|||
Please check if you have multiple settings_local.py files.
|
||||
|
||||
""").replace('\n', '\n ').rstrip(),
|
||||
id = "datatracker.E0016",
|
||||
id = "datatracker.E0021",
|
||||
))
|
||||
|
||||
return errors
|
||||
|
|
|
@ -927,6 +927,10 @@ SILENCED_SYSTEM_CHECKS = [
|
|||
"fields.W342", # Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
|
||||
]
|
||||
|
||||
CHECKS_PATCHES_TO_APPLY = [
|
||||
'patch/fix-django-unicode-comparison-bug.patch',
|
||||
]
|
||||
|
||||
STATS_NAMES_LIMIT = 25
|
||||
|
||||
UTILS_TEST_RANDOM_STATE_FILE = '.factoryboy_random_state'
|
||||
|
|
11
patch/fix-django-unicode-comparison-bug.patch
Normal file
11
patch/fix-django-unicode-comparison-bug.patch
Normal file
|
@ -0,0 +1,11 @@
|
|||
--- ./../yang/env/lib/python2.7/site-packages/django/db/models/fields/__init__.py 2017-06-14 08:43:21.665812000 -0700
|
||||
+++ env/lib/python2.7/site-packages/django/db/models/fields/__init__.py 2017-12-17 14:34:03.023976702 -0800
|
||||
@@ -2323,7 +2323,7 @@
|
||||
if self.has_default() and not callable(self.default):
|
||||
return self.default
|
||||
default = super(BinaryField, self).get_default()
|
||||
- if default == '':
|
||||
+ if isinstance(default, six.text_type) and default == '':
|
||||
return b''
|
||||
return default
|
||||
|
Loading…
Reference in a new issue