Skip to content

Commit c8a66cd

Browse files
Deploy preview for PR 1133 🛫
1 parent 64fdf73 commit c8a66cd

File tree

559 files changed

+728
-594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

559 files changed

+728
-594
lines changed

pr-preview/pr-1133/_sources/library/functions.rst.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,13 +1550,19 @@ are always available. They are listed here in alphabetical order.
15501550
.. versionchanged:: 3.11
15511551
The ``'U'`` mode has been removed.
15521552

1553-
.. function:: ord(c)
1553+
.. function:: ord(character, /)
15541554

1555-
Given a string representing one Unicode character, return an integer
1556-
representing the Unicode code point of that character. For example,
1555+
Return the ordinal value of a character.
1556+
1557+
If the argument is a one-character string, return the Unicode code point
1558+
of that character. For example,
15571559
``ord('a')`` returns the integer ``97`` and ``ord('€')`` (Euro sign)
15581560
returns ``8364``. This is the inverse of :func:`chr`.
15591561

1562+
If the argument is a :class:`bytes` or :class:`bytearray` object of
1563+
length 1, return its single byte value.
1564+
For example, ``ord(b'a')`` returns the integer ``97``.
1565+
15601566

15611567
.. function:: pow(base, exp, mod=None)
15621568

pr-preview/pr-1133/_sources/library/locale.rst.txt

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,17 @@ The :mod:`locale` module defines the following exception and functions:
3434

3535
If *locale* is given and not ``None``, :func:`setlocale` modifies the locale
3636
setting for the *category*. The available categories are listed in the data
37-
description below. *locale* may be a string, or an iterable of two strings
38-
(language code and encoding). If it's an iterable, it's converted to a locale
39-
name using the locale aliasing engine. An empty string specifies the user's
37+
description below. *locale* may be a :ref:`string <locale_name>`, or a pair,
38+
language code and encoding. An empty string specifies the user's
4039
default settings. If the modification of the locale fails, the exception
4140
:exc:`Error` is raised. If successful, the new locale setting is returned.
4241

42+
If *locale* is a pair, it is converted to a locale name using
43+
the locale aliasing engine.
44+
The language code has the same format as a :ref:`locale name <locale_name>`,
45+
but without encoding and ``@``-modifier.
46+
The language code and encoding can be ``None``.
47+
4348
If *locale* is omitted or ``None``, the current setting for *category* is
4449
returned.
4550

@@ -336,22 +341,26 @@ The :mod:`locale` module defines the following exception and functions:
336341
``'LANG'``. The GNU gettext search path contains ``'LC_ALL'``,
337342
``'LC_CTYPE'``, ``'LANG'`` and ``'LANGUAGE'``, in that order.
338343

339-
Except for the code ``'C'``, the language code corresponds to :rfc:`1766`.
340-
*language code* and *encoding* may be ``None`` if their values cannot be
344+
The language code has the same format as a :ref:`locale name <locale_name>`,
345+
but without encoding and ``@``-modifier.
346+
The language code and encoding may be ``None`` if their values cannot be
341347
determined.
348+
The "C" locale is represented as ``(None, None)``.
342349

343350
.. deprecated-removed:: 3.11 3.15
344351

345352

346353
.. function:: getlocale(category=LC_CTYPE)
347354

348-
Returns the current setting for the given locale category as sequence containing
349-
*language code*, *encoding*. *category* may be one of the :const:`!LC_\*` values
350-
except :const:`LC_ALL`. It defaults to :const:`LC_CTYPE`.
355+
Returns the current setting for the given locale category as a tuple containing
356+
the language code and encoding. *category* may be one of the :const:`!LC_\*`
357+
values except :const:`LC_ALL`. It defaults to :const:`LC_CTYPE`.
351358

