diff --git a/django/core/validators.py b/django/core/validators.py index effa5140ce..2092b52cd6 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -61,7 +61,7 @@ class RegexValidator: @deconstructible class URLValidator(RegexValidator): - ul = '\u00a1-\uffff' # unicode letters range (must not be a raw string) + ul = '\u00a1-\uffff' # Unicode letters range (must not be a raw string). # IP patterns ipv4_re = r'(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}' diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 4d2f5b51f1..8285aacdc1 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -38,8 +38,8 @@ def _setup_environment(environ): _setup_environment([ # Oracle takes client-side character set encoding from the environment. ('NLS_LANG', '.AL32UTF8'), - # This prevents unicode from getting mangled by getting encoded into the - # potentially non-unicode database character set. + # This prevents Unicode from getting mangled by getting encoded into the + # potentially non-Unicode database character set. ('ORA_NCHAR_LITERAL_REPLACE', 'TRUE'), ]) diff --git a/django/utils/encoding.py b/django/utils/encoding.py index 080b63d214..e1ebacef47 100644 --- a/django/utils/encoding.py +++ b/django/utils/encoding.py @@ -157,7 +157,7 @@ _hextobyte = { for fmt in ['%02x', '%02X'] } # And then everything above 128, because bytes ≥ 128 are part of multibyte -# unicode characters. +# Unicode characters. _hexdig = '0123456789ABCDEFabcdef' _hextobyte.update({ (a + b).encode(): bytes.fromhex(a + b) diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt index 7b7a184b1a..6374f4e8cd 100644 --- a/docs/ref/validators.txt +++ b/docs/ref/validators.txt @@ -154,7 +154,7 @@ to, or in lieu of custom ``field.clean()`` methods. an error code of ``'invalid'`` if it doesn't. Loopback addresses and reserved IP spaces are considered valid. Literal - IPv6 addresses (:rfc:`3986#section-3.2.2`) and unicode domains are both + IPv6 addresses (:rfc:`3986#section-3.2.2`) and Unicode domains are both supported. In addition to the optional arguments of its parent :class:`RegexValidator` diff --git a/docs/releases/1.3.6.txt b/docs/releases/1.3.6.txt index a808c18b60..8932939425 100644 --- a/docs/releases/1.3.6.txt +++ b/docs/releases/1.3.6.txt @@ -73,6 +73,6 @@ Admin history view information leakage ====================================== In previous versions of Django, an admin user without change permission on a -model could still view the unicode representation of instances via their admin +model could still view the Unicode representation of instances via their admin history log. Django 1.3.6 now limits the admin history log view for an object to users with change permission for that model. diff --git a/docs/releases/1.4.4.txt b/docs/releases/1.4.4.txt index 26b4c56e55..979d1144f3 100644 --- a/docs/releases/1.4.4.txt +++ b/docs/releases/1.4.4.txt @@ -74,7 +74,7 @@ Admin history view information leakage ====================================== In previous versions of Django, an admin user without change permission on a -model could still view the unicode representation of instances via their admin +model could still view the Unicode representation of instances via their admin history log. Django 1.4.4 now limits the admin history log view for an object to users with change permission for that model. diff --git a/docs/releases/1.5.2.txt b/docs/releases/1.5.2.txt index 33341342a6..e4f21bc5ae 100644 --- a/docs/releases/1.5.2.txt +++ b/docs/releases/1.5.2.txt @@ -52,7 +52,7 @@ Bugfixes * Fixed ``geojson`` detection with SpatiaLite. * :meth:`~django.test.SimpleTestCase.assertContains` once again works with binary content (#20237). -* Fixed :class:`~django.db.models.ManyToManyField` if it has a unicode ``name`` +* Fixed :class:`~django.db.models.ManyToManyField` if it has a Unicode ``name`` parameter (#20207). * Ensured that the WSGI request's path is correctly based on the ``SCRIPT_NAME`` environment variable or the :setting:`FORCE_SCRIPT_NAME` diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt index 502667c0f1..44d567931a 100644 --- a/docs/releases/1.5.txt +++ b/docs/releases/1.5.txt @@ -499,7 +499,7 @@ There are no known incompatibilities between Django's copy of version 2.0.7 and Python's copy of version 2.0.9. However, there are some incompatibilities between other versions of ``simplejson``: -- While the ``simplejson`` API is documented as always returning unicode +- While the ``simplejson`` API is documented as always returning Unicode strings, the optional C implementation can return a bytestring. This was fixed in Python 2.7. - ``simplejson.JSONEncoder`` gained a ``namedtuple_as_object`` keyword diff --git a/docs/releases/1.6.1.txt b/docs/releases/1.6.1.txt index 28fb4358e0..995cf95934 100644 --- a/docs/releases/1.6.1.txt +++ b/docs/releases/1.6.1.txt @@ -25,7 +25,7 @@ Bug fixes * Added missing ``to_python`` method for ``ModelMultipleChoiceField`` which is required in Django 1.6 to properly detect changes from initial values (#21568). -* Fixed ``django.contrib.humanize`` translations where the unicode sequence +* Fixed ``django.contrib.humanize`` translations where the Unicode sequence for the non-breaking space was returned verbatim (#21415). * Fixed :djadmin:`loaddata` error when fixture file name contained any dots not related to file extensions (#21457) or when fixture path was relative diff --git a/docs/releases/1.6.6.txt b/docs/releases/1.6.6.txt index 42ad2f8b5f..38e2304c5d 100644 --- a/docs/releases/1.6.6.txt +++ b/docs/releases/1.6.6.txt @@ -84,7 +84,7 @@ Bugfixes * Fixed the "ORA-01843: not a valid month" errors when using Unicode with older versions of Oracle server (:ticket:`20292`). -* Restored bug fix for sending unicode email with Python 2.6.5 and below +* Restored bug fix for sending Unicode email with Python 2.6.5 and below (:ticket:`19107`). * Prevented ``UnicodeDecodeError`` in ``runserver`` with non-UTF-8 and diff --git a/docs/releases/1.7.1.txt b/docs/releases/1.7.1.txt index bb30e2c62d..6cf0e9edf4 100644 --- a/docs/releases/1.7.1.txt +++ b/docs/releases/1.7.1.txt @@ -83,7 +83,7 @@ Bugfixes * Added ``SchemaEditor`` for Oracle GIS backend so that spatial metadata and indexes will be created for apps with migrations (:ticket:`23537`). -* Coerced the ``related_name`` model field option to unicode during migration +* Coerced the ``related_name`` model field option to Unicode during migration generation to generate migrations that work with both Python 2 and 3 (:ticket:`23455`). diff --git a/docs/releases/1.7.2.txt b/docs/releases/1.7.2.txt index 171d938861..d057295017 100644 --- a/docs/releases/1.7.2.txt +++ b/docs/releases/1.7.2.txt @@ -125,7 +125,7 @@ Bugfixes * Fixed a crash in the admin when using "Save as new" and also deleting a related inline (:ticket:`23857`). -* Always converted ``related_name`` to text (unicode), since that is required +* Always converted ``related_name`` to text (Unicode), since that is required on Python 3 for interpolation. Removed conversion of ``related_name`` to text in migration deconstruction (:ticket:`23455` and :ticket:`23982`). diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt index 0e7a2da6c6..fab2fe9187 100644 --- a/docs/releases/1.8.txt +++ b/docs/releases/1.8.txt @@ -658,7 +658,7 @@ Validators ~~~~~~~~~~ * :class:`~django.core.validators.URLValidator` now supports IPv6 addresses, - unicode domains, and URLs containing authentication data. + Unicode domains, and URLs containing authentication data. .. _backwards-incompatible-1.8: diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index c085f65447..e774f9e558 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -345,7 +345,7 @@ Removed support for bytestrings in some places ---------------------------------------------- To support native Python 2 strings, older Django versions had to accept both -bytestrings and unicode strings. Now that Python 2 support is dropped, +bytestrings and Unicode strings. Now that Python 2 support is dropped, bytestrings should only be encountered around input/output boundaries (handling of binary fields or HTTP streams, for example). You might have to update your code to limit bytestring usage to a minimum, as Django no longer accepts diff --git a/docs/spelling_wordlist b/docs/spelling_wordlist index 63e7c3dbb4..cb1d869147 100644 --- a/docs/spelling_wordlist +++ b/docs/spelling_wordlist @@ -724,7 +724,6 @@ ungrouped unhandled unharmful unhashable -unicode uninstall uninstalling unioning diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index 354ef95a69..eb816c690b 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -418,7 +418,7 @@ arbitrary Python code. For example, the following won't work because the `requests `_ library doesn't handle ``gettext_lazy`` objects:: - body = gettext_lazy("I \u2764 Django") # (unicode :heart:) + body = gettext_lazy("I \u2764 Django") # (Unicode :heart:) requests.post('https://example.com/send', data={'body': body}) You can avoid such problems by casting ``gettext_lazy()`` objects to text diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 6266619216..222d55f023 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -570,7 +570,7 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase): self.assertTrue(os.path.exists(os.path.join(app_path, 'api.py'))) def test_startapp_unicode_name(self): - "directory: startapp creates the correct directory with unicode characters" + """startapp creates the correct directory with Unicode characters.""" args = ['startapp', 'こんにちは'] app_path = os.path.join(self.test_dir, 'こんにちは') out, err = self.run_django_admin(args, 'test_project.settings') diff --git a/tests/admin_views/models.py b/tests/admin_views/models.py index 16dd58bcd3..ba818ea10e 100644 --- a/tests/admin_views/models.py +++ b/tests/admin_views/models.py @@ -458,12 +458,12 @@ class PrePopulatedSubPost(models.Model): class Post(models.Model): - title = models.CharField(max_length=100, help_text="Some help text for the title (with unicode ŠĐĆŽćžšđ)") - content = models.TextField(help_text="Some help text for the content (with unicode ŠĐĆŽćžšđ)") + title = models.CharField(max_length=100, help_text='Some help text for the title (with Unicode ŠĐĆŽćžšđ)') + content = models.TextField(help_text='Some help text for the content (with Unicode ŠĐĆŽćžšđ)') readonly_content = models.TextField() posted = models.DateField( default=datetime.date.today, - help_text="Some help text for the date (with unicode ŠĐĆŽćžšđ)" + help_text='Some help text for the date (with Unicode ŠĐĆŽćžšđ)', ) public = models.BooleanField(null=True, blank=True) diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 8fde8ed45c..37818f7f65 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -4842,17 +4842,17 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase): self.assertContains(response, '
', 3) self.assertContains( response, - '
Some help text for the title (with unicode ŠĐĆŽćžšđ)
', + '
Some help text for the title (with Unicode ŠĐĆŽćžšđ)
', html=True ) self.assertContains( response, - '
Some help text for the content (with unicode ŠĐĆŽćžšđ)
', + '
Some help text for the content (with Unicode ŠĐĆŽćžšđ)
', html=True ) self.assertContains( response, - '
Some help text for the date (with unicode ŠĐĆŽćžšđ)
', + '
Some help text for the date (with Unicode ŠĐĆŽćžšđ)
', html=True ) @@ -4962,7 +4962,7 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase): response = self.client.get(reverse('admin:admin_views_fieldoverridepost_change', args=(p.pk,))) self.assertContains(response, '
Overridden help text for the date
') self.assertContains(response, '', html=True) - self.assertNotContains(response, "Some help text for the date (with unicode ŠĐĆŽćžšđ)") + self.assertNotContains(response, 'Some help text for the date (with Unicode ŠĐĆŽćžšđ)') def test_correct_autoescaping(self): """ diff --git a/tests/auth_tests/test_basic.py b/tests/auth_tests/test_basic.py index 9e0d8e863e..4cba35eb41 100644 --- a/tests/auth_tests/test_basic.py +++ b/tests/auth_tests/test_basic.py @@ -44,7 +44,7 @@ class BasicTestCase(TestCase): def test_unicode_username(self): User.objects.create_user('jörg') User.objects.create_user('Григорий') - # Two equivalent unicode normalized usernames should be duplicates + # Two equivalent Unicode normalized usernames are duplicates. omega_username = 'iamtheΩ' # U+03A9 GREEK CAPITAL LETTER OMEGA ohm_username = 'iamtheΩ' # U+2126 OHM SIGN User.objects.create_user(ohm_username) diff --git a/tests/backends/tests.py b/tests/backends/tests.py index 40fc6de7fc..08bdac3437 100644 --- a/tests/backends/tests.py +++ b/tests/backends/tests.py @@ -317,7 +317,7 @@ class BackendTestCase(TransactionTestCase): self.assertEqual(Square.objects.count(), 9) def test_unicode_fetches(self): - # fetchone, fetchmany, fetchall return strings as unicode objects #6254 + # fetchone, fetchmany, fetchall return strings as Unicode objects. qn = connection.ops.quote_name Person(first_name="John", last_name="Doe").save() Person(first_name="Jane", last_name="Doe").save() @@ -349,7 +349,7 @@ class BackendTestCase(TransactionTestCase): # As password is probably wrong, a database exception is expected pass except Exception as e: - self.fail("Unexpected error raised with unicode password: %s" % e) + self.fail('Unexpected error raised with Unicode password: %s' % e) finally: connection.settings_dict['PASSWORD'] = old_password diff --git a/tests/custom_pk/tests.py b/tests/custom_pk/tests.py index da0cff14cc..934ed248ea 100644 --- a/tests/custom_pk/tests.py +++ b/tests/custom_pk/tests.py @@ -187,7 +187,7 @@ class CustomPKTests(TestCase): Business.objects.create(pk="Tears") def test_unicode_pk(self): - # Primary key may be unicode string + # Primary key may be Unicode string. Business.objects.create(name='jaźń') def test_unique_pk(self): diff --git a/tests/file_uploads/views.py b/tests/file_uploads/views.py index 36c9fc12a2..ff381c0a05 100644 --- a/tests/file_uploads/views.py +++ b/tests/file_uploads/views.py @@ -54,7 +54,7 @@ def file_upload_view_verify(request): def file_upload_unicode_name(request): - # Check to see if unicode name came through properly. + # Check to see if Unicode name came through properly. if not request.FILES['file_unicode'].name.endswith(UNICODE_FILENAME): return HttpResponseServerError() # Check to make sure the exotic characters are preserved even diff --git a/tests/forms_tests/tests/test_utils.py b/tests/forms_tests/tests/test_utils.py index c849bfd262..ea0949920e 100644 --- a/tests/forms_tests/tests/test_utils.py +++ b/tests/forms_tests/tests/test_utils.py @@ -59,7 +59,7 @@ class FormsUtilsTestCase(SimpleTestCase): str(ErrorList(ValidationError("There was an error.").messages)), '' ) - # Can take a unicode string. + # Can take a Unicode string. self.assertHTMLEqual( str(ErrorList(ValidationError("Not \u03C0.").messages)), '' diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py index de04e8a3bc..18b4c58b5e 100644 --- a/tests/forms_tests/tests/tests.py +++ b/tests/forms_tests/tests/tests.py @@ -150,7 +150,7 @@ class ModelFormCallableModelDefault(TestCase): class FormsModelTestCase(TestCase): def test_unicode_filename(self): - # FileModel with unicode filename and data ######################### + # FileModel with Unicode filename and data ######################### file1 = SimpleUploadedFile('我隻氣墊船裝滿晒鱔.txt', 'मेरी मँडराने वाली नाव सर्पमीनों से भरी ह'.encode()) f = FileForm(data={}, files={'file1': file1}, auto_id=False) self.assertTrue(f.is_valid()) diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py index 3d322ec6ed..3b655a91c2 100644 --- a/tests/handlers/tests.py +++ b/tests/handlers/tests.py @@ -50,7 +50,7 @@ class HandlerTests(SimpleTestCase): environ['QUERY_STRING'] = str(raw_query_string, 'iso-8859-1') request = WSGIRequest(environ) got.append(request.GET['want']) - # %E9 is converted to the unicode replacement character by parse_qsl + # %E9 is converted to the Unicode replacement character by parse_qsl self.assertEqual(got, ['café', 'café', 'caf\ufffd', 'café']) def test_non_ascii_cookie(self): diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py index bafdd2891c..04c2a9516c 100644 --- a/tests/httpwrappers/tests.py +++ b/tests/httpwrappers/tests.py @@ -302,7 +302,8 @@ class HttpResponseTests(unittest.TestCase): r['key'] = 'café' self.assertIn('café'.encode('latin-1'), r.serialize_headers()) - # Other unicode values are MIME-encoded (there's no way to pass them as bytes). + # Other Unicode values are MIME-encoded (there's no way to pass them as + # bytes). r['key'] = '†' self.assertEqual(r['key'], '=?utf-8?b?4oCg?=') self.assertIn(b'=?utf-8?b?4oCg?=', r.serialize_headers()) diff --git a/tests/mail/tests.py b/tests/mail/tests.py index 84aa8dc498..1f8c6b12bf 100644 --- a/tests/mail/tests.py +++ b/tests/mail/tests.py @@ -302,7 +302,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase): def test_unicode_address_header(self): """ - Regression for #11144 - When a to/from/cc header contains unicode, + Regression for #11144 - When a to/from/cc header contains Unicode, make sure the email addresses are parsed correctly (especially with regards to commas) """ diff --git a/tests/responses/test_cookie.py b/tests/responses/test_cookie.py index 36cb43ed81..a52443eefe 100644 --- a/tests/responses/test_cookie.py +++ b/tests/responses/test_cookie.py @@ -73,7 +73,7 @@ class SetCookieTests(SimpleTestCase): self.assertIs(example_cookie['httponly'], True) def test_unicode_cookie(self): - """HttpResponse.set_cookie() works with unicode data.""" + """HttpResponse.set_cookie() works with Unicode data.""" response = HttpResponse() cookie_value = '清風' response.set_cookie('test', cookie_value) diff --git a/tests/template_tests/syntax_tests/test_autoescape.py b/tests/template_tests/syntax_tests/test_autoescape.py index 810731978b..e684bc94bd 100644 --- a/tests/template_tests/syntax_tests/test_autoescape.py +++ b/tests/template_tests/syntax_tests/test_autoescape.py @@ -36,7 +36,7 @@ class AutoescapeTagTests(SimpleTestCase): output = self.engine.render_to_string('autoescape-tag05', {'first': 'first'}) self.assertEqual(output, '<b>first</b>') - # Strings (ASCII or unicode) already marked as "safe" are not + # Strings (ASCII or Unicode) already marked as "safe" are not # auto-escaped @setup({'autoescape-tag06': '{{ first }}'}) def test_autoescape_tag06(self): diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index 59f8ddd26b..4e90d720ee 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -806,10 +806,10 @@ class HTMLEqualTests(SimpleTestCase): self.assertContains(response, '

') def test_unicode_handling(self): - response = HttpResponse('

Some help text for the title (with unicode ŠĐĆŽćžšđ)

') + response = HttpResponse('

Some help text for the title (with Unicode ŠĐĆŽćžšđ)

') self.assertContains( response, - '

Some help text for the title (with unicode ŠĐĆŽćžšđ)

', + '

Some help text for the title (with Unicode ŠĐĆŽćžšđ)

', html=True ) diff --git a/tests/utils_tests/test_text.py b/tests/utils_tests/test_text.py index 66dbd5b366..9dbf9367c3 100644 --- a/tests/utils_tests/test_text.py +++ b/tests/utils_tests/test_text.py @@ -189,7 +189,7 @@ class TestUtilsText(SimpleTestCase): def test_slugify(self): items = ( - # given - expected - unicode? + # given - expected - Unicode? ('Hello, World!', 'hello-world', False), ('spam & eggs', 'spam-eggs', False), ('spam & ıçüş', 'spam-ıçüş', True), diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py index dd07aa9f93..fcbffa711d 100644 --- a/tests/view_tests/tests/test_i18n.py +++ b/tests/view_tests/tests/test_i18n.py @@ -252,7 +252,7 @@ class I18NViewTests(SimpleTestCase): self.assertEqual(response['Content-Type'], 'text/javascript; charset="utf-8"') # response content must include a line like: # "this is to be translated": - # json.dumps() is used to be able to check unicode strings + # json.dumps() is used to be able to check Unicode strings. self.assertContains(response, json.dumps(trans_txt), 1) if lang_code == 'fr': # Message with context (msgctxt)