| Author | SHA1 | Nachricht | Datum |
|---|---|---|---|
|
|
22fdc5db34 | vor 1 Woche |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 |
import json |
| 4 | 4 |
|
| 5 | 5 |
from django.db import transaction |
| 6 |
-from django.utils.encoding import force_text |
|
| 7 | 6 |
from django.db.models import Count, Q |
| 8 | 7 |
from django_logit import logit |
| 9 | 8 |
from django_response import response |
@@ -46,15 +45,13 @@ def _parse_rule_sections(value): |
||
| 46 | 45 |
if not isinstance(section, dict): |
| 47 | 46 |
raise ValueError('rule section must be an object')
|
| 48 | 47 |
|
| 49 |
- title = force_text(section.get('title') or '').strip()
|
|
| 48 |
+ title = (section.get('title') or '').strip()
|
|
| 50 | 49 |
items = section.get('items') or []
|
| 51 | 50 |
|
| 52 | 51 |
if not isinstance(items, list): |
| 53 | 52 |
raise ValueError('rule section items must be a list')
|
| 54 | 53 |
|
| 55 |
- # 不能用 str():py2 下 str(unicode 中文) 抛 UnicodeEncodeError, |
|
| 56 |
- # 而它是 ValueError 的子类,会被外层 except 吞成「参数格式不正确」 |
|
| 57 |
- items = [text for text in (force_text(item).strip() for item in items) if text] |
|
| 54 |
+ items = [str(item).strip() for item in items if str(item).strip()] |
|
| 58 | 55 |
|
| 59 | 56 |
if title or items: |
| 60 | 57 |
cleaned.append({'title': title, 'items': items})
|