Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #20462 - Replaced the str() cast introduced in 273dc55 by force…

…_text()
  • Loading branch information...
commit a9ea7d8c708c8265cccc17f23c62b2268d9e94f8 1 parent 273dc55
Loic Bistuer authored June 26, 2013
3  django/db/backends/sqlite3/base.py
@@ -19,6 +19,7 @@
19 19
 from django.db.models import fields
20 20
 from django.db.models.sql import aggregates
21 21
 from django.utils.dateparse import parse_date, parse_datetime, parse_time
  22
+from django.utils.encoding import force_text
22 23
 from django.utils.functional import cached_property
23 24
 from django.utils.safestring import SafeBytes
24 25
 from django.utils import six
@@ -522,4 +523,4 @@ def _sqlite_format_dtdelta(dt, conn, days, secs, usecs):
522 523
     return str(dt)
523 524
 
524 525
 def _sqlite_regexp(re_pattern, re_string):
525  
-    return bool(re.search(re_pattern, str(re_string))) if re_string is not None else False
  526
+    return bool(re.search(re_pattern, force_text(re_string))) if re_string is not None else False
7  tests/lookup/tests.py
@@ -625,6 +625,13 @@ def test_regex_non_string(self):
625 625
         self.assertQuerysetEqual(Season.objects.filter(gt__regex=r'^444$'),
626 626
             ['<Season: 2013>'])
627 627
 
  628
+    def test_regex_non_ascii(self):
  629
+        """
  630
+        Ensure that a regex lookup does not trip on non-ascii characters.
  631
+        """
  632
+        Player.objects.create(name='\u2660')
  633
+        Player.objects.get(name__regex='\u2660')
  634
+
628 635
     def test_nonfield_lookups(self):
629 636
         """
630 637
         Ensure that a lookup query containing non-fields raises the proper

0 notes on commit a9ea7d8

Please sign in to comment.
Something went wrong with that request. Please try again.