352-
Except for the code ``'C'``, the language code corresponds to :rfc:`1766`.
353-
*language code* and *encoding* may be ``None`` if their values cannot be
359+
The language code has the same format as a :ref:`locale name <locale_name>`,
360+
but without encoding and ``@``-modifier.
361+
The language code and encoding may be ``None`` if their values cannot be
354362
determined.
363+
The "C" locale is represented as ``(None, None)``.
355364

356365

357366
.. function:: getpreferredencoding(do_setlocale=True)
@@ -606,6 +615,61 @@ whose high bit is set (i.e., non-ASCII bytes) are never converted or considered
606615
part of a character class such as letter or whitespace.
607616

608617

618+
.. _locale_name:
619+
620+
Locale names
621+
------------
622+
623+
The format of the locale name is platform dependent, and the set of supported
624+
locales can depend on the system configuration.
625+
626+
On Posix platforms, it usually has the format [1]_:
627+
628+
.. productionlist:: locale_name
629+
: language ["_" territory] ["." charset] ["@" modifier]
630+
631+
where *language* is a two- or three-letter language code from `ISO 639`_,
632+
*territory* is a two-letter country or region code from `ISO 3166`_,
633+
*charset* is a locale encoding, and *modifier* is a script name,
634+
a language subtag, a sort order identifier, or other locale modifier
635+
(for example, "latin", "valencia", "stroke" and "euro").
636+
637+
On Windows, several formats are supported. [2]_ [3]_
638+
A subset of `IETF BCP 47`_ tags:
639+
640+
.. productionlist:: locale_name
641+
: language ["-" script] ["-" territory] ["." charset]
642+
: language ["-" script] "-" territory "-" modifier
643+
644+
where *language* and *territory* have the same meaning as in Posix,
645+
*script* is a four-letter script code from `ISO 15924`_,
646+
and *modifier* is a language subtag, a sort order identifier
647+
or custom modifier (for example, "valencia", "stroke" or "x-python").
648+
Both hyphen (``'-'``) and underscore (``'_'``) separators are supported.
649+
Only UTF-8 encoding is allowed for BCP 47 tags.
650+
651+
Windows also supports locale names in the format:
652+
653+
.. productionlist:: locale_name
654+
: language ["_" territory] ["." charset]
655+
656+
where *language* and *territory* are full names, such as "English" and
657+
"United States", and *charset* is either a code page number (for example, "1252")
658+
or UTF-8.
659+
Only the underscore separator is supported in this format.
660+
661+
The "C" locale is supported on all platforms.
662+
663+
.. _ISO 639: https://www.iso.org/iso-639-language-code
664+
.. _ISO 3166: https://www.iso.org/iso-3166-country-codes.html
665+
.. _IETF BCP 47: https://www.rfc-editor.org/info/bcp47
666+
.. _ISO 15924: https://www.unicode.org/iso15924/
667+
668+
.. [1] `IEEE Std 1003.1-2024; 8.2 Internationalization Variables <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap08.html#tag_08_02>`_
669+
.. [2] `UCRT Locale names, Languages, and Country/Region strings <https://learn.microsoft.com/en-us/cpp/c-runtime-library/locale-names-languages-and-country-region-strings>`_
670+
.. [3] `Locale Names <https://learn.microsoft.com/en-us/windows/win32/intl/locale-names>`_
671+
672+
609673
.. _embedding-locale:
610674

611675
For extension writers and programs that embed Python

pr-preview/pr-1133/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ <h3>瀏覽</h3>
320320
<a href="https://www.python.org/psf/donations/">Please donate.</a>
321321
<br>
322322
<br>
323-
最後更新於 8月 13, 2025 (00:21 UTC)。
323+
最後更新於 8月 14, 2025 (00:21 UTC)。
324324

325325
<a href="/bugs.html">Found a bug</a>?
326326

