Modified the patch actions run under the 'check' management command to patch an issue with a unidecode lib warning.

- Legacy-Id: 14535
This commit is contained in:
Henrik Levkowetz 2018-01-17 19:27:52 +00:00
parent d2441c7921
commit 7d5bd3f5d5
3 changed files with 23 additions and 6 deletions

View file

@ -351,20 +351,22 @@ def check_svn_import(app_configs, **kwargs):
return errors return errors
@checks.register('files') @checks.register('files')
def maybe_patch_django(app_configs, **kwargs): def maybe_patch_library(app_configs, **kwargs):
errors = [] errors = []
# Change path to our copy of django (this assumes we're running in a # Change path to our copy of django (this assumes we're running in a
# virtualenv, which we should) # virtualenv, which we should)
import os, django import os, django
django_path = os.path.dirname(django.__file__) django_path = os.path.dirname(django.__file__)
parent_path = os.path.dirname(django_path) library_path = os.path.dirname(django_path)
saved_cwd = os.getcwd() saved_cwd = os.getcwd()
os.chdir(parent_path) os.chdir(library_path)
# All patches in settings.CHECKS_DJANGO_PATCHES_TO_APPLY must have a # All patches in settings.CHECKS_LIBRARY_PATCHES_TO_APPLY must have a
# relative file path rooted in the django dir, for instance # relative file path rooted in the django dir, for instance
# 'django/db/models/fields/__init__.py' # 'django/db/models/fields/__init__.py'
for patch_file in settings.CHECKS_DJANGO_PATCHES_TO_APPLY: for patch_file in settings.CHECKS_LIBRARY_PATCHES_TO_APPLY:
patch_path = os.path.join(saved_cwd, patch_file) patch_path = os.path.join(saved_cwd, patch_file)
with open(patch_path) as f:
p = f.read()
patch_set = patch.fromfile(patch_path) patch_set = patch.fromfile(patch_path)
if patch_set: if patch_set:
if not patch_set.apply(): if not patch_set.apply():

View file

@ -927,8 +927,9 @@ SILENCED_SYSTEM_CHECKS = [
"fields.W342", # Setting unique=True on a ForeignKey has the same effect as using a OneToOneField. "fields.W342", # Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
] ]
CHECKS_DJANGO_PATCHES_TO_APPLY = [ CHECKS_LIBRARY_PATCHES_TO_APPLY = [
'patch/fix-django-unicode-comparison-bug.patch', 'patch/fix-django-unicode-comparison-bug.patch',
'patch/fix-unidecode-argument-warning.patch',
] ]
STATS_NAMES_LIMIT = 25 STATS_NAMES_LIMIT = 25

View file

@ -0,0 +1,14 @@
--- unidecode/__init__.py.old 2018-01-17 07:54:06.882306379 -0800
+++ unidecode/__init__.py 2018-01-09 04:26:04.210366000 -0800
@@ -22,9 +22,9 @@
def _warn_if_not_unicode(string):
if version_info[0] < 3 and not isinstance(string, unicode):
- warnings.warn( "Argument %r is not an unicode object. "
+ warnings.warn( "Argument %r (%s) is not an unicode object. "
"Passing an encoded string will likely have "
- "unexpected results." % (type(string),),
+ "unexpected results." % (type(string), string[:16]),
RuntimeWarning, 2)