Skip to content

Commit 7d5bd3f

Browse files
committed
Modified the patch actions run under the 'check' management command to patch an issue with a unidecode lib warning.
- Legacy-Id: 14535
1 parent d2441c7 commit 7d5bd3f

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

ietf/checks.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,20 +351,22 @@ def check_svn_import(app_configs, **kwargs):
351351
return errors
352352

353353
@checks.register('files')
354-
def maybe_patch_django(app_configs, **kwargs):
354+
def maybe_patch_library(app_configs, **kwargs):
355355
errors = []
356356
# Change path to our copy of django (this assumes we're running in a
357357
# virtualenv, which we should)
358358
import os, django
359359
django_path = os.path.dirname(django.__file__)
360-
parent_path = os.path.dirname(django_path)
360+
library_path = os.path.dirname(django_path)
361361
saved_cwd = os.getcwd()
362-
os.chdir(parent_path)
363-
# All patches in settings.CHECKS_DJANGO_PATCHES_TO_APPLY must have a
362+
os.chdir(library_path)
363+
# All patches in settings.CHECKS_LIBRARY_PATCHES_TO_APPLY must have a
364364
# relative file path rooted in the django dir, for instance
365365
# 'django/db/models/fields/__init__.py'
366-
for patch_file in settings.CHECKS_DJANGO_PATCHES_TO_APPLY:
366+
for patch_file in settings.CHECKS_LIBRARY_PATCHES_TO_APPLY:
367367
patch_path = os.path.join(saved_cwd, patch_file)
368+
with open(patch_path) as f:
369+
p = f.read()
368370
patch_set = patch.fromfile(patch_path)
369371
if patch_set:
370372
if not patch_set.apply():

ietf/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,9 @@ 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_DJANGO_PATCHES_TO_APPLY = [
930+
CHECKS_LIBRARY_PATCHES_TO_APPLY = [
931931
'patch/fix-django-unicode-comparison-bug.patch',
932+
'patch/fix-unidecode-argument-warning.patch',
932933
]
933934

934935
STATS_NAMES_LIMIT = 25
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- unidecode/__init__.py.old 2018-01-17 07:54:06.882306379 -0800
2+
+++ unidecode/__init__.py 2018-01-09 04:26:04.210366000 -0800
3+
@@ -22,9 +22,9 @@
4+
5+
def _warn_if_not_unicode(string):
6+
if version_info[0] < 3 and not isinstance(string, unicode):
7+
- warnings.warn( "Argument %r is not an unicode object. "
8+
+ warnings.warn( "Argument %r (%s) is not an unicode object. "
9+
"Passing an encoded string will likely have "
10+
- "unexpected results." % (type(string),),
11+
+ "unexpected results." % (type(string), string[:16]),
12+
RuntimeWarning, 2)
13+
14+

0 commit comments

Comments
 (0)