pr-preview/pr-1133/bugs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ <h2>說明文件的錯誤<a class="headerlink" href="#documentation-bugs" title=
231231
</section>
232232
<section id="getting-started-contributing-to-python-yourself">
233233
<span id="contributing-to-python"></span><h2>開始讓自己貢獻 Python<a class="headerlink" href="#getting-started-contributing-to-python-yourself" title="連結到這個標頭"></a></h2>
234-
<p>除了只是回報你所發現的錯誤之外,同樣也歡迎你提交修正它們的修補程式 (patch)。你可以在 <a class="reference external" href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果你有任何問題,<a class="reference external" href="https://devguide.python.org/">核心導師郵寄清單</a>是一個友善的地方,你可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
234+
<p>除了只是回報你所發現的錯誤之外,同樣也歡迎你提交修正它們的修補程式 (patch)。你可以在 <a class="reference external" href="https://devguide.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果你有任何問題,<a class="reference external" href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">核心導師郵寄清單</a>是一個友善的地方,你可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
235235
</section>
236236
</section>
237237

@@ -359,7 +359,7 @@ <h3>瀏覽</h3>
359359
<a href="https://www.python.org/psf/donations/">Please donate.</a>
360360
<br>
361361
<br>
362-
最後更新於 8月 13, 2025 (00:21 UTC)。
362+
最後更新於 8月 14, 2025 (00:21 UTC)。
363363

364364
<a href="/bugs.html">Found a bug</a>?
365365

pr-preview/pr-1133/c-api/abstract.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ <h3>瀏覽</h3>
329329
<a href="https://www.python.org/psf/donations/">Please donate.</a>
330330
<br>
331331
<br>
332-
最後更新於 8月 13, 2025 (00:21 UTC)。
332+
最後更新於 8月 14, 2025 (00:21 UTC)。
333333

334334
<a href="/bugs.html">Found a bug</a>?
335335

pr-preview/pr-1133/c-api/allocation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ <h3>瀏覽</h3>
346346
<a href="https://www.python.org/psf/donations/">Please donate.</a>
347347
<br>
348348
<br>
349-
最後更新於 8月 13, 2025 (00:21 UTC)。
349+
最後更新於 8月 14, 2025 (00:21 UTC)。
350350

351351
<a href="/bugs.html">Found a bug</a>?
352352

pr-preview/pr-1133/c-api/apiabiversion.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ <h3>瀏覽</h3>
376376
<a href="https://www.python.org/psf/donations/">Please donate.</a>
377377
<br>
378378
<br>
379-
最後更新於 8月 13, 2025 (00:21 UTC)。
379+
最後更新於 8月 14, 2025 (00:21 UTC)。
380380

381381
<a href="/bugs.html">Found a bug</a>?
382382

pr-preview/pr-1133/c-api/arg.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ <h3>瀏覽</h3>
931931
<a href="https://www.python.org/psf/donations/">Please donate.</a>
932932
<br>
933933
<br>
934-
最後更新於 8月 13, 2025 (00:21 UTC)。
934+
最後更新於 8月 14, 2025 (00:21 UTC)。
935935

936936
<a href="/bugs.html">Found a bug</a>?
937937

pr-preview/pr-1133/c-api/bool.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ <h3>瀏覽</h3>
340340
<a href="https://www.python.org/psf/donations/">Please donate.</a>
341341
<br>
342342
<br>
343-
最後更新於 8月 13, 2025 (00:21 UTC)。
343+
最後更新於 8月 14, 2025 (00:21 UTC)。
344344

345345
<a href="/bugs.html">Found a bug</a>?
346346

pr-preview/pr-1133/c-api/buffer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ <h3>瀏覽</h3>
10221022
<a href="https://www.python.org/psf/donations/">Please donate.</a>
10231023
<br>
10241024
<br>
1025-
最後更新於 8月 13, 2025 (00:21 UTC)。
1025+
最後更新於 8月 14, 2025 (00:21 UTC)。
10261026

10271027
<a href="/bugs.html">Found a bug</a>?
10281028

0 commit comments

Comments
 (0)