mirror of
https://github.com/django/django.git
synced 2024-11-22 11:57:34 +01:00
Capitalized Unicode in docs, strings, and comments.
This commit is contained in:
parent
3152146e3a
commit
505fec6bad
@ -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}'
|
||||
|
@ -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'),
|
||||
])
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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`
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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`
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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`).
|
||||
|
||||
|
@ -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`).
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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
|
||||
|
@ -724,7 +724,6 @@ ungrouped
|
||||
unhandled
|
||||
unharmful
|
||||
unhashable
|
||||
unicode
|
||||
uninstall
|
||||
uninstalling
|
||||
unioning
|
||||
|
@ -418,7 +418,7 @@ arbitrary Python code. For example, the following won't work because the
|
||||
`requests <https://pypi.org/project/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
|
||||
|
@ -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')
|
||||
|
@ -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)
|
||||
|
||||
|
@ -4842,17 +4842,17 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase):
|
||||
self.assertContains(response, '<div class="help">', 3)
|
||||
self.assertContains(
|
||||
response,
|
||||
'<div class="help">Some help text for the title (with unicode ŠĐĆŽćžšđ)</div>',
|
||||
'<div class="help">Some help text for the title (with Unicode ŠĐĆŽćžšđ)</div>',
|
||||
html=True
|
||||
)
|
||||
self.assertContains(
|
||||
response,
|
||||
'<div class="help">Some help text for the content (with unicode ŠĐĆŽćžšđ)</div>',
|
||||
'<div class="help">Some help text for the content (with Unicode ŠĐĆŽćžšđ)</div>',
|
||||
html=True
|
||||
)
|
||||
self.assertContains(
|
||||
response,
|
||||
'<div class="help">Some help text for the date (with unicode ŠĐĆŽćžšđ)</div>',
|
||||
'<div class="help">Some help text for the date (with Unicode ŠĐĆŽćžšđ)</div>',
|
||||
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, '<div class="help">Overridden help text for the date</div>')
|
||||
self.assertContains(response, '<label for="id_public">Overridden public label:</label>', 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):
|
||||
"""
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -59,7 +59,7 @@ class FormsUtilsTestCase(SimpleTestCase):
|
||||
str(ErrorList(ValidationError("There was an error.").messages)),
|
||||
'<ul class="errorlist"><li>There was an error.</li></ul>'
|
||||
)
|
||||
# Can take a unicode string.
|
||||
# Can take a Unicode string.
|
||||
self.assertHTMLEqual(
|
||||
str(ErrorList(ValidationError("Not \u03C0.").messages)),
|
||||
'<ul class="errorlist"><li>Not π.</li></ul>'
|
||||
|
@ -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())
|
||||
|
@ -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):
|
||||
|
@ -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())
|
||||
|
@ -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)
|
||||
"""
|
||||
|
@ -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)
|
||||
|
@ -36,7 +36,7 @@ class AutoescapeTagTests(SimpleTestCase):
|
||||
output = self.engine.render_to_string('autoescape-tag05', {'first': '<b>first</b>'})
|
||||
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):
|
||||
|
@ -806,10 +806,10 @@ class HTMLEqualTests(SimpleTestCase):
|
||||
self.assertContains(response, '<p "whats" that>')
|
||||
|
||||
def test_unicode_handling(self):
|
||||
response = HttpResponse('<p class="help">Some help text for the title (with unicode ŠĐĆŽćžšđ)</p>')
|
||||
response = HttpResponse('<p class="help">Some help text for the title (with Unicode ŠĐĆŽćžšđ)</p>')
|
||||
self.assertContains(
|
||||
response,
|
||||
'<p class="help">Some help text for the title (with unicode ŠĐĆŽćžšđ)</p>',
|
||||
'<p class="help">Some help text for the title (with Unicode ŠĐĆŽćžšđ)</p>',
|
||||
html=True
|
||||
)
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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": <value of trans_txt Python variable>
|
||||
# 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)
|
||||
|
Loading…
Reference in New Issue
Block a user