From c5fb0c0ae78ca322b2adc97b6c0c8f746dc136c1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 28 Jul 2025 17:31:41 +0000 Subject: [PATCH 01/23] sync with cpython cdae923f --- library/asyncio-eventloop.po | 650 +++++++++--------- library/multiprocessing.po | 1192 +++++++++++++++++----------------- 2 files changed, 924 insertions(+), 918 deletions(-) diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index 26091449c9..a337f0aedd 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-07-28 17:30+0000\n" "PO-Revision-Date: 2022-02-20 12:36+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -295,8 +295,8 @@ msgid "" msgstr "請注意,使用 :func:`asyncio.run` 時不需要呼叫此函式。" #: ../../library/asyncio-eventloop.rst:177 -#: ../../library/asyncio-eventloop.rst:1320 -#: ../../library/asyncio-eventloop.rst:1769 +#: ../../library/asyncio-eventloop.rst:1326 +#: ../../library/asyncio-eventloop.rst:1775 msgid "Example::" msgstr "範例: ::" @@ -687,8 +687,8 @@ msgid "The socket type will be :py:const:`~socket.SOCK_STREAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_STREAM`。" #: ../../library/asyncio-eventloop.rst:437 -#: ../../library/asyncio-eventloop.rst:1230 -#: ../../library/asyncio-eventloop.rst:1247 +#: ../../library/asyncio-eventloop.rst:1236 +#: ../../library/asyncio-eventloop.rst:1253 msgid "" "*protocol_factory* must be a callable returning an :ref:`asyncio protocol " "` implementation." @@ -827,8 +827,8 @@ msgstr "" "*flags*、*happy_eyeballs_delay*、*interleave* 和 *local_addr* 中的任何一項。" #: ../../library/asyncio-eventloop.rst:507 -#: ../../library/asyncio-eventloop.rst:623 -#: ../../library/asyncio-eventloop.rst:871 +#: ../../library/asyncio-eventloop.rst:629 +#: ../../library/asyncio-eventloop.rst:877 msgid "" "The *sock* argument transfers ownership of the socket to the transport " "created. To close the socket, call the transport's :meth:`~asyncio." @@ -848,7 +848,7 @@ msgstr "" "式類似於 *host* 和 *port*。" #: ../../library/asyncio-eventloop.rst:515 -#: ../../library/asyncio-eventloop.rst:967 +#: ../../library/asyncio-eventloop.rst:973 msgid "" "*ssl_handshake_timeout* is (for a TLS connection) the time in seconds to " "wait for the TLS handshake to complete before aborting the connection. " @@ -859,9 +859,9 @@ msgstr "" "秒。" #: ../../library/asyncio-eventloop.rst:519 -#: ../../library/asyncio-eventloop.rst:778 -#: ../../library/asyncio-eventloop.rst:882 -#: ../../library/asyncio-eventloop.rst:971 +#: ../../library/asyncio-eventloop.rst:784 +#: ../../library/asyncio-eventloop.rst:888 +#: ../../library/asyncio-eventloop.rst:977 msgid "" "*ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown " "to complete before aborting the connection. ``30.0`` seconds if ``None`` " @@ -885,7 +885,7 @@ msgstr "" "包含所有例外的 ``ExceptionGroup`` (即使只有一個例外)。" #: ../../library/asyncio-eventloop.rst:533 -#: ../../library/asyncio-eventloop.rst:790 +#: ../../library/asyncio-eventloop.rst:796 msgid "Added support for SSL/TLS in :class:`ProactorEventLoop`." msgstr "新增 :class:`ProactorEventLoop` 中的 SSL/TLS 支援。" @@ -898,7 +898,7 @@ msgstr "" "socket 選項。" #: ../../library/asyncio-eventloop.rst:542 -#: ../../library/asyncio-eventloop.rst:892 +#: ../../library/asyncio-eventloop.rst:898 msgid "Added the *ssl_handshake_timeout* parameter." msgstr "增加 *ssl_handshake_timeout* 參數。" @@ -927,11 +927,11 @@ msgid "For more information: https://datatracker.ietf.org/doc/html/rfc6555" msgstr "更多資訊請見: https://datatracker.ietf.org/doc/html/rfc6555" #: ../../library/asyncio-eventloop.rst:561 -#: ../../library/asyncio-eventloop.rst:687 -#: ../../library/asyncio-eventloop.rst:804 -#: ../../library/asyncio-eventloop.rst:844 -#: ../../library/asyncio-eventloop.rst:896 -#: ../../library/asyncio-eventloop.rst:979 +#: ../../library/asyncio-eventloop.rst:693 +#: ../../library/asyncio-eventloop.rst:810 +#: ../../library/asyncio-eventloop.rst:850 +#: ../../library/asyncio-eventloop.rst:902 +#: ../../library/asyncio-eventloop.rst:985 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "增加 *ssl_shutdown_timeout* 參數。" @@ -967,8 +967,8 @@ msgid "The socket type will be :py:const:`~socket.SOCK_DGRAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_DGRAM`。" #: ../../library/asyncio-eventloop.rst:587 -#: ../../library/asyncio-eventloop.rst:714 -#: ../../library/asyncio-eventloop.rst:863 +#: ../../library/asyncio-eventloop.rst:720 +#: ../../library/asyncio-eventloop.rst:869 msgid "" "*protocol_factory* must be a callable returning a :ref:`protocol ` implementation." @@ -977,7 +977,7 @@ msgstr "" "protocol>` 實作。" #: ../../library/asyncio-eventloop.rst:590 -#: ../../library/asyncio-eventloop.rst:669 +#: ../../library/asyncio-eventloop.rst:675 msgid "A tuple of ``(transport, protocol)`` is returned on success." msgstr "成功時回傳 ``(transport, protocol)`` 元組。" @@ -990,7 +990,13 @@ msgstr "" "*local_addr*,如果提供,是一個 ``(local_host, local_port)`` 元組,用於在本地" "綁定 socket。*local_host* 和 *local_port* 使用 :meth:`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:598 +#: ../../library/asyncio-eventloop.rst:600 +msgid "" +"On Windows, when using the proactor event loop with ``local_addr=None``, an :" +"exc:`OSError` with :attr:`!errno.WSAEINVAL` will be raised when running it." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:604 msgid "" "*remote_addr*, if given, is a ``(remote_host, remote_port)`` tuple used to " "connect the socket to a remote address. The *remote_host* and *remote_port* " @@ -1000,7 +1006,7 @@ msgstr "" "socket 連線到遠端位址。 *remote_host* 和 *remote_port* 使用 :meth:" "`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:602 +#: ../../library/asyncio-eventloop.rst:608 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to :meth:`getaddrinfo` for *host* resolution. If " @@ -1011,7 +1017,7 @@ msgstr "" "的可選地址家族、協定和旗標。如果提供,這些應該都是來自相應的 :mod:`socket` 模" "組常數的整數。" -#: ../../library/asyncio-eventloop.rst:607 +#: ../../library/asyncio-eventloop.rst:613 msgid "" "*reuse_port* tells the kernel to allow this endpoint to be bound to the same " "port as other existing endpoints are bound to, so long as they all set this " @@ -1023,13 +1029,13 @@ msgstr "" "時都設定了此旗標。此選項不受 Windows 和某些 Unix 系統支援。如果未定義 :py:" "const:`~socket.SO_REUSEPORT` 常數,則不支援此功能。" -#: ../../library/asyncio-eventloop.rst:613 +#: ../../library/asyncio-eventloop.rst:619 msgid "" "*allow_broadcast* tells the kernel to allow this endpoint to send messages " "to the broadcast address." msgstr "*allow_broadcast* 告訴核心允許此端點向廣播位址發送訊息。" -#: ../../library/asyncio-eventloop.rst:616 +#: ../../library/asyncio-eventloop.rst:622 msgid "" "*sock* can optionally be specified in order to use a preexisting, already " "connected, :class:`socket.socket` object to be used by the transport. If " @@ -1040,7 +1046,7 @@ msgstr "" "供傳輸使用。如果指定,*local_addr* 和 *remote_addr* 應省略(必須是 :const:" "`None`\\ )。" -#: ../../library/asyncio-eventloop.rst:627 +#: ../../library/asyncio-eventloop.rst:633 msgid "" "See :ref:`UDP echo client protocol ` and :" "ref:`UDP echo server protocol ` examples." @@ -1048,7 +1054,7 @@ msgstr "" "請參閱 :ref:`UDP 回應用戶端協定 ` 和 :ref:" "`UDP 回應伺服器協定 ` 範例。" -#: ../../library/asyncio-eventloop.rst:630 +#: ../../library/asyncio-eventloop.rst:636 msgid "" "The *family*, *proto*, *flags*, *reuse_address*, *reuse_port*, " "*allow_broadcast*, and *sock* parameters were added." @@ -1056,11 +1062,11 @@ msgstr "" "新增 *family*、*proto*、*flags*、*reuse_address*、*reuse_port*、" "*allow_broadcast* 和 *sock* 參數。" -#: ../../library/asyncio-eventloop.rst:634 +#: ../../library/asyncio-eventloop.rst:640 msgid "Added support for Windows." msgstr "新增對於 Windows 的支援。" -#: ../../library/asyncio-eventloop.rst:637 +#: ../../library/asyncio-eventloop.rst:643 msgid "" "The *reuse_address* parameter is no longer supported, as using :ref:`socket." "SO_REUSEADDR ` poses a significant security concern " @@ -1069,7 +1075,7 @@ msgstr "" "不再支援 *reuse_address* 參數,因為使用 :py:const:`~sockets.SO_REUSEADDR` 對" "於 UDP 存有重大的安全疑慮。明確傳遞 ``reuse_address=True`` 將引發例外。" -#: ../../library/asyncio-eventloop.rst:643 +#: ../../library/asyncio-eventloop.rst:649 msgid "" "When multiple processes with differing UIDs assign sockets to an identical " "UDP socket address with ``SO_REUSEADDR``, incoming packets can become " @@ -1078,7 +1084,7 @@ msgstr "" "當具有不同 UID 的多個行程使用 ``SO_REUSEADDR`` 將 socket 分配給相同的 UDP " "socket 地址時,傳入的封包可能會在 socket 之間隨機分佈。" -#: ../../library/asyncio-eventloop.rst:647 +#: ../../library/asyncio-eventloop.rst:653 msgid "" "For supported platforms, *reuse_port* can be used as a replacement for " "similar functionality. With *reuse_port*, :ref:`socket.SO_REUSEPORT ` is set by default " @@ -1304,7 +1310,7 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。所有 TCP 連線都預設有 :" "ref:`socket.TCP_NODELAY ` socket 選項。" -#: ../../library/asyncio-eventloop.rst:808 +#: ../../library/asyncio-eventloop.rst:814 msgid "" "The :func:`start_server` function is a higher-level alternative API that " "returns a pair of :class:`StreamReader` and :class:`StreamWriter` that can " @@ -1313,7 +1319,7 @@ msgstr "" ":func:`start_server` 函式是一個更高階的替代 API,它回傳一對 :class:" "`StreamReader` 和 :class:`StreamWriter`,可以在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:820 +#: ../../library/asyncio-eventloop.rst:826 msgid "" "Similar to :meth:`loop.create_server` but works with the :py:const:`~socket." "AF_UNIX` socket family." @@ -1321,7 +1327,7 @@ msgstr "" "類似 :meth:`loop.create_server`,但適用於 :py:const:`~socket.AF_UNIX` socket " "家族。" -#: ../../library/asyncio-eventloop.rst:823 +#: ../../library/asyncio-eventloop.rst:829 msgid "" "*path* is the name of a Unix domain socket, and is required, unless a *sock* " "argument is provided. Abstract Unix sockets, :class:`str`, :class:`bytes`, " @@ -1331,7 +1337,7 @@ msgstr "" "象 Unix sockets、:class:`str`、:class:`bytes` 和 :class:`~pathlib.Path` 路" "徑。" -#: ../../library/asyncio-eventloop.rst:828 +#: ../../library/asyncio-eventloop.rst:834 msgid "" "If *cleanup_socket* is true then the Unix socket will automatically be " "removed from the filesystem when the server is closed, unless the socket has " @@ -1340,13 +1346,13 @@ msgstr "" "如果 *cleanup_socket* 為真,則 Unix socket 將在伺服器關閉時自動從檔案系統中刪" "除,除非在建立伺服器後替換了 socket。" -#: ../../library/asyncio-eventloop.rst:832 +#: ../../library/asyncio-eventloop.rst:838 msgid "" "See the documentation of the :meth:`loop.create_server` method for " "information about arguments to this method." msgstr "有關此方法的引數資訊,請參閱 :meth:`loop.create_server` 方法的文件。" -#: ../../library/asyncio-eventloop.rst:839 +#: ../../library/asyncio-eventloop.rst:845 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :class:`~pathlib.Path` object." @@ -1354,26 +1360,26 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。*path* 參數現在可為一" "個 :class:`~pathlib.Path` 物件。" -#: ../../library/asyncio-eventloop.rst:848 +#: ../../library/asyncio-eventloop.rst:854 msgid "Added the *cleanup_socket* parameter." msgstr "加入 *cleanup_socket* 參數。" -#: ../../library/asyncio-eventloop.rst:856 +#: ../../library/asyncio-eventloop.rst:862 msgid "Wrap an already accepted connection into a transport/protocol pair." msgstr "將已接受的連線包裝成傳輸層/協定對。" -#: ../../library/asyncio-eventloop.rst:858 +#: ../../library/asyncio-eventloop.rst:864 msgid "" "This method can be used by servers that accept connections outside of " "asyncio but that use asyncio to handle them." msgstr "此方法可以由在 asyncio 外接受連線但使用 asyncio 處理連線的伺服器使用。" -#: ../../library/asyncio-eventloop.rst:861 -#: ../../library/asyncio-eventloop.rst:953 +#: ../../library/asyncio-eventloop.rst:867 +#: ../../library/asyncio-eventloop.rst:959 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-eventloop.rst:866 +#: ../../library/asyncio-eventloop.rst:872 msgid "" "*sock* is a preexisting socket object returned from :meth:`socket.accept " "`." @@ -1381,13 +1387,13 @@ msgstr "" "*sock* 是從 :meth:`socket.accept ` 回傳的預先存在的 " "socket 物件。" -#: ../../library/asyncio-eventloop.rst:875 +#: ../../library/asyncio-eventloop.rst:881 msgid "" "*ssl* can be set to an :class:`~ssl.SSLContext` to enable SSL over the " "accepted connections." msgstr "*ssl* 可以設置為 :class:`~ssl.SSLContext` 以在已接受的連線上啟用 SSL。" -#: ../../library/asyncio-eventloop.rst:878 +#: ../../library/asyncio-eventloop.rst:884 msgid "" "*ssl_handshake_timeout* is (for an SSL connection) the time in seconds to " "wait for the SSL handshake to complete before aborting the connection. " @@ -1396,29 +1402,29 @@ msgstr "" "(對於 SSL 連線)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 SSL 握手完成" "的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:886 +#: ../../library/asyncio-eventloop.rst:892 msgid "Returns a ``(transport, protocol)`` pair." msgstr "回傳 ``(transport, protocol)`` 對。" -#: ../../library/asyncio-eventloop.rst:900 +#: ../../library/asyncio-eventloop.rst:906 msgid "Transferring files" msgstr "傳輸檔案" -#: ../../library/asyncio-eventloop.rst:906 +#: ../../library/asyncio-eventloop.rst:912 msgid "" "Send a *file* over a *transport*. Return the total number of bytes sent." msgstr "通過 *transport* 發送 *file*。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:909 +#: ../../library/asyncio-eventloop.rst:915 msgid "The method uses high-performance :meth:`os.sendfile` if available." msgstr "如果可用,該方法使用高性能 :meth:`os.sendfile`。" -#: ../../library/asyncio-eventloop.rst:911 +#: ../../library/asyncio-eventloop.rst:917 msgid "*file* must be a regular file object opened in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:913 -#: ../../library/asyncio-eventloop.rst:1174 +#: ../../library/asyncio-eventloop.rst:919 +#: ../../library/asyncio-eventloop.rst:1180 msgid "" "*offset* tells from where to start reading the file. If specified, *count* " "is the total number of bytes to transmit as opposed to sending the file " @@ -1430,7 +1436,7 @@ msgstr "" "不是發送檔案直到達到 EOF。即使此方法引發錯誤時,檔案位置也始終更新,可以使" "用 :meth:`file.tell() ` 取得實際發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:920 +#: ../../library/asyncio-eventloop.rst:926 msgid "" "*fallback* set to ``True`` makes asyncio to manually read and send the file " "when the platform does not support the sendfile system call (e.g. Windows or " @@ -1439,7 +1445,7 @@ msgstr "" "將 *fallback* 設置為 ``True`` 會使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:924 +#: ../../library/asyncio-eventloop.rst:930 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support the " "*sendfile* syscall and *fallback* is ``False``." @@ -1447,15 +1453,15 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,則引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:931 +#: ../../library/asyncio-eventloop.rst:937 msgid "TLS Upgrade" msgstr "TLS 升級" -#: ../../library/asyncio-eventloop.rst:939 +#: ../../library/asyncio-eventloop.rst:945 msgid "Upgrade an existing transport-based connection to TLS." msgstr "將基於傳輸的現有連線升級到 TLS。" -#: ../../library/asyncio-eventloop.rst:941 +#: ../../library/asyncio-eventloop.rst:947 msgid "" "Create a TLS coder/decoder instance and insert it between the *transport* " "and the *protocol*. The coder/decoder implements both *transport*-facing " @@ -1464,7 +1470,7 @@ msgstr "" "建立 TLS 編解碼器實例並在 *transport* 和 *protocol* 之間插入它。編解碼器既實" "作了對於 *transport* 的協定,也實作了對於 *protocol* 的傳輸。" -#: ../../library/asyncio-eventloop.rst:945 +#: ../../library/asyncio-eventloop.rst:951 msgid "" "Return the created two-interface instance. After *await*, the *protocol* " "must stop using the original *transport* and communicate with the returned " @@ -1475,13 +1481,13 @@ msgstr "" "*transport*,僅與回傳的物件通信,因為編碼器快取了 *protocol* 端的資料,並且" "與 *transport* 間歇性地交換額外的 TLS session 封包。" -#: ../../library/asyncio-eventloop.rst:950 +#: ../../library/asyncio-eventloop.rst:956 msgid "" "In some situations (e.g. when the passed transport is already closing) this " "may return ``None``." msgstr "在某些情況下(例如傳入的傳輸已經關閉),此函式可能回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:955 +#: ../../library/asyncio-eventloop.rst:961 msgid "" "*transport* and *protocol* instances that methods like :meth:`~loop." "create_server` and :meth:`~loop.create_connection` return." @@ -1489,11 +1495,11 @@ msgstr "" "*transport* 和 *protocol* 實例,由像 :meth:`~loop.create_server` 和 :meth:" "`~loop.create_connection` 等方法回傳。" -#: ../../library/asyncio-eventloop.rst:959 +#: ../../library/asyncio-eventloop.rst:965 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "*sslcontext*:配置好的 :class:`~ssl.SSLContext` 實例。" -#: ../../library/asyncio-eventloop.rst:961 +#: ../../library/asyncio-eventloop.rst:967 msgid "" "*server_side* pass ``True`` when a server-side connection is being upgraded " "(like the one created by :meth:`~loop.create_server`)." @@ -1501,17 +1507,17 @@ msgstr "" "當升級伺服器端連線時(像由 :meth:`~loop.create_server` 建立的那樣)傳遞 " "``True``。" -#: ../../library/asyncio-eventloop.rst:964 +#: ../../library/asyncio-eventloop.rst:970 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." msgstr "*server_hostname*:設置或覆蓋將用於匹配目標伺服器憑證的主機名。" -#: ../../library/asyncio-eventloop.rst:984 +#: ../../library/asyncio-eventloop.rst:990 msgid "Watching file descriptors" msgstr "監視檔案描述器" -#: ../../library/asyncio-eventloop.rst:988 +#: ../../library/asyncio-eventloop.rst:994 msgid "" "Start monitoring the *fd* file descriptor for read availability and invoke " "*callback* with the specified arguments once *fd* is available for reading." @@ -1519,14 +1525,14 @@ msgstr "" "開始監視 *fd* 檔案描述器的讀取可用性,一但 *fd* 可讀取,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:992 -#: ../../library/asyncio-eventloop.rst:1006 +#: ../../library/asyncio-eventloop.rst:998 +#: ../../library/asyncio-eventloop.rst:1012 msgid "" "Any preexisting callback registered for *fd* is cancelled and replaced by " "*callback*." msgstr "任何預先存在、為 *fd* 註冊的回呼函式將被取消並替換為 *callback*。" -#: ../../library/asyncio-eventloop.rst:997 +#: ../../library/asyncio-eventloop.rst:1003 msgid "" "Stop monitoring the *fd* file descriptor for read availability. Returns " "``True`` if *fd* was previously being monitored for reads." @@ -1534,7 +1540,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的讀取可用性。如果 *fd* 之前正在監視讀取,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:1002 +#: ../../library/asyncio-eventloop.rst:1008 msgid "" "Start monitoring the *fd* file descriptor for write availability and invoke " "*callback* with the specified arguments once *fd* is available for writing." @@ -1542,8 +1548,8 @@ msgstr "" "開始監視 *fd* 檔案描述器的寫入可用性,一旦 *fd* 可寫入,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:1009 -#: ../../library/asyncio-eventloop.rst:1287 +#: ../../library/asyncio-eventloop.rst:1015 +#: ../../library/asyncio-eventloop.rst:1293 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *callback*." @@ -1551,7 +1557,7 @@ msgstr "" "使用 :func:`functools.partial` 向 *callback* :ref:`傳送關鍵字引數 `。" -#: ../../library/asyncio-eventloop.rst:1014 +#: ../../library/asyncio-eventloop.rst:1020 msgid "" "Stop monitoring the *fd* file descriptor for write availability. Returns " "``True`` if *fd* was previously being monitored for writes." @@ -1559,7 +1565,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的寫入可用性。如果 *fd* 之前正在監視寫入,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:1017 +#: ../../library/asyncio-eventloop.rst:1023 msgid "" "See also :ref:`Platform Support ` section for some " "limitations of these methods." @@ -1567,11 +1573,11 @@ msgstr "" "另請參閱\\ :ref:`平台支援 `\\ 部分以了解這些方法的" "一些限制。" -#: ../../library/asyncio-eventloop.rst:1022 +#: ../../library/asyncio-eventloop.rst:1028 msgid "Working with socket objects directly" msgstr "直接使用 socket 物件" -#: ../../library/asyncio-eventloop.rst:1024 +#: ../../library/asyncio-eventloop.rst:1030 msgid "" "In general, protocol implementations that use transport-based APIs such as :" "meth:`loop.create_connection` and :meth:`loop.create_server` are faster than " @@ -1580,10 +1586,10 @@ msgid "" "socket` objects directly is more convenient." msgstr "" "一般情況下,使用基於傳輸的 API(如 :meth:`loop.create_connection` 和 :meth:" -"`loop.create_server`)的協定實作比直接使用 socket 的實作更快。然而在某些情" -"況下性能不是關鍵,直接使用 :class:`~socket.socket` 物件更方便。" +"`loop.create_server`)的協定實作比直接使用 socket 的實作更快。然而在某些情況" +"下性能不是關鍵,直接使用 :class:`~socket.socket` 物件更方便。" -#: ../../library/asyncio-eventloop.rst:1034 +#: ../../library/asyncio-eventloop.rst:1040 msgid "" "Receive up to *nbytes* from *sock*. Asynchronous version of :meth:`socket." "recv() `." @@ -1591,23 +1597,23 @@ msgstr "" "從 *sock* 接收最多 *nbytes*。:meth:`socket.recv() ` 的非" "同步版本。" -#: ../../library/asyncio-eventloop.rst:1037 +#: ../../library/asyncio-eventloop.rst:1043 msgid "Return the received data as a bytes object." msgstr "將接收到的資料作為 bytes 物件回傳。" -#: ../../library/asyncio-eventloop.rst:1039 -#: ../../library/asyncio-eventloop.rst:1054 -#: ../../library/asyncio-eventloop.rst:1066 -#: ../../library/asyncio-eventloop.rst:1079 -#: ../../library/asyncio-eventloop.rst:1095 -#: ../../library/asyncio-eventloop.rst:1111 -#: ../../library/asyncio-eventloop.rst:1122 -#: ../../library/asyncio-eventloop.rst:1149 -#: ../../library/asyncio-eventloop.rst:1188 +#: ../../library/asyncio-eventloop.rst:1045 +#: ../../library/asyncio-eventloop.rst:1060 +#: ../../library/asyncio-eventloop.rst:1072 +#: ../../library/asyncio-eventloop.rst:1085 +#: ../../library/asyncio-eventloop.rst:1101 +#: ../../library/asyncio-eventloop.rst:1117 +#: ../../library/asyncio-eventloop.rst:1128 +#: ../../library/asyncio-eventloop.rst:1155 +#: ../../library/asyncio-eventloop.rst:1194 msgid "*sock* must be a non-blocking socket." msgstr "*sock* 必須是非阻塞 socket。" -#: ../../library/asyncio-eventloop.rst:1041 +#: ../../library/asyncio-eventloop.rst:1047 msgid "" "Even though this method was always documented as a coroutine method, " "releases before Python 3.7 returned a :class:`Future`. Since Python 3.7 this " @@ -1616,7 +1622,7 @@ msgstr "" "儘管此方法一直記錄為協程方法,但 Python 3.7 之前的版本回傳 :class:`Future`。" "自 Python 3.7 起,這是 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1049 +#: ../../library/asyncio-eventloop.rst:1055 msgid "" "Receive data from *sock* into the *buf* buffer. Modeled after the blocking :" "meth:`socket.recv_into() ` method." @@ -1624,11 +1630,11 @@ msgstr "" "從 *sock* 接收資料到 *buf* 緩衝區。仿照阻塞 :meth:`socket.recv_into() " "` 方法。" -#: ../../library/asyncio-eventloop.rst:1052 +#: ../../library/asyncio-eventloop.rst:1058 msgid "Return the number of bytes written to the buffer." msgstr "回傳寫入緩衝區位元組的數目。" -#: ../../library/asyncio-eventloop.rst:1061 +#: ../../library/asyncio-eventloop.rst:1067 msgid "" "Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of :" "meth:`socket.recvfrom() `." @@ -1636,11 +1642,11 @@ msgstr "" "從 *sock* 接收最多 *bufsize* 大小的資料單元。:meth:`socket.recvfrom() " "` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1064 +#: ../../library/asyncio-eventloop.rst:1070 msgid "Return a tuple of (received data, remote address)." msgstr "回傳一個元組 (received data, remote address)。" -#: ../../library/asyncio-eventloop.rst:1073 +#: ../../library/asyncio-eventloop.rst:1079 msgid "" "Receive a datagram of up to *nbytes* from *sock* into *buf*. Asynchronous " "version of :meth:`socket.recvfrom_into() `." @@ -1648,11 +1654,11 @@ msgstr "" "從 *sock* 接收最多 *nbytes* 大小的資料單元到 *buf*。:meth:`socket." "recvfrom_into() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1077 +#: ../../library/asyncio-eventloop.rst:1083 msgid "Return a tuple of (number of bytes received, remote address)." msgstr "回傳一個元組 (number of bytes received, remote address)。" -#: ../../library/asyncio-eventloop.rst:1086 +#: ../../library/asyncio-eventloop.rst:1092 msgid "" "Send *data* to the *sock* socket. Asynchronous version of :meth:`socket." "sendall() `." @@ -1660,7 +1666,7 @@ msgstr "" "將 *data* 發送到 *sock* socket。:meth:`socket.sendall() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1089 +#: ../../library/asyncio-eventloop.rst:1095 msgid "" "This method continues to send to the socket until either all data in *data* " "has been sent or an error occurs. ``None`` is returned on success. On " @@ -1672,8 +1678,8 @@ msgstr "" "回傳 ``None``。錯誤時引發例外。此外,沒有辦法確定接收端成功處理了多少資料(如" "果有的話)。" -#: ../../library/asyncio-eventloop.rst:1097 -#: ../../library/asyncio-eventloop.rst:1151 +#: ../../library/asyncio-eventloop.rst:1103 +#: ../../library/asyncio-eventloop.rst:1157 msgid "" "Even though the method was always documented as a coroutine method, before " "Python 3.7 it returned a :class:`Future`. Since Python 3.7, this is an " @@ -1682,7 +1688,7 @@ msgstr "" "儘管該方法一直被記錄為協程方法,但在 Python 3.7 之前它回傳 :class:`Future`。" "從 Python 3.7 開始,這是一個 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1105 +#: ../../library/asyncio-eventloop.rst:1111 msgid "" "Send a datagram from *sock* to *address*. Asynchronous version of :meth:" "`socket.sendto() `." @@ -1690,20 +1696,20 @@ msgstr "" "從 *sock* 向 *address* 發送一個資料單元。:meth:`socket.sendto() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1109 +#: ../../library/asyncio-eventloop.rst:1115 msgid "Return the number of bytes sent." msgstr "回傳發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:1118 +#: ../../library/asyncio-eventloop.rst:1124 msgid "Connect *sock* to a remote socket at *address*." msgstr "將 *sock* 連線到位於 *address* 的遠端 socket。" -#: ../../library/asyncio-eventloop.rst:1120 +#: ../../library/asyncio-eventloop.rst:1126 msgid "" "Asynchronous version of :meth:`socket.connect() `." msgstr ":meth:`socket.connect() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1124 +#: ../../library/asyncio-eventloop.rst:1130 msgid "" "``address`` no longer needs to be resolved. ``sock_connect`` will try to " "check if the *address* is already resolved by calling :func:`socket." @@ -1714,7 +1720,7 @@ msgstr "" "inet_pton` 檢查 *address* 是否已解析。如果沒有,將使用 :meth:`loop." "getaddrinfo` 解析 *address*。" -#: ../../library/asyncio-eventloop.rst:1133 +#: ../../library/asyncio-eventloop.rst:1139 msgid "" ":meth:`loop.create_connection` and :func:`asyncio.open_connection() " "`." @@ -1722,7 +1728,7 @@ msgstr "" ":meth:`loop.create_connection` 和 :func:`asyncio.open_connection() " "`。" -#: ../../library/asyncio-eventloop.rst:1140 +#: ../../library/asyncio-eventloop.rst:1146 msgid "" "Accept a connection. Modeled after the blocking :meth:`socket.accept() " "` method." @@ -1730,7 +1736,7 @@ msgstr "" "接受一個連線。模擬阻塞的 :meth:`socket.accept() ` 方" "法。" -#: ../../library/asyncio-eventloop.rst:1143 +#: ../../library/asyncio-eventloop.rst:1149 msgid "" "The socket must be bound to an address and listening for connections. The " "return value is a pair ``(conn, address)`` where *conn* is a *new* socket " @@ -1741,34 +1747,34 @@ msgstr "" "中 *conn* 是一個 *新* socket 物件,可在連線上發送和接收資料,*address* 是連接" "另一端對應的 socket 地址。" -#: ../../library/asyncio-eventloop.rst:1158 +#: ../../library/asyncio-eventloop.rst:1164 msgid ":meth:`loop.create_server` and :func:`start_server`." msgstr ":meth:`loop.create_server` 和 :func:`start_server`。" -#: ../../library/asyncio-eventloop.rst:1164 +#: ../../library/asyncio-eventloop.rst:1170 msgid "" "Send a file using high-performance :mod:`os.sendfile` if possible. Return " "the total number of bytes sent." msgstr "" "如果可行,使用高性能 :mod:`os.sendfile` 發送檔案。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:1167 +#: ../../library/asyncio-eventloop.rst:1173 msgid "" "Asynchronous version of :meth:`socket.sendfile() `." msgstr ":meth:`socket.sendfile() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1169 +#: ../../library/asyncio-eventloop.rst:1175 msgid "" "*sock* must be a non-blocking :const:`socket.SOCK_STREAM` :class:`~socket." "socket`." msgstr "" "*sock* 必須是非阻塞的 :const:`socket.SOCK_STREAM` :class:`~socket.socket`。" -#: ../../library/asyncio-eventloop.rst:1172 +#: ../../library/asyncio-eventloop.rst:1178 msgid "*file* must be a regular file object open in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:1181 +#: ../../library/asyncio-eventloop.rst:1187 msgid "" "*fallback*, when set to ``True``, makes asyncio manually read and send the " "file when the platform does not support the sendfile syscall (e.g. Windows " @@ -1777,7 +1783,7 @@ msgstr "" "當設置為 ``True`` 時,*fallback* 使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:1185 +#: ../../library/asyncio-eventloop.rst:1191 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support " "*sendfile* syscall and *fallback* is ``False``." @@ -1785,19 +1791,19 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:1194 +#: ../../library/asyncio-eventloop.rst:1200 msgid "DNS" msgstr "DNS" -#: ../../library/asyncio-eventloop.rst:1200 +#: ../../library/asyncio-eventloop.rst:1206 msgid "Asynchronous version of :meth:`socket.getaddrinfo`." msgstr ":meth:`socket.getaddrinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1205 +#: ../../library/asyncio-eventloop.rst:1211 msgid "Asynchronous version of :meth:`socket.getnameinfo`." msgstr ":meth:`socket.getnameinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1208 +#: ../../library/asyncio-eventloop.rst:1214 msgid "" "Both *getaddrinfo* and *getnameinfo* internally utilize their synchronous " "versions through the loop's default thread pool executor. When this executor " @@ -1807,7 +1813,7 @@ msgid "" "executor with a larger number of workers." msgstr "" -#: ../../library/asyncio-eventloop.rst:1215 +#: ../../library/asyncio-eventloop.rst:1221 msgid "" "Both *getaddrinfo* and *getnameinfo* methods were always documented to " "return a coroutine, but prior to Python 3.7 they were, in fact, returning :" @@ -1818,19 +1824,19 @@ msgstr "" "它們實際上回傳 :class:`asyncio.Future` 物件。從 Python 3.7 開始,兩個方法都是" "協程。" -#: ../../library/asyncio-eventloop.rst:1223 +#: ../../library/asyncio-eventloop.rst:1229 msgid "Working with pipes" msgstr "使用管道" -#: ../../library/asyncio-eventloop.rst:1228 +#: ../../library/asyncio-eventloop.rst:1234 msgid "Register the read end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的讀取端。" -#: ../../library/asyncio-eventloop.rst:1233 +#: ../../library/asyncio-eventloop.rst:1239 msgid "*pipe* is a :term:`file-like object `." msgstr "*pipe* 是 :term:`類檔案物件 `。" -#: ../../library/asyncio-eventloop.rst:1235 +#: ../../library/asyncio-eventloop.rst:1241 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports the :class:" "`ReadTransport` interface and *protocol* is an object instantiated by the " @@ -1839,22 +1845,22 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`ReadTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1239 -#: ../../library/asyncio-eventloop.rst:1256 +#: ../../library/asyncio-eventloop.rst:1245 +#: ../../library/asyncio-eventloop.rst:1262 msgid "" "With :class:`SelectorEventLoop` event loop, the *pipe* is set to non-" "blocking mode." msgstr "使用 :class:`SelectorEventLoop` 事件迴圈時,*pipe* 設置為非阻塞模式。" -#: ../../library/asyncio-eventloop.rst:1245 +#: ../../library/asyncio-eventloop.rst:1251 msgid "Register the write end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的寫入端。" -#: ../../library/asyncio-eventloop.rst:1250 +#: ../../library/asyncio-eventloop.rst:1256 msgid "*pipe* is :term:`file-like object `." msgstr "*pipe* 是 :term:`file-like object `。" -#: ../../library/asyncio-eventloop.rst:1252 +#: ../../library/asyncio-eventloop.rst:1258 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports :class:" "`WriteTransport` interface and *protocol* is an object instantiated by the " @@ -1863,7 +1869,7 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`WriteTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1261 +#: ../../library/asyncio-eventloop.rst:1267 msgid "" ":class:`SelectorEventLoop` does not support the above methods on Windows. " "Use :class:`ProactorEventLoop` instead for Windows." @@ -1871,20 +1877,20 @@ msgstr "" ":class:`SelectorEventLoop` 在 Windows 上不支援上述方法。對於 Windows 請使用 :" "class:`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1266 +#: ../../library/asyncio-eventloop.rst:1272 msgid "" "The :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell` methods." msgstr ":meth:`loop.subprocess_exec` 和 :meth:`loop.subprocess_shell` 方法。" -#: ../../library/asyncio-eventloop.rst:1271 +#: ../../library/asyncio-eventloop.rst:1277 msgid "Unix signals" msgstr "Unix 訊號" -#: ../../library/asyncio-eventloop.rst:1277 +#: ../../library/asyncio-eventloop.rst:1283 msgid "Set *callback* as the handler for the *signum* signal." msgstr "將 *callback* 設置為 *signum* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1279 +#: ../../library/asyncio-eventloop.rst:1285 msgid "" "The callback will be invoked by *loop*, along with other queued callbacks " "and runnable coroutines of that event loop. Unlike signal handlers " @@ -1895,7 +1901,7 @@ msgstr "" "用 :func:`signal.signal` 註冊的訊號處理程式不同,使用此函式註冊的回呼允許與事" "件迴圈進行互動。" -#: ../../library/asyncio-eventloop.rst:1284 +#: ../../library/asyncio-eventloop.rst:1290 msgid "" "Raise :exc:`ValueError` if the signal number is invalid or uncatchable. " "Raise :exc:`RuntimeError` if there is a problem setting up the handler." @@ -1903,16 +1909,16 @@ msgstr "" "如果訊號號無效或不可捕獲,引發 :exc:`ValueError`。如果設定處理程序有問題,拋" "出 :exc:`RuntimeError`。" -#: ../../library/asyncio-eventloop.rst:1290 +#: ../../library/asyncio-eventloop.rst:1296 msgid "" "Like :func:`signal.signal`, this function must be invoked in the main thread." msgstr "像 :func:`signal.signal` 一樣,此函式必須在主執行緒中叫用。" -#: ../../library/asyncio-eventloop.rst:1295 +#: ../../library/asyncio-eventloop.rst:1301 msgid "Remove the handler for the *sig* signal." msgstr "移除 *sig* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1297 +#: ../../library/asyncio-eventloop.rst:1303 msgid "" "Return ``True`` if the signal handler was removed, or ``False`` if no " "handler was set for the given signal." @@ -1920,19 +1926,19 @@ msgstr "" "如果訊號處理程式被移除,回傳 ``True``;如果給定訊號沒有設置處理程式,回傳 " "``False``。" -#: ../../library/asyncio-eventloop.rst:1304 +#: ../../library/asyncio-eventloop.rst:1310 msgid "The :mod:`signal` module." msgstr ":mod:`signal` 模組。" -#: ../../library/asyncio-eventloop.rst:1308 +#: ../../library/asyncio-eventloop.rst:1314 msgid "Executing code in thread or process pools" msgstr "在執行緒池或行程池中執行程式碼" -#: ../../library/asyncio-eventloop.rst:1312 +#: ../../library/asyncio-eventloop.rst:1318 msgid "Arrange for *func* to be called in the specified executor." msgstr "安排在指定的執行器中呼叫 *func*。" -#: ../../library/asyncio-eventloop.rst:1314 +#: ../../library/asyncio-eventloop.rst:1320 msgid "" "The *executor* argument should be an :class:`concurrent.futures.Executor` " "instance. The default executor is used if *executor* is ``None``. The " @@ -1941,7 +1947,7 @@ msgid "" "and used by :func:`run_in_executor` if needed." msgstr "" -#: ../../library/asyncio-eventloop.rst:1322 +#: ../../library/asyncio-eventloop.rst:1328 msgid "" "import asyncio\n" "import concurrent.futures\n" @@ -1984,7 +1990,7 @@ msgid "" " asyncio.run(main())" msgstr "" -#: ../../library/asyncio-eventloop.rst:1362 +#: ../../library/asyncio-eventloop.rst:1368 msgid "" "Note that the entry point guard (``if __name__ == '__main__'``) is required " "for option 3 due to the peculiarities of :mod:`multiprocessing`, which is " @@ -1996,11 +2002,11 @@ msgstr "" "== '__main__'``\\ )。請參閱\\ :ref:`主模組的安全引入 `。" -#: ../../library/asyncio-eventloop.rst:1367 +#: ../../library/asyncio-eventloop.rst:1373 msgid "This method returns a :class:`asyncio.Future` object." msgstr "此方法回傳 :class:`asyncio.Future` 物件。" -#: ../../library/asyncio-eventloop.rst:1369 +#: ../../library/asyncio-eventloop.rst:1375 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *func*." @@ -2008,7 +2014,7 @@ msgstr "" "使用 :func:`functools.partial` 將來\\ :ref:`關鍵字引數傳遞 `\\ 給 *func*。" -#: ../../library/asyncio-eventloop.rst:1372 +#: ../../library/asyncio-eventloop.rst:1378 msgid "" ":meth:`loop.run_in_executor` no longer configures the ``max_workers`` of the " "thread pool executor it creates, instead leaving it up to the thread pool " @@ -2019,7 +2025,7 @@ msgstr "" "``max_workers``,而是讓執行緒池執行器(\\ :class:`~concurrent.futures." "ThreadPoolExecutor`)設定預設值。" -#: ../../library/asyncio-eventloop.rst:1381 +#: ../../library/asyncio-eventloop.rst:1387 msgid "" "Set *executor* as the default executor used by :meth:`run_in_executor`. " "*executor* must be an instance of :class:`~concurrent.futures." @@ -2028,26 +2034,26 @@ msgstr "" "將 *executor* 設置為 :meth:`run_in_executor` 使用的預設執行器。*executor* 必" "須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1385 +#: ../../library/asyncio-eventloop.rst:1391 msgid "" "*executor* must be an instance of :class:`~concurrent.futures." "ThreadPoolExecutor`." msgstr "" "*executor* 必須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1391 +#: ../../library/asyncio-eventloop.rst:1397 msgid "Error Handling API" msgstr "錯誤處理 API" -#: ../../library/asyncio-eventloop.rst:1393 +#: ../../library/asyncio-eventloop.rst:1399 msgid "Allows customizing how exceptions are handled in the event loop." msgstr "允許自定義事件迴圈中的例外處理方式。" -#: ../../library/asyncio-eventloop.rst:1397 +#: ../../library/asyncio-eventloop.rst:1403 msgid "Set *handler* as the new event loop exception handler." msgstr "將 *handler* 設定為新的事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1399 +#: ../../library/asyncio-eventloop.rst:1405 msgid "" "If *handler* is ``None``, the default exception handler will be set. " "Otherwise, *handler* must be a callable with the signature matching ``(loop, " @@ -2060,7 +2066,7 @@ msgstr "" "圈的,``context`` 是包含例外詳細資訊的 ``dict`` 物件(有關情境的詳細資訊,請" "參閱 :meth:`call_exception_handler` 文件)。" -#: ../../library/asyncio-eventloop.rst:1407 +#: ../../library/asyncio-eventloop.rst:1413 msgid "" "If the handler is called on behalf of a :class:`~asyncio.Task` or :class:" "`~asyncio.Handle`, it is run in the :class:`contextvars.Context` of that " @@ -2069,7 +2075,7 @@ msgstr "" "如果代表 :class:`~asyncio.Task` 或 :class:`~asyncio.Handle` 呼叫處理程式,它" "將在該任務或回呼處理程式的 :class:`contextvars.Context` 中運行。" -#: ../../library/asyncio-eventloop.rst:1413 +#: ../../library/asyncio-eventloop.rst:1419 msgid "" "The handler may be called in the :class:`~contextvars.Context` of the task " "or handle where the exception originated." @@ -2077,18 +2083,18 @@ msgstr "" "處理程式可能在引發例外的任務或處理程式的 :class:`~contextvars.Context` 中被呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1418 +#: ../../library/asyncio-eventloop.rst:1424 msgid "" "Return the current exception handler, or ``None`` if no custom exception " "handler was set." msgstr "" "回傳目前的例外處理程式,如果未設置自定義例外處理程式,則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:1425 +#: ../../library/asyncio-eventloop.rst:1431 msgid "Default exception handler." msgstr "預設例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1427 +#: ../../library/asyncio-eventloop.rst:1433 msgid "" "This is called when an exception occurs and no exception handler is set. " "This can be called by a custom exception handler that wants to defer to the " @@ -2097,17 +2103,17 @@ msgstr "" "當發生例外且未設置例外處理程式時呼叫此函式。自定義例外處理程式可以呼叫此函式" "以轉由預設處理程式處理。" -#: ../../library/asyncio-eventloop.rst:1431 +#: ../../library/asyncio-eventloop.rst:1437 msgid "" "*context* parameter has the same meaning as in :meth:" "`call_exception_handler`." msgstr "*context* 參數與 :meth:`call_exception_handler` 中的意思相同。" -#: ../../library/asyncio-eventloop.rst:1436 +#: ../../library/asyncio-eventloop.rst:1442 msgid "Call the current event loop exception handler." msgstr "呼叫目前事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1438 +#: ../../library/asyncio-eventloop.rst:1444 msgid "" "*context* is a ``dict`` object containing the following keys (new keys may " "be introduced in future Python versions):" @@ -2115,55 +2121,55 @@ msgstr "" "*context* 是一個包含以下鍵的 ``dict`` 物件(未來的 Python 版本中可能會引入新" "的鍵):" -#: ../../library/asyncio-eventloop.rst:1441 +#: ../../library/asyncio-eventloop.rst:1447 msgid "'message': Error message;" msgstr "'message':錯誤訊息;" -#: ../../library/asyncio-eventloop.rst:1442 +#: ../../library/asyncio-eventloop.rst:1448 msgid "'exception' (optional): Exception object;" msgstr "'exception'(可選):例外物件;" -#: ../../library/asyncio-eventloop.rst:1443 +#: ../../library/asyncio-eventloop.rst:1449 msgid "'future' (optional): :class:`asyncio.Future` instance;" msgstr "'future'(可選): :class:`asyncio.Future` 實例;" -#: ../../library/asyncio-eventloop.rst:1444 +#: ../../library/asyncio-eventloop.rst:1450 msgid "'task' (optional): :class:`asyncio.Task` instance;" msgstr "'task'(可選): :class:`asyncio.Task` 實例;" -#: ../../library/asyncio-eventloop.rst:1445 +#: ../../library/asyncio-eventloop.rst:1451 msgid "'handle' (optional): :class:`asyncio.Handle` instance;" msgstr "'handle'(可選): :class:`asyncio.Handle` 實例;" -#: ../../library/asyncio-eventloop.rst:1446 +#: ../../library/asyncio-eventloop.rst:1452 msgid "'protocol' (optional): :ref:`Protocol ` instance;" msgstr "'protocol'(可選): :ref:`Protocol ` 實例;" -#: ../../library/asyncio-eventloop.rst:1447 +#: ../../library/asyncio-eventloop.rst:1453 msgid "'transport' (optional): :ref:`Transport ` instance;" msgstr "'transport'(可選): :ref:`Transport ` 實例;" -#: ../../library/asyncio-eventloop.rst:1448 +#: ../../library/asyncio-eventloop.rst:1454 msgid "'socket' (optional): :class:`socket.socket` instance;" msgstr "'socket'(可選): :class:`socket.socket` 實例;" -#: ../../library/asyncio-eventloop.rst:1449 +#: ../../library/asyncio-eventloop.rst:1455 msgid "'source_traceback' (optional): Traceback of the source;" msgstr "" -#: ../../library/asyncio-eventloop.rst:1450 +#: ../../library/asyncio-eventloop.rst:1456 msgid "'handle_traceback' (optional): Traceback of the handle;" msgstr "" -#: ../../library/asyncio-eventloop.rst:1451 +#: ../../library/asyncio-eventloop.rst:1457 msgid "'asyncgen' (optional): Asynchronous generator that caused" msgstr "'asyncgen'(可選): 非同步產生器引發" -#: ../../library/asyncio-eventloop.rst:1452 +#: ../../library/asyncio-eventloop.rst:1458 msgid "the exception." msgstr "例外。" -#: ../../library/asyncio-eventloop.rst:1456 +#: ../../library/asyncio-eventloop.rst:1462 msgid "" "This method should not be overloaded in subclassed event loops. For custom " "exception handling, use the :meth:`set_exception_handler` method." @@ -2171,15 +2177,15 @@ msgstr "" "此方法不應在子類別事件迴圈中被覆寫。為了自定義例外處理,請使用 :meth:" "`set_exception_handler` 方法。" -#: ../../library/asyncio-eventloop.rst:1461 +#: ../../library/asyncio-eventloop.rst:1467 msgid "Enabling debug mode" msgstr "啟用除錯模式" -#: ../../library/asyncio-eventloop.rst:1465 +#: ../../library/asyncio-eventloop.rst:1471 msgid "Get the debug mode (:class:`bool`) of the event loop." msgstr "取得事件迴圈的除錯模式(\\ :class:`bool`\\ )。" -#: ../../library/asyncio-eventloop.rst:1467 +#: ../../library/asyncio-eventloop.rst:1473 msgid "" "The default value is ``True`` if the environment variable :envvar:" "`PYTHONASYNCIODEBUG` is set to a non-empty string, ``False`` otherwise." @@ -2187,17 +2193,17 @@ msgstr "" "如果環境變數 :envvar:`PYTHONASYNCIODEBUG` 被設定為非空字串,則預設值為 " "``True``,否則為 ``False``。" -#: ../../library/asyncio-eventloop.rst:1473 +#: ../../library/asyncio-eventloop.rst:1479 msgid "Set the debug mode of the event loop." msgstr "設定事件迴圈的除錯模式。" -#: ../../library/asyncio-eventloop.rst:1477 +#: ../../library/asyncio-eventloop.rst:1483 msgid "" "The new :ref:`Python Development Mode ` can now also be used to " "enable the debug mode." msgstr "現在也可以使用新的 :ref:`Python 開發模式 ` 啟用除錯模式。" -#: ../../library/asyncio-eventloop.rst:1482 +#: ../../library/asyncio-eventloop.rst:1488 msgid "" "This attribute can be used to set the minimum execution duration in seconds " "that is considered \"slow\". When debug mode is enabled, \"slow\" callbacks " @@ -2206,19 +2212,19 @@ msgstr "" "此屬性可用於設定被視為\"慢\"的最短執行時間(以秒為單位)。啟用偵錯模式" "後,\"慢\"回呼將被記錄。" -#: ../../library/asyncio-eventloop.rst:1486 +#: ../../library/asyncio-eventloop.rst:1492 msgid "Default value is 100 milliseconds." msgstr "預設值為 100 毫秒" -#: ../../library/asyncio-eventloop.rst:1490 +#: ../../library/asyncio-eventloop.rst:1496 msgid "The :ref:`debug mode of asyncio `." msgstr ":ref:`asyncio 的除錯模式 `。" -#: ../../library/asyncio-eventloop.rst:1494 +#: ../../library/asyncio-eventloop.rst:1500 msgid "Running Subprocesses" msgstr "運行子行程" -#: ../../library/asyncio-eventloop.rst:1496 +#: ../../library/asyncio-eventloop.rst:1502 msgid "" "Methods described in this subsections are low-level. In regular async/await " "code consider using the high-level :func:`asyncio.create_subprocess_shell` " @@ -2228,7 +2234,7 @@ msgstr "" "func:`asyncio.create_subprocess_shell` 和 :func:`asyncio." "create_subprocess_exec` 輔助功能而不是。" -#: ../../library/asyncio-eventloop.rst:1503 +#: ../../library/asyncio-eventloop.rst:1509 msgid "" "On Windows, the default event loop :class:`ProactorEventLoop` supports " "subprocesses, whereas :class:`SelectorEventLoop` does not. See :ref:" @@ -2238,26 +2244,26 @@ msgstr "" "`SelectorEventLoop` 不支援。詳細資訊請參見 :ref:`Windows 上對於子行程的支援 " "`。" -#: ../../library/asyncio-eventloop.rst:1515 +#: ../../library/asyncio-eventloop.rst:1521 msgid "" "Create a subprocess from one or more string arguments specified by *args*." msgstr "從 *args* 指定的一個或多個字串引數建立子行程。" -#: ../../library/asyncio-eventloop.rst:1518 +#: ../../library/asyncio-eventloop.rst:1524 msgid "*args* must be a list of strings represented by:" msgstr "*args* 必須是由以下項表示的字串串列:" -#: ../../library/asyncio-eventloop.rst:1520 +#: ../../library/asyncio-eventloop.rst:1526 msgid ":class:`str`;" msgstr ":class:`str`;" -#: ../../library/asyncio-eventloop.rst:1521 +#: ../../library/asyncio-eventloop.rst:1527 msgid "" "or :class:`bytes`, encoded to the :ref:`filesystem encoding `." msgstr "或 :class:`bytes`,編碼為 :ref:`檔案系統編碼 `。" -#: ../../library/asyncio-eventloop.rst:1524 +#: ../../library/asyncio-eventloop.rst:1530 msgid "" "The first string specifies the program executable, and the remaining strings " "specify the arguments. Together, string arguments form the ``argv`` of the " @@ -2266,7 +2272,7 @@ msgstr "" "第一個字串指定程序可執行檔案,其餘字串指定引數。字串引數一起組成程序的 " "``argv``。" -#: ../../library/asyncio-eventloop.rst:1528 +#: ../../library/asyncio-eventloop.rst:1534 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=False`` and the list of strings passed as the first " @@ -2277,7 +2283,7 @@ msgstr "" "字串串列作為第一個引數傳遞;然而,:class:`~subprocess.Popen` 接受單個字串串列" "引數,*subprocess_exec* 接受多個字串引數。" -#: ../../library/asyncio-eventloop.rst:1534 +#: ../../library/asyncio-eventloop.rst:1540 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`asyncio.SubprocessProtocol` class." @@ -2285,67 +2291,67 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`asyncio.SubprocessProtocol` 子類別的可" "呼叫物件。" -#: ../../library/asyncio-eventloop.rst:1537 +#: ../../library/asyncio-eventloop.rst:1543 msgid "Other parameters:" msgstr "其他參數:" -#: ../../library/asyncio-eventloop.rst:1539 +#: ../../library/asyncio-eventloop.rst:1545 msgid "*stdin* can be any of these:" msgstr "*stdin* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1541 -#: ../../library/asyncio-eventloop.rst:1552 -#: ../../library/asyncio-eventloop.rst:1562 +#: ../../library/asyncio-eventloop.rst:1547 +#: ../../library/asyncio-eventloop.rst:1558 +#: ../../library/asyncio-eventloop.rst:1568 msgid "a file-like object" msgstr "類檔案物件" -#: ../../library/asyncio-eventloop.rst:1542 +#: ../../library/asyncio-eventloop.rst:1548 msgid "" "an existing file descriptor (a positive integer), for example those created " "with :meth:`os.pipe`" msgstr "現有的檔案描述器(正整數),例如用 :meth:`os.pipe` 建立的" -#: ../../library/asyncio-eventloop.rst:1543 -#: ../../library/asyncio-eventloop.rst:1553 -#: ../../library/asyncio-eventloop.rst:1563 +#: ../../library/asyncio-eventloop.rst:1549 +#: ../../library/asyncio-eventloop.rst:1559 +#: ../../library/asyncio-eventloop.rst:1569 msgid "" "the :const:`subprocess.PIPE` constant (default) which will create a new pipe " "and connect it," msgstr ":const:`subprocess.PIPE` 常數(預設),它將建立一個新的管道並連線," -#: ../../library/asyncio-eventloop.rst:1545 -#: ../../library/asyncio-eventloop.rst:1555 -#: ../../library/asyncio-eventloop.rst:1565 +#: ../../library/asyncio-eventloop.rst:1551 +#: ../../library/asyncio-eventloop.rst:1561 +#: ../../library/asyncio-eventloop.rst:1571 msgid "" "the value ``None`` which will make the subprocess inherit the file " "descriptor from this process" msgstr "值 ``None`` 將使子行程從此行程繼承檔案描述器" -#: ../../library/asyncio-eventloop.rst:1547 -#: ../../library/asyncio-eventloop.rst:1557 -#: ../../library/asyncio-eventloop.rst:1567 +#: ../../library/asyncio-eventloop.rst:1553 +#: ../../library/asyncio-eventloop.rst:1563 +#: ../../library/asyncio-eventloop.rst:1573 msgid "" "the :const:`subprocess.DEVNULL` constant which indicates that the special :" "data:`os.devnull` file will be used" msgstr "" ":const:`subprocess.DEVNULL` 常數,表示將使用特殊的 :data:`os.devnull` 檔案" -#: ../../library/asyncio-eventloop.rst:1550 +#: ../../library/asyncio-eventloop.rst:1556 msgid "*stdout* can be any of these:" msgstr "*stdout* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1560 +#: ../../library/asyncio-eventloop.rst:1566 msgid "*stderr* can be any of these:" msgstr "*stderr* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1569 +#: ../../library/asyncio-eventloop.rst:1575 msgid "" "the :const:`subprocess.STDOUT` constant which will connect the standard " "error stream to the process' standard output stream" msgstr "" ":const:`subprocess.STDOUT` 常數,它將標準錯誤串流連線到行程的標準輸出串流" -#: ../../library/asyncio-eventloop.rst:1572 +#: ../../library/asyncio-eventloop.rst:1578 msgid "" "All other keyword arguments are passed to :class:`subprocess.Popen` without " "interpretation, except for *bufsize*, *universal_newlines*, *shell*, *text*, " @@ -2355,7 +2361,7 @@ msgstr "" "*bufsize*、*universal_newlines*、*shell*、*text*、*encoding* 和 *errors* 除" "外,這些不應該指定。" -#: ../../library/asyncio-eventloop.rst:1577 +#: ../../library/asyncio-eventloop.rst:1583 msgid "" "The ``asyncio`` subprocess API does not support decoding the streams as " "text. :func:`bytes.decode` can be used to convert the bytes returned from " @@ -2364,7 +2370,7 @@ msgstr "" "``asyncio`` 子行程 API 不支援將串流解碼為文本。可以使用 :func:`bytes.decode` " "將從串流回傳的位元組轉換為文本。" -#: ../../library/asyncio-eventloop.rst:1581 +#: ../../library/asyncio-eventloop.rst:1587 msgid "" "If a file-like object passed as *stdin*, *stdout* or *stderr* represents a " "pipe, then the other side of this pipe should be registered with :meth:" @@ -2375,13 +2381,13 @@ msgstr "" "端應該使用 :meth:`~loop.connect_write_pipe` 或 :meth:`~loop." "connect_read_pipe` 註冊到事件迴圈中。" -#: ../../library/asyncio-eventloop.rst:1586 +#: ../../library/asyncio-eventloop.rst:1592 msgid "" "See the constructor of the :class:`subprocess.Popen` class for documentation " "on other arguments." msgstr "有關其他引數的文件,請參閱 :class:`subprocess.Popen` 類別的建構函式。" -#: ../../library/asyncio-eventloop.rst:1589 +#: ../../library/asyncio-eventloop.rst:1595 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`asyncio.SubprocessTransport` base class and *protocol* is an " @@ -2391,7 +2397,7 @@ msgstr "" "SubprocessTransport` 基底類別,*protocol* 是由 *protocol_factory* 實例化的物" "件。" -#: ../../library/asyncio-eventloop.rst:1598 +#: ../../library/asyncio-eventloop.rst:1604 msgid "" "Create a subprocess from *cmd*, which can be a :class:`str` or a :class:" "`bytes` string encoded to the :ref:`filesystem encoding ` 的 :class:`bytes` 字串。" -#: ../../library/asyncio-eventloop.rst:1603 +#: ../../library/asyncio-eventloop.rst:1609 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=True``." @@ -2408,7 +2414,7 @@ msgstr "" "這類似於標準函式庫中的 :class:`subprocess.Popen` 類別,使用 ``shell=True`` 呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1606 +#: ../../library/asyncio-eventloop.rst:1612 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`SubprocessProtocol` class." @@ -2416,13 +2422,13 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`SubprocessProtocol` 子類別的可呼叫物" "件。" -#: ../../library/asyncio-eventloop.rst:1609 +#: ../../library/asyncio-eventloop.rst:1615 msgid "" "See :meth:`~loop.subprocess_exec` for more details about the remaining " "arguments." msgstr "有關其餘引數的更多詳細資訊,請參閱 :meth:`~loop.subprocess_exec`。" -#: ../../library/asyncio-eventloop.rst:1612 +#: ../../library/asyncio-eventloop.rst:1618 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`SubprocessTransport` base class and *protocol* is an object " @@ -2432,7 +2438,7 @@ msgstr "" "`SubprocessTransport` 基底類別,而 *protocol* 是由 *protocol_factory* 實例化" "的物件。" -#: ../../library/asyncio-eventloop.rst:1617 +#: ../../library/asyncio-eventloop.rst:1623 msgid "" "It is the application's responsibility to ensure that all whitespace and " "special characters are quoted appropriately to avoid `shell injection " @@ -2445,11 +2451,11 @@ msgstr "" "wikipedia.org/wiki/Shell_injection#Shell_injection>`_\\ 風險。可以使用 :func:" "`shlex.quote` 函式來正確跳脫用於構建 shell 命令的字串中的空白和特殊字元。" -#: ../../library/asyncio-eventloop.rst:1626 +#: ../../library/asyncio-eventloop.rst:1632 msgid "Callback Handles" msgstr "回呼處理" -#: ../../library/asyncio-eventloop.rst:1630 +#: ../../library/asyncio-eventloop.rst:1636 msgid "" "A callback wrapper object returned by :meth:`loop.call_soon`, :meth:`loop." "call_soon_threadsafe`." @@ -2457,46 +2463,46 @@ msgstr "" "由 :meth:`loop.call_soon` 和 :meth:`loop.call_soon_threadsafe` 回傳的回呼包裝" "器。" -#: ../../library/asyncio-eventloop.rst:1635 +#: ../../library/asyncio-eventloop.rst:1641 msgid "" "Return the :class:`contextvars.Context` object associated with the handle." msgstr "回傳與處理相關聯的 :class:`contextvars.Context` 物件。" -#: ../../library/asyncio-eventloop.rst:1642 +#: ../../library/asyncio-eventloop.rst:1648 msgid "" "Cancel the callback. If the callback has already been canceled or executed, " "this method has no effect." msgstr "取消回呼。如果回呼已被取消或執行,此方法將不起作用。" -#: ../../library/asyncio-eventloop.rst:1647 +#: ../../library/asyncio-eventloop.rst:1653 msgid "Return ``True`` if the callback was cancelled." msgstr "如果回呼已被取消,回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1653 +#: ../../library/asyncio-eventloop.rst:1659 msgid "" "A callback wrapper object returned by :meth:`loop.call_later`, and :meth:" "`loop.call_at`." msgstr "由 :meth:`loop.call_later` 和 :meth:`loop.call_at` 回傳的回呼包裝器。" -#: ../../library/asyncio-eventloop.rst:1656 +#: ../../library/asyncio-eventloop.rst:1662 msgid "This class is a subclass of :class:`Handle`." msgstr "這個類別是 :class:`Handle` 的子類別。" -#: ../../library/asyncio-eventloop.rst:1660 +#: ../../library/asyncio-eventloop.rst:1666 msgid "Return a scheduled callback time as :class:`float` seconds." msgstr "回傳預定的回呼時間,以 :class:`float` 秒為單位。" -#: ../../library/asyncio-eventloop.rst:1662 +#: ../../library/asyncio-eventloop.rst:1668 msgid "" "The time is an absolute timestamp, using the same time reference as :meth:" "`loop.time`." msgstr "時間是一個絕對的時間戳,使用與 :meth:`loop.time` 相同的時間參照。" -#: ../../library/asyncio-eventloop.rst:1669 +#: ../../library/asyncio-eventloop.rst:1675 msgid "Server Objects" msgstr "Server 物件" -#: ../../library/asyncio-eventloop.rst:1671 +#: ../../library/asyncio-eventloop.rst:1677 msgid "" "Server objects are created by :meth:`loop.create_server`, :meth:`loop." "create_unix_server`, :func:`start_server`, and :func:`start_unix_server` " @@ -2506,11 +2512,11 @@ msgstr "" "create_unix_server`、:func:`start_server` 和 :func:`start_unix_server` 函式所" "建立。" -#: ../../library/asyncio-eventloop.rst:1675 +#: ../../library/asyncio-eventloop.rst:1681 msgid "Do not instantiate the :class:`Server` class directly." msgstr "請勿直接實例化 :class:`Server` 類別。" -#: ../../library/asyncio-eventloop.rst:1679 +#: ../../library/asyncio-eventloop.rst:1685 msgid "" "*Server* objects are asynchronous context managers. When used in an ``async " "with`` statement, it's guaranteed that the Server object is closed and not " @@ -2519,7 +2525,7 @@ msgstr "" "*Server* 物件是非同步情境管理器。當在 ``async with`` 陳述中使用時,可以保證在" "完成 ``async with`` 陳述時,Server 物件將會關閉並停止接受新的連線: ::" -#: ../../library/asyncio-eventloop.rst:1684 +#: ../../library/asyncio-eventloop.rst:1690 msgid "" "srv = await loop.create_server(...)\n" "\n" @@ -2535,30 +2541,30 @@ msgstr "" "\n" "# 此時 srv 已關閉,不再接受新的連線。" -#: ../../library/asyncio-eventloop.rst:1692 +#: ../../library/asyncio-eventloop.rst:1698 msgid "Server object is an asynchronous context manager since Python 3.7." msgstr "自 Python 3.7 起,Server 物件是非同步情境管理器。" -#: ../../library/asyncio-eventloop.rst:1695 +#: ../../library/asyncio-eventloop.rst:1701 msgid "" "This class was exposed publicly as ``asyncio.Server`` in Python 3.9.11, " "3.10.3 and 3.11." msgstr "" "此類別在 Python 3.9.11、3.10.3 和 3.11 中以 ``asyncio.Server`` 的形式被公開。" -#: ../../library/asyncio-eventloop.rst:1700 +#: ../../library/asyncio-eventloop.rst:1706 msgid "" "Stop serving: close listening sockets and set the :attr:`sockets` attribute " "to ``None``." msgstr "停止服務:關閉監聽的 sockets 並將 :attr:`sockets` 屬性設為 ``None``。" -#: ../../library/asyncio-eventloop.rst:1703 +#: ../../library/asyncio-eventloop.rst:1709 msgid "" "The sockets that represent existing incoming client connections are left " "open." msgstr "代表現有傳入用戶端連線的 sockets 仍然保持開啟。" -#: ../../library/asyncio-eventloop.rst:1706 +#: ../../library/asyncio-eventloop.rst:1712 msgid "" "The server is closed asynchronously; use the :meth:`wait_closed` coroutine " "to wait until the server is closed (and no more connections are active)." @@ -2566,53 +2572,53 @@ msgstr "" "伺服器以非同步方式關閉;使用 :meth:`wait_close` 協程等待伺服器關閉(不再有活" "躍連線)。" -#: ../../library/asyncio-eventloop.rst:1712 +#: ../../library/asyncio-eventloop.rst:1718 msgid "Close all existing incoming client connections." msgstr "關閉所有現有的傳入用戶端連線。" -#: ../../library/asyncio-eventloop.rst:1714 +#: ../../library/asyncio-eventloop.rst:1720 msgid "" "Calls :meth:`~asyncio.BaseTransport.close` on all associated transports." msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" -#: ../../library/asyncio-eventloop.rst:1717 +#: ../../library/asyncio-eventloop.rst:1723 msgid "" ":meth:`close` should be called before :meth:`close_clients` when closing the " "server to avoid races with new clients connecting." msgstr "" -#: ../../library/asyncio-eventloop.rst:1724 +#: ../../library/asyncio-eventloop.rst:1730 msgid "" "Close all existing incoming client connections immediately, without waiting " "for pending operations to complete." msgstr "立即關閉所有現有的傳入用戶端連線,而不等待待定操作完成。" -#: ../../library/asyncio-eventloop.rst:1727 +#: ../../library/asyncio-eventloop.rst:1733 msgid "" "Calls :meth:`~asyncio.WriteTransport.abort` on all associated transports." msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" -#: ../../library/asyncio-eventloop.rst:1730 +#: ../../library/asyncio-eventloop.rst:1736 msgid "" ":meth:`close` should be called before :meth:`abort_clients` when closing the " "server to avoid races with new clients connecting." msgstr "" -#: ../../library/asyncio-eventloop.rst:1737 +#: ../../library/asyncio-eventloop.rst:1743 msgid "Return the event loop associated with the server object." msgstr "回傳與伺服器物件關聯的事件迴圈。" -#: ../../library/asyncio-eventloop.rst:1744 +#: ../../library/asyncio-eventloop.rst:1750 msgid "Start accepting connections." msgstr "開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1746 +#: ../../library/asyncio-eventloop.rst:1752 msgid "" "This method is idempotent, so it can be called when the server is already " "serving." msgstr "此方法是幂等的,因此可以在伺服器已經運行時呼叫。" -#: ../../library/asyncio-eventloop.rst:1749 +#: ../../library/asyncio-eventloop.rst:1755 msgid "" "The *start_serving* keyword-only parameter to :meth:`loop.create_server` " "and :meth:`asyncio.start_server` allows creating a Server object that is not " @@ -2625,14 +2631,14 @@ msgstr "" "種情況下,可以使用 ``Server.start_serving()`` 或 :meth:`Server." "serve_forever` 來使 Server 開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1761 +#: ../../library/asyncio-eventloop.rst:1767 msgid "" "Start accepting connections until the coroutine is cancelled. Cancellation " "of ``serve_forever`` task causes the server to be closed." msgstr "" "開始接受連線,直到協程被取消。取消 ``serve_forever`` 任務會導致伺服器關閉。" -#: ../../library/asyncio-eventloop.rst:1765 +#: ../../library/asyncio-eventloop.rst:1771 msgid "" "This method can be called if the server is already accepting connections. " "Only one ``serve_forever`` task can exist per one *Server* object." @@ -2640,7 +2646,7 @@ msgstr "" "如果伺服器已經接受連線,則可以呼叫此方法。每個 *Server* 物件只能存在一個 " "``serve_forever`` 任務。" -#: ../../library/asyncio-eventloop.rst:1771 +#: ../../library/asyncio-eventloop.rst:1777 msgid "" "async def client_connected(reader, writer):\n" " # Communicate with the client with\n" @@ -2666,24 +2672,24 @@ msgstr "" "\n" "asyncio.run(main('127.0.0.1', 0))" -#: ../../library/asyncio-eventloop.rst:1787 +#: ../../library/asyncio-eventloop.rst:1793 msgid "Return ``True`` if the server is accepting new connections." msgstr "如果伺服器正在接受新連線,則回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1794 +#: ../../library/asyncio-eventloop.rst:1800 msgid "" "Wait until the :meth:`close` method completes and all active connections " "have finished." msgstr "等待 :meth:`close` 方法完成且所有活動連線都已結束。" -#: ../../library/asyncio-eventloop.rst:1799 +#: ../../library/asyncio-eventloop.rst:1805 msgid "" "List of socket-like objects, ``asyncio.trsock.TransportSocket``, which the " "server is listening on." msgstr "" "伺服器正在監聽的類似 socket 的物件串列,``asyncio.trsock.TransportSocket``。" -#: ../../library/asyncio-eventloop.rst:1802 +#: ../../library/asyncio-eventloop.rst:1808 msgid "" "Prior to Python 3.7 ``Server.sockets`` used to return an internal list of " "server sockets directly. In 3.7 a copy of that list is returned." @@ -2691,11 +2697,11 @@ msgstr "" "在 Python 3.7 之前,``Server.sockets`` 曾經直接回傳內部伺服器 sockets 的串" "列。在 3.7 中回傳了該串列的副本。" -#: ../../library/asyncio-eventloop.rst:1812 +#: ../../library/asyncio-eventloop.rst:1818 msgid "Event Loop Implementations" msgstr "事件迴圈實作" -#: ../../library/asyncio-eventloop.rst:1814 +#: ../../library/asyncio-eventloop.rst:1820 msgid "" "asyncio ships with two different event loop implementations: :class:" "`SelectorEventLoop` and :class:`ProactorEventLoop`." @@ -2703,17 +2709,17 @@ msgstr "" "asyncio 內附兩個不同的事件迴圈實作::class:`SelectorEventLoop` 和 :class:" "`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1817 +#: ../../library/asyncio-eventloop.rst:1823 msgid "By default asyncio is configured to use :class:`EventLoop`." msgstr "預設情況下,asyncio 被配置為要使用 :class:`EventLoop`。" -#: ../../library/asyncio-eventloop.rst:1822 +#: ../../library/asyncio-eventloop.rst:1828 msgid "" "A subclass of :class:`AbstractEventLoop` based on the :mod:`selectors` " "module." msgstr "基於 :mod:`selectors` 模組的一個 :class:`AbstractEventLoop` 子類別。" -#: ../../library/asyncio-eventloop.rst:1825 +#: ../../library/asyncio-eventloop.rst:1831 msgid "" "Uses the most efficient *selector* available for the given platform. It is " "also possible to manually configure the exact selector implementation to be " @@ -2722,7 +2728,7 @@ msgstr "" "使用特定平台上最有效的 *selector*。也可以手動配置要使用的確切 selector 實" "作: ::" -#: ../../library/asyncio-eventloop.rst:1829 +#: ../../library/asyncio-eventloop.rst:1835 msgid "" "import asyncio\n" "import selectors\n" @@ -2744,7 +2750,7 @@ msgstr "" "\n" "asyncio.set_event_loop_policy(MyPolicy())" -#: ../../library/asyncio-eventloop.rst:1845 +#: ../../library/asyncio-eventloop.rst:1851 msgid "" "A subclass of :class:`AbstractEventLoop` for Windows that uses \"I/O " "Completion Ports\" (IOCP)." @@ -2752,7 +2758,7 @@ msgstr "" "用於 Windows 的 :class:`AbstractEventLoop` 子類別,使用「I/O 完成埠 (IOCP, I/" "O Completion Ports)」。" -#: ../../library/asyncio-eventloop.rst:1851 +#: ../../library/asyncio-eventloop.rst:1857 msgid "" "`MSDN documentation on I/O Completion Ports `_." @@ -2760,13 +2766,13 @@ msgstr "" "`I/O 完成埠的 MSDN 文件 `_。" -#: ../../library/asyncio-eventloop.rst:1856 +#: ../../library/asyncio-eventloop.rst:1862 msgid "" "An alias to the most efficient available subclass of :class:" "`AbstractEventLoop` for the given platform." msgstr "" -#: ../../library/asyncio-eventloop.rst:1859 +#: ../../library/asyncio-eventloop.rst:1865 msgid "" "It is an alias to :class:`SelectorEventLoop` on Unix and :class:" "`ProactorEventLoop` on Windows." @@ -2774,11 +2780,11 @@ msgstr "" "在 Unix 上是 :class:`SelectorEventLoop` 的別名,在 Windows 上是 :class:" "`ProactorEventLoop` 的別名。" -#: ../../library/asyncio-eventloop.rst:1865 +#: ../../library/asyncio-eventloop.rst:1871 msgid "Abstract base class for asyncio-compliant event loops." msgstr "為符合 asyncio 標準的事件迴圈的抽象基礎類別。" -#: ../../library/asyncio-eventloop.rst:1867 +#: ../../library/asyncio-eventloop.rst:1873 msgid "" "The :ref:`asyncio-event-loop-methods` section lists all methods that an " "alternative implementation of ``AbstractEventLoop`` should have defined." @@ -2786,11 +2792,11 @@ msgstr "" ":ref:`asyncio-event-loop-methods` 部分列出了替代 ``AbstractEventLoop`` 實作應" "該定義的所有方法。" -#: ../../library/asyncio-eventloop.rst:1873 +#: ../../library/asyncio-eventloop.rst:1879 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-eventloop.rst:1875 +#: ../../library/asyncio-eventloop.rst:1881 msgid "" "Note that all examples in this section **purposefully** show how to use the " "low-level event loop APIs, such as :meth:`loop.run_forever` and :meth:`loop." @@ -2801,11 +2807,11 @@ msgstr "" "`loop.run_forever` 和 :meth:`loop.call_soon`。現代 asyncio 應用程式很少需要這" "種方式撰寫;請考慮使用高階的函式,如 :func:`asyncio.run`。" -#: ../../library/asyncio-eventloop.rst:1885 +#: ../../library/asyncio-eventloop.rst:1891 msgid "Hello World with call_soon()" msgstr "使用 call_soon() 的 Hello World 範例" -#: ../../library/asyncio-eventloop.rst:1887 +#: ../../library/asyncio-eventloop.rst:1893 msgid "" "An example using the :meth:`loop.call_soon` method to schedule a callback. " "The callback displays ``\"Hello World\"`` and then stops the event loop::" @@ -2813,7 +2819,7 @@ msgstr "" "使用 :meth:`loop.call_soon` 方法排程回呼的範例。回呼會顯示 ``\"Hello " "World\"``,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1891 +#: ../../library/asyncio-eventloop.rst:1897 msgid "" "import asyncio\n" "\n" @@ -2851,18 +2857,18 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1911 +#: ../../library/asyncio-eventloop.rst:1917 msgid "" "A similar :ref:`Hello World ` example created with a coroutine " "and the :func:`run` function." msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`Hello World ` 範例。" -#: ../../library/asyncio-eventloop.rst:1918 +#: ../../library/asyncio-eventloop.rst:1924 msgid "Display the current date with call_later()" msgstr "使用 call_later() 顯示目前日期" -#: ../../library/asyncio-eventloop.rst:1920 +#: ../../library/asyncio-eventloop.rst:1926 msgid "" "An example of a callback displaying the current date every second. The " "callback uses the :meth:`loop.call_later` method to reschedule itself after " @@ -2871,7 +2877,7 @@ msgstr "" "一個回呼的範例,每秒顯示目前日期。回呼使用 :meth:`loop.call_later` 方法在 5 " "秒後重新排程自己,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1924 +#: ../../library/asyncio-eventloop.rst:1930 msgid "" "import asyncio\n" "import datetime\n" @@ -2917,7 +2923,7 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1948 +#: ../../library/asyncio-eventloop.rst:1954 msgid "" "A similar :ref:`current date ` example created with a " "coroutine and the :func:`run` function." @@ -2925,11 +2931,11 @@ msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`current date " "` 範例。" -#: ../../library/asyncio-eventloop.rst:1955 +#: ../../library/asyncio-eventloop.rst:1961 msgid "Watch a file descriptor for read events" msgstr "監聽檔案描述器以進行讀取事件" -#: ../../library/asyncio-eventloop.rst:1957 +#: ../../library/asyncio-eventloop.rst:1963 msgid "" "Wait until a file descriptor received some data using the :meth:`loop." "add_reader` method and then close the event loop::" @@ -2937,7 +2943,7 @@ msgstr "" "使用 :meth:`loop.add_reader` 方法等待檔案描述器接收到某些資料,然後關閉事件迴" "圈: ::" -#: ../../library/asyncio-eventloop.rst:1960 +#: ../../library/asyncio-eventloop.rst:1966 msgid "" "import asyncio\n" "from socket import socketpair\n" @@ -3005,7 +3011,7 @@ msgstr "" " wsock.close()\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1995 +#: ../../library/asyncio-eventloop.rst:2001 msgid "" "A similar :ref:`example ` using " "transports, protocols, and the :meth:`loop.create_connection` method." @@ -3013,7 +3019,7 @@ msgstr "" "使用傳輸、協定和 :meth:`loop.create_connection` 方法的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:1999 +#: ../../library/asyncio-eventloop.rst:2005 msgid "" "Another similar :ref:`example ` " "using the high-level :func:`asyncio.open_connection` function and streams." @@ -3021,15 +3027,15 @@ msgstr "" "另一個使用高階 :func:`asyncio.open_connection` 函式和串流的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:2007 +#: ../../library/asyncio-eventloop.rst:2013 msgid "Set signal handlers for SIGINT and SIGTERM" msgstr "設定 SIGINT 和 SIGTERM 的訊號處理程式" -#: ../../library/asyncio-eventloop.rst:2009 +#: ../../library/asyncio-eventloop.rst:2015 msgid "(This ``signals`` example only works on Unix.)" msgstr "(此 ``signals`` 範例僅在 Unix 上運作。)" -#: ../../library/asyncio-eventloop.rst:2011 +#: ../../library/asyncio-eventloop.rst:2017 msgid "" "Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal." "SIGTERM` using the :meth:`loop.add_signal_handler` method::" @@ -3037,7 +3043,7 @@ msgstr "" "使用 :meth:`loop.add_signal_handler` 方法註冊訊號 :py:data:`SIGINT` 和 :py:" "data:`SIGTERM` 的處理程式: ::" -#: ../../library/asyncio-eventloop.rst:2014 +#: ../../library/asyncio-eventloop.rst:2020 msgid "" "import asyncio\n" "import functools\n" diff --git a/library/multiprocessing.po b/library/multiprocessing.po index 9c7cbb4de5..c1a61a818f 100644 --- a/library/multiprocessing.po +++ b/library/multiprocessing.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-28 00:20+0000\n" +"POT-Creation-Date: 2025-07-28 17:30+0000\n" "PO-Revision-Date: 2018-05-23 16:06+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -206,11 +206,11 @@ msgid "" "start a process. These *start methods* are" msgstr "" -#: ../../library/multiprocessing.rst:114 +#: ../../library/multiprocessing.rst:116 msgid "*spawn*" msgstr "*spawn*" -#: ../../library/multiprocessing.rst:115 +#: ../../library/multiprocessing.rst:117 msgid "" "The parent process starts a fresh Python interpreter process. The child " "process will only inherit those resources necessary to run the process " @@ -220,16 +220,16 @@ msgid "" "or *forkserver*." msgstr "" -#: ../../library/multiprocessing.rst:122 +#: ../../library/multiprocessing.rst:124 msgid "" "Available on POSIX and Windows platforms. The default on Windows and macOS." msgstr "" -#: ../../library/multiprocessing.rst:124 +#: ../../library/multiprocessing.rst:128 msgid "*fork*" msgstr "*fork*" -#: ../../library/multiprocessing.rst:125 +#: ../../library/multiprocessing.rst:129 msgid "" "The parent process uses :func:`os.fork` to fork the Python interpreter. The " "child process, when it begins, is effectively identical to the parent " @@ -237,19 +237,19 @@ msgid "" "Note that safely forking a multithreaded process is problematic." msgstr "" -#: ../../library/multiprocessing.rst:131 +#: ../../library/multiprocessing.rst:135 msgid "" "Available on POSIX systems. Currently the default on POSIX except macOS." msgstr "" -#: ../../library/multiprocessing.rst:134 +#: ../../library/multiprocessing.rst:138 msgid "" "The default start method will change away from *fork* in Python 3.14. Code " "that requires *fork* should explicitly specify that via :func:`get_context` " "or :func:`set_start_method`." msgstr "" -#: ../../library/multiprocessing.rst:138 +#: ../../library/multiprocessing.rst:142 msgid "" "If Python is able to detect that your process has multiple threads, the :" "func:`os.fork` function that this start method calls internally will raise " @@ -257,11 +257,11 @@ msgid "" "fork` documentation for further explanation." msgstr "" -#: ../../library/multiprocessing.rst:144 +#: ../../library/multiprocessing.rst:150 msgid "*forkserver*" msgstr "*forkserver*" -#: ../../library/multiprocessing.rst:145 +#: ../../library/multiprocessing.rst:151 msgid "" "When the program starts and selects the *forkserver* start method, a server " "process is spawned. From then on, whenever a new process is needed, the " @@ -271,27 +271,27 @@ msgid "" "for it to use :func:`os.fork`. No unnecessary resources are inherited." msgstr "" -#: ../../library/multiprocessing.rst:153 +#: ../../library/multiprocessing.rst:159 msgid "" "Available on POSIX platforms which support passing file descriptors over " "Unix pipes such as Linux." msgstr "" -#: ../../library/multiprocessing.rst:157 +#: ../../library/multiprocessing.rst:163 msgid "" "*spawn* added on all POSIX platforms, and *forkserver* added for some POSIX " "platforms. Child processes no longer inherit all of the parents inheritable " "handles on Windows." msgstr "" -#: ../../library/multiprocessing.rst:165 +#: ../../library/multiprocessing.rst:171 msgid "" "On macOS, the *spawn* start method is now the default. The *fork* start " "method should be considered unsafe as it can lead to crashes of the " "subprocess as macOS system libraries may start threads. See :issue:`33725`." msgstr "" -#: ../../library/multiprocessing.rst:169 +#: ../../library/multiprocessing.rst:175 msgid "" "On POSIX using the *spawn* or *forkserver* start methods will also start a " "*resource tracker* process which tracks the unlinked named system resources " @@ -306,13 +306,13 @@ msgid "" "space in the main memory.)" msgstr "" -#: ../../library/multiprocessing.rst:182 +#: ../../library/multiprocessing.rst:188 msgid "" "To select a start method you use the :func:`set_start_method` in the ``if " "__name__ == '__main__'`` clause of the main module. For example::" msgstr "" -#: ../../library/multiprocessing.rst:186 +#: ../../library/multiprocessing.rst:192 msgid "" "import multiprocessing as mp\n" "\n" @@ -340,19 +340,19 @@ msgstr "" " print(q.get())\n" " p.join()" -#: ../../library/multiprocessing.rst:199 +#: ../../library/multiprocessing.rst:205 msgid "" ":func:`set_start_method` should not be used more than once in the program." msgstr "" -#: ../../library/multiprocessing.rst:202 +#: ../../library/multiprocessing.rst:208 msgid "" "Alternatively, you can use :func:`get_context` to obtain a context object. " "Context objects have the same API as the multiprocessing module, and allow " "one to use multiple start methods in the same program. ::" msgstr "" -#: ../../library/multiprocessing.rst:207 +#: ../../library/multiprocessing.rst:213 msgid "" "import multiprocessing as mp\n" "\n" @@ -380,7 +380,7 @@ msgstr "" " print(q.get())\n" " p.join()" -#: ../../library/multiprocessing.rst:220 +#: ../../library/multiprocessing.rst:226 msgid "" "Note that objects related to one context may not be compatible with " "processes for a different context. In particular, locks created using the " @@ -388,7 +388,7 @@ msgid "" "*forkserver* start methods." msgstr "" -#: ../../library/multiprocessing.rst:225 +#: ../../library/multiprocessing.rst:231 msgid "" "Libraries using :mod:`multiprocessing` or :class:`~concurrent.futures." "ProcessPoolExecutor` should be designed to allow their users to provide " @@ -398,7 +398,7 @@ msgid "" "start method." msgstr "" -#: ../../library/multiprocessing.rst:234 +#: ../../library/multiprocessing.rst:240 msgid "" "The ``'spawn'`` and ``'forkserver'`` start methods generally cannot be used " "with \"frozen\" executables (i.e., binaries produced by packages like " @@ -406,27 +406,27 @@ msgid "" "method may work if code does not use threads." msgstr "" -#: ../../library/multiprocessing.rst:241 +#: ../../library/multiprocessing.rst:247 msgid "Exchanging objects between processes" msgstr "" -#: ../../library/multiprocessing.rst:243 +#: ../../library/multiprocessing.rst:249 msgid "" ":mod:`multiprocessing` supports two types of communication channel between " "processes:" msgstr "" -#: ../../library/multiprocessing.rst:246 +#: ../../library/multiprocessing.rst:252 msgid "**Queues**" msgstr "" -#: ../../library/multiprocessing.rst:248 +#: ../../library/multiprocessing.rst:254 msgid "" "The :class:`Queue` class is a near clone of :class:`queue.Queue`. For " "example::" msgstr "" -#: ../../library/multiprocessing.rst:251 +#: ../../library/multiprocessing.rst:257 msgid "" "from multiprocessing import Process, Queue\n" "\n" @@ -452,23 +452,23 @@ msgstr "" " print(q.get()) # 印出 \"[42, None, 'hello']\"\n" " p.join()" -#: ../../library/multiprocessing.rst:263 +#: ../../library/multiprocessing.rst:269 msgid "" "Queues are thread and process safe. Any object put into a :mod:" "`~multiprocessing` queue will be serialized." msgstr "" -#: ../../library/multiprocessing.rst:266 +#: ../../library/multiprocessing.rst:272 msgid "**Pipes**" msgstr "" -#: ../../library/multiprocessing.rst:268 +#: ../../library/multiprocessing.rst:274 msgid "" "The :func:`Pipe` function returns a pair of connection objects connected by " "a pipe which by default is duplex (two-way). For example::" msgstr "" -#: ../../library/multiprocessing.rst:271 +#: ../../library/multiprocessing.rst:277 msgid "" "from multiprocessing import Process, Pipe\n" "\n" @@ -496,7 +496,7 @@ msgstr "" " print(parent_conn.recv()) # 印出 \"[42, None, 'hello']\"\n" " p.join()" -#: ../../library/multiprocessing.rst:284 +#: ../../library/multiprocessing.rst:290 msgid "" "The two connection objects returned by :func:`Pipe` represent the two ends " "of the pipe. Each connection object has :meth:`~Connection.send` and :meth:" @@ -506,24 +506,24 @@ msgid "" "corruption from processes using different ends of the pipe at the same time." msgstr "" -#: ../../library/multiprocessing.rst:292 +#: ../../library/multiprocessing.rst:298 msgid "" "The :meth:`~Connection.send` method serializes the object and :meth:" "`~Connection.recv` re-creates the object." msgstr "" -#: ../../library/multiprocessing.rst:296 +#: ../../library/multiprocessing.rst:302 msgid "Synchronization between processes" msgstr "" -#: ../../library/multiprocessing.rst:298 +#: ../../library/multiprocessing.rst:304 msgid "" ":mod:`multiprocessing` contains equivalents of all the synchronization " "primitives from :mod:`threading`. For instance one can use a lock to ensure " "that only one process prints to standard output at a time::" msgstr "" -#: ../../library/multiprocessing.rst:302 +#: ../../library/multiprocessing.rst:308 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -555,40 +555,40 @@ msgstr "" " for num in range(10):\n" " Process(target=f, args=(lock, num)).start()" -#: ../../library/multiprocessing.rst:317 +#: ../../library/multiprocessing.rst:323 msgid "" "Without using the lock output from the different processes is liable to get " "all mixed up." msgstr "" -#: ../../library/multiprocessing.rst:322 +#: ../../library/multiprocessing.rst:328 msgid "Sharing state between processes" msgstr "" -#: ../../library/multiprocessing.rst:324 +#: ../../library/multiprocessing.rst:330 msgid "" "As mentioned above, when doing concurrent programming it is usually best to " "avoid using shared state as far as possible. This is particularly true when " "using multiple processes." msgstr "" -#: ../../library/multiprocessing.rst:328 +#: ../../library/multiprocessing.rst:334 msgid "" "However, if you really do need to use some shared data then :mod:" "`multiprocessing` provides a couple of ways of doing so." msgstr "" -#: ../../library/multiprocessing.rst:331 +#: ../../library/multiprocessing.rst:337 msgid "**Shared memory**" msgstr "" -#: ../../library/multiprocessing.rst:333 +#: ../../library/multiprocessing.rst:339 msgid "" "Data can be stored in a shared memory map using :class:`Value` or :class:" "`Array`. For example, the following code ::" msgstr "" -#: ../../library/multiprocessing.rst:336 +#: ../../library/multiprocessing.rst:342 msgid "" "from multiprocessing import Process, Value, Array\n" "\n" @@ -626,11 +626,11 @@ msgstr "" " print(num.value)\n" " print(arr[:])" -#: ../../library/multiprocessing.rst:354 ../../library/multiprocessing.rst:400 +#: ../../library/multiprocessing.rst:360 ../../library/multiprocessing.rst:406 msgid "will print ::" msgstr "" -#: ../../library/multiprocessing.rst:356 +#: ../../library/multiprocessing.rst:362 msgid "" "3.1415927\n" "[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]" @@ -638,7 +638,7 @@ msgstr "" "3.1415927\n" "[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]" -#: ../../library/multiprocessing.rst:359 +#: ../../library/multiprocessing.rst:365 msgid "" "The ``'d'`` and ``'i'`` arguments used when creating ``num`` and ``arr`` are " "typecodes of the kind used by the :mod:`array` module: ``'d'`` indicates a " @@ -646,25 +646,25 @@ msgid "" "objects will be process and thread-safe." msgstr "" -#: ../../library/multiprocessing.rst:364 +#: ../../library/multiprocessing.rst:370 msgid "" "For more flexibility in using shared memory one can use the :mod:" "`multiprocessing.sharedctypes` module which supports the creation of " "arbitrary ctypes objects allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:368 +#: ../../library/multiprocessing.rst:374 msgid "**Server process**" msgstr "" -#: ../../library/multiprocessing.rst:370 +#: ../../library/multiprocessing.rst:376 msgid "" "A manager object returned by :func:`Manager` controls a server process which " "holds Python objects and allows other processes to manipulate them using " "proxies." msgstr "" -#: ../../library/multiprocessing.rst:374 +#: ../../library/multiprocessing.rst:380 msgid "" "A manager returned by :func:`Manager` will support types :class:`list`, :" "class:`dict`, :class:`~managers.Namespace`, :class:`Lock`, :class:`RLock`, :" @@ -673,7 +673,7 @@ msgid "" "`Array`. For example, ::" msgstr "" -#: ../../library/multiprocessing.rst:380 +#: ../../library/multiprocessing.rst:386 msgid "" "from multiprocessing import Process, Manager\n" "\n" @@ -715,7 +715,7 @@ msgstr "" " print(d)\n" " print(l)" -#: ../../library/multiprocessing.rst:402 +#: ../../library/multiprocessing.rst:408 msgid "" "{0.25: None, 1: '1', '2': 2}\n" "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]" @@ -723,7 +723,7 @@ msgstr "" "{0.25: None, 1: '1', '2': 2}\n" "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]" -#: ../../library/multiprocessing.rst:405 +#: ../../library/multiprocessing.rst:411 msgid "" "Server process managers are more flexible than using shared memory objects " "because they can be made to support arbitrary object types. Also, a single " @@ -731,22 +731,22 @@ msgid "" "They are, however, slower than using shared memory." msgstr "" -#: ../../library/multiprocessing.rst:412 +#: ../../library/multiprocessing.rst:418 msgid "Using a pool of workers" msgstr "" -#: ../../library/multiprocessing.rst:414 +#: ../../library/multiprocessing.rst:420 msgid "" "The :class:`~multiprocessing.pool.Pool` class represents a pool of worker " "processes. It has methods which allows tasks to be offloaded to the worker " "processes in a few different ways." msgstr "" -#: ../../library/multiprocessing.rst:418 +#: ../../library/multiprocessing.rst:424 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/multiprocessing.rst:420 +#: ../../library/multiprocessing.rst:426 msgid "" "from multiprocessing import Pool, TimeoutError\n" "import time\n" @@ -795,13 +795,13 @@ msgid "" " print(\"Now the pool is closed and no longer available\")" msgstr "" -#: ../../library/multiprocessing.rst:462 +#: ../../library/multiprocessing.rst:468 msgid "" "Note that the methods of a pool should only ever be used by the process " "which created it." msgstr "" -#: ../../library/multiprocessing.rst:467 +#: ../../library/multiprocessing.rst:473 msgid "" "Functionality within this package requires that the ``__main__`` module be " "importable by the children. This is covered in :ref:`multiprocessing-" @@ -810,7 +810,7 @@ msgid "" "work in the interactive interpreter. For example::" msgstr "" -#: ../../library/multiprocessing.rst:473 +#: ../../library/multiprocessing.rst:479 msgid "" ">>> from multiprocessing import Pool\n" ">>> p = Pool(5)\n" @@ -852,35 +852,35 @@ msgstr "" "AttributeError: Can't get attribute 'f' on )>" -#: ../../library/multiprocessing.rst:490 +#: ../../library/multiprocessing.rst:496 msgid "" "(If you try this it will actually output three full tracebacks interleaved " "in a semi-random fashion, and then you may have to stop the parent process " "somehow.)" msgstr "" -#: ../../library/multiprocessing.rst:496 +#: ../../library/multiprocessing.rst:502 msgid "Reference" msgstr "" -#: ../../library/multiprocessing.rst:498 +#: ../../library/multiprocessing.rst:504 msgid "" "The :mod:`multiprocessing` package mostly replicates the API of the :mod:" "`threading` module." msgstr "" -#: ../../library/multiprocessing.rst:503 +#: ../../library/multiprocessing.rst:509 msgid ":class:`Process` and exceptions" msgstr ":class:`Process` 與例外" -#: ../../library/multiprocessing.rst:508 +#: ../../library/multiprocessing.rst:514 msgid "" "Process objects represent activity that is run in a separate process. The :" "class:`Process` class has equivalents of all the methods of :class:" "`threading.Thread`." msgstr "" -#: ../../library/multiprocessing.rst:512 +#: ../../library/multiprocessing.rst:518 msgid "" "The constructor should always be called with keyword arguments. *group* " "should always be ``None``; it exists solely for compatibility with :class:" @@ -894,21 +894,21 @@ msgid "" "creating process." msgstr "" -#: ../../library/multiprocessing.rst:523 +#: ../../library/multiprocessing.rst:529 msgid "" "By default, no arguments are passed to *target*. The *args* argument, which " "defaults to ``()``, can be used to specify a list or tuple of the arguments " "to pass to *target*." msgstr "" -#: ../../library/multiprocessing.rst:527 +#: ../../library/multiprocessing.rst:533 msgid "" "If a subclass overrides the constructor, it must make sure it invokes the " "base class constructor (``super().__init__()``) before doing anything else " "to the process." msgstr "" -#: ../../library/multiprocessing.rst:533 +#: ../../library/multiprocessing.rst:539 msgid "" "In general, all arguments to :class:`Process` must be picklable. This is " "frequently observed when trying to create a :class:`Process` or use a :class:" @@ -916,7 +916,7 @@ msgid "" "*target* function." msgstr "" -#: ../../library/multiprocessing.rst:538 +#: ../../library/multiprocessing.rst:544 msgid "" "Passing a callable object defined in the current REPL session causes the " "child process to die via an uncaught :exc:`AttributeError` exception when " @@ -924,11 +924,11 @@ msgid "" "order to be loaded during unpickling." msgstr "" -#: ../../library/multiprocessing.rst:543 +#: ../../library/multiprocessing.rst:549 msgid "Example of this uncatchable error from the child::" msgstr "" -#: ../../library/multiprocessing.rst:545 +#: ../../library/multiprocessing.rst:551 msgid "" ">>> import multiprocessing as mp\n" ">>> def knigit():\n" @@ -958,7 +958,7 @@ msgstr "" "" -#: ../../library/multiprocessing.rst:558 +#: ../../library/multiprocessing.rst:564 msgid "" "See :ref:`multiprocessing-programming-spawn`. While this restriction is not " "true if using the ``\"fork\"`` start method, as of Python ``3.14`` that is " @@ -966,15 +966,15 @@ msgid "" "methods`. See also :gh:`132898`." msgstr "" -#: ../../library/multiprocessing.rst:564 +#: ../../library/multiprocessing.rst:570 msgid "Added the *daemon* parameter." msgstr "新增 *daemon* 參數。" -#: ../../library/multiprocessing.rst:569 +#: ../../library/multiprocessing.rst:575 msgid "Method representing the process's activity." msgstr "" -#: ../../library/multiprocessing.rst:571 +#: ../../library/multiprocessing.rst:577 msgid "" "You may override this method in a subclass. The standard :meth:`run` method " "invokes the callable object passed to the object's constructor as the target " @@ -982,17 +982,17 @@ msgid "" "*args* and *kwargs* arguments, respectively." msgstr "" -#: ../../library/multiprocessing.rst:576 +#: ../../library/multiprocessing.rst:582 msgid "" "Using a list or tuple as the *args* argument passed to :class:`Process` " "achieves the same effect." msgstr "" -#: ../../library/multiprocessing.rst:579 +#: ../../library/multiprocessing.rst:585 msgid "Example::" msgstr "範例: ::" -#: ../../library/multiprocessing.rst:581 +#: ../../library/multiprocessing.rst:587 msgid "" ">>> from multiprocessing import Process\n" ">>> p = Process(target=print, args=[1])\n" @@ -1010,17 +1010,17 @@ msgstr "" ">>> p.run()\n" "1" -#: ../../library/multiprocessing.rst:591 +#: ../../library/multiprocessing.rst:597 msgid "Start the process's activity." msgstr "" -#: ../../library/multiprocessing.rst:593 +#: ../../library/multiprocessing.rst:599 msgid "" "This must be called at most once per process object. It arranges for the " "object's :meth:`run` method to be invoked in a separate process." msgstr "" -#: ../../library/multiprocessing.rst:598 +#: ../../library/multiprocessing.rst:604 msgid "" "If the optional argument *timeout* is ``None`` (the default), the method " "blocks until the process whose :meth:`join` method is called terminates. If " @@ -1030,23 +1030,23 @@ msgid "" "terminated." msgstr "" -#: ../../library/multiprocessing.rst:605 +#: ../../library/multiprocessing.rst:611 msgid "A process can be joined many times." msgstr "" -#: ../../library/multiprocessing.rst:607 +#: ../../library/multiprocessing.rst:613 msgid "" "A process cannot join itself because this would cause a deadlock. It is an " "error to attempt to join a process before it has been started." msgstr "" -#: ../../library/multiprocessing.rst:612 +#: ../../library/multiprocessing.rst:618 msgid "" "The process's name. The name is a string used for identification purposes " "only. It has no semantics. Multiple processes may be given the same name." msgstr "" -#: ../../library/multiprocessing.rst:616 +#: ../../library/multiprocessing.rst:622 msgid "" "The initial name is set by the constructor. If no explicit name is provided " "to the constructor, a name of the form 'Process-N\\ :sub:`1`:N\\ :sub:" @@ -1054,33 +1054,33 @@ msgid "" "child of its parent." msgstr "" -#: ../../library/multiprocessing.rst:623 +#: ../../library/multiprocessing.rst:629 msgid "Return whether the process is alive." msgstr "" -#: ../../library/multiprocessing.rst:625 +#: ../../library/multiprocessing.rst:631 msgid "" "Roughly, a process object is alive from the moment the :meth:`start` method " "returns until the child process terminates." msgstr "" -#: ../../library/multiprocessing.rst:630 +#: ../../library/multiprocessing.rst:636 msgid "" "The process's daemon flag, a Boolean value. This must be set before :meth:" "`start` is called." msgstr "" -#: ../../library/multiprocessing.rst:633 +#: ../../library/multiprocessing.rst:639 msgid "The initial value is inherited from the creating process." msgstr "" -#: ../../library/multiprocessing.rst:635 +#: ../../library/multiprocessing.rst:641 msgid "" "When a process exits, it attempts to terminate all of its daemonic child " "processes." msgstr "" -#: ../../library/multiprocessing.rst:638 +#: ../../library/multiprocessing.rst:644 msgid "" "Note that a daemonic process is not allowed to create child processes. " "Otherwise a daemonic process would leave its children orphaned if it gets " @@ -1089,92 +1089,92 @@ msgid "" "(and not joined) if non-daemonic processes have exited." msgstr "" -#: ../../library/multiprocessing.rst:644 +#: ../../library/multiprocessing.rst:650 msgid "" "In addition to the :class:`threading.Thread` API, :class:`Process` objects " "also support the following attributes and methods:" msgstr "" -#: ../../library/multiprocessing.rst:649 +#: ../../library/multiprocessing.rst:655 msgid "" "Return the process ID. Before the process is spawned, this will be ``None``." msgstr "" -#: ../../library/multiprocessing.rst:654 +#: ../../library/multiprocessing.rst:660 msgid "" "The child's exit code. This will be ``None`` if the process has not yet " "terminated." msgstr "" -#: ../../library/multiprocessing.rst:657 +#: ../../library/multiprocessing.rst:663 msgid "" "If the child's :meth:`run` method returned normally, the exit code will be " "0. If it terminated via :func:`sys.exit` with an integer argument *N*, the " "exit code will be *N*." msgstr "" -#: ../../library/multiprocessing.rst:661 +#: ../../library/multiprocessing.rst:667 msgid "" "If the child terminated due to an exception not caught within :meth:`run`, " "the exit code will be 1. If it was terminated by signal *N*, the exit code " "will be the negative value *-N*." msgstr "" -#: ../../library/multiprocessing.rst:667 +#: ../../library/multiprocessing.rst:673 msgid "The process's authentication key (a byte string)." msgstr "" -#: ../../library/multiprocessing.rst:669 +#: ../../library/multiprocessing.rst:675 msgid "" "When :mod:`multiprocessing` is initialized the main process is assigned a " "random string using :func:`os.urandom`." msgstr "" -#: ../../library/multiprocessing.rst:672 +#: ../../library/multiprocessing.rst:678 msgid "" "When a :class:`Process` object is created, it will inherit the " "authentication key of its parent process, although this may be changed by " "setting :attr:`authkey` to another byte string." msgstr "" -#: ../../library/multiprocessing.rst:676 +#: ../../library/multiprocessing.rst:682 msgid "See :ref:`multiprocessing-auth-keys`." msgstr "參閱 :ref:`multiprocessing-auth-keys`。" -#: ../../library/multiprocessing.rst:680 +#: ../../library/multiprocessing.rst:686 msgid "" "A numeric handle of a system object which will become \"ready\" when the " "process ends." msgstr "" -#: ../../library/multiprocessing.rst:683 +#: ../../library/multiprocessing.rst:689 msgid "" "You can use this value if you want to wait on several events at once using :" "func:`multiprocessing.connection.wait`. Otherwise calling :meth:`join` is " "simpler." msgstr "" -#: ../../library/multiprocessing.rst:687 +#: ../../library/multiprocessing.rst:693 msgid "" "On Windows, this is an OS handle usable with the ``WaitForSingleObject`` and " "``WaitForMultipleObjects`` family of API calls. On POSIX, this is a file " "descriptor usable with primitives from the :mod:`select` module." msgstr "" -#: ../../library/multiprocessing.rst:695 +#: ../../library/multiprocessing.rst:701 msgid "" "Terminate the process. On POSIX this is done using the :py:const:`~signal." "SIGTERM` signal; on Windows :c:func:`!TerminateProcess` is used. Note that " "exit handlers and finally clauses, etc., will not be executed." msgstr "" -#: ../../library/multiprocessing.rst:699 +#: ../../library/multiprocessing.rst:705 msgid "" "Note that descendant processes of the process will *not* be terminated -- " "they will simply become orphaned." msgstr "" -#: ../../library/multiprocessing.rst:704 +#: ../../library/multiprocessing.rst:710 msgid "" "If this method is used when the associated process is using a pipe or queue " "then the pipe or queue is liable to become corrupted and may become unusable " @@ -1183,11 +1183,11 @@ msgid "" "deadlock." msgstr "" -#: ../../library/multiprocessing.rst:712 +#: ../../library/multiprocessing.rst:718 msgid "Same as :meth:`terminate` but using the ``SIGKILL`` signal on POSIX." msgstr "" -#: ../../library/multiprocessing.rst:718 +#: ../../library/multiprocessing.rst:724 msgid "" "Close the :class:`Process` object, releasing all resources associated with " "it. :exc:`ValueError` is raised if the underlying process is still " @@ -1195,18 +1195,18 @@ msgid "" "attributes of the :class:`Process` object will raise :exc:`ValueError`." msgstr "" -#: ../../library/multiprocessing.rst:726 +#: ../../library/multiprocessing.rst:732 msgid "" "Note that the :meth:`start`, :meth:`join`, :meth:`is_alive`, :meth:" "`terminate` and :attr:`exitcode` methods should only be called by the " "process that created the process object." msgstr "" -#: ../../library/multiprocessing.rst:730 +#: ../../library/multiprocessing.rst:736 msgid "Example usage of some of the methods of :class:`Process`:" msgstr "" -#: ../../library/multiprocessing.rst:732 +#: ../../library/multiprocessing.rst:738 msgid "" ">>> import multiprocessing, time, signal\n" ">>> mp_context = multiprocessing.get_context('spawn')\n" @@ -1238,48 +1238,48 @@ msgstr "" ">>> p.exitcode == -signal.SIGTERM\n" "True" -#: ../../library/multiprocessing.rst:751 +#: ../../library/multiprocessing.rst:757 msgid "The base class of all :mod:`multiprocessing` exceptions." msgstr "" -#: ../../library/multiprocessing.rst:755 +#: ../../library/multiprocessing.rst:761 msgid "" "Exception raised by :meth:`Connection.recv_bytes_into` when the supplied " "buffer object is too small for the message read." msgstr "" -#: ../../library/multiprocessing.rst:758 +#: ../../library/multiprocessing.rst:764 msgid "" "If ``e`` is an instance of :exc:`BufferTooShort` then ``e.args[0]`` will " "give the message as a byte string." msgstr "" -#: ../../library/multiprocessing.rst:763 +#: ../../library/multiprocessing.rst:769 msgid "Raised when there is an authentication error." msgstr "" -#: ../../library/multiprocessing.rst:767 +#: ../../library/multiprocessing.rst:773 msgid "Raised by methods with a timeout when the timeout expires." msgstr "" -#: ../../library/multiprocessing.rst:770 +#: ../../library/multiprocessing.rst:776 msgid "Pipes and Queues" msgstr "" -#: ../../library/multiprocessing.rst:772 +#: ../../library/multiprocessing.rst:778 msgid "" "When using multiple processes, one generally uses message passing for " "communication between processes and avoids having to use any synchronization " "primitives like locks." msgstr "" -#: ../../library/multiprocessing.rst:776 +#: ../../library/multiprocessing.rst:782 msgid "" "For passing messages one can use :func:`Pipe` (for a connection between two " "processes) or a queue (which allows multiple producers and consumers)." msgstr "" -#: ../../library/multiprocessing.rst:779 +#: ../../library/multiprocessing.rst:785 msgid "" "The :class:`Queue`, :class:`SimpleQueue` and :class:`JoinableQueue` types " "are multi-producer, multi-consumer :abbr:`FIFO (first-in, first-out)` queues " @@ -1289,7 +1289,7 @@ msgid "" "Queue` class." msgstr "" -#: ../../library/multiprocessing.rst:786 +#: ../../library/multiprocessing.rst:792 msgid "" "If you use :class:`JoinableQueue` then you **must** call :meth:" "`JoinableQueue.task_done` for each task removed from the queue or else the " @@ -1297,7 +1297,7 @@ msgid "" "overflow, raising an exception." msgstr "" -#: ../../library/multiprocessing.rst:791 +#: ../../library/multiprocessing.rst:797 msgid "" "One difference from other Python queue implementations, is that :mod:" "`multiprocessing` queues serializes all objects that are put into them " @@ -1305,20 +1305,20 @@ msgid "" "object that does not share memory with the original object." msgstr "" -#: ../../library/multiprocessing.rst:796 +#: ../../library/multiprocessing.rst:802 msgid "" "Note that one can also create a shared queue by using a manager object -- " "see :ref:`multiprocessing-managers`." msgstr "" -#: ../../library/multiprocessing.rst:801 +#: ../../library/multiprocessing.rst:807 msgid "" ":mod:`multiprocessing` uses the usual :exc:`queue.Empty` and :exc:`queue." "Full` exceptions to signal a timeout. They are not available in the :mod:" "`multiprocessing` namespace so you need to import them from :mod:`queue`." msgstr "" -#: ../../library/multiprocessing.rst:808 +#: ../../library/multiprocessing.rst:814 msgid "" "When an object is put on a queue, the object is pickled and a background " "thread later flushes the pickled data to an underlying pipe. This has some " @@ -1327,14 +1327,14 @@ msgid "" "a queue created with a :ref:`manager `." msgstr "" -#: ../../library/multiprocessing.rst:815 +#: ../../library/multiprocessing.rst:821 msgid "" "After putting an object on an empty queue there may be an infinitesimal " "delay before the queue's :meth:`~Queue.empty` method returns :const:`False` " "and :meth:`~Queue.get_nowait` can return without raising :exc:`queue.Empty`." msgstr "" -#: ../../library/multiprocessing.rst:820 +#: ../../library/multiprocessing.rst:826 msgid "" "If multiple processes are enqueuing objects, it is possible for the objects " "to be received at the other end out-of-order. However, objects enqueued by " @@ -1342,7 +1342,7 @@ msgid "" "other." msgstr "" -#: ../../library/multiprocessing.rst:827 +#: ../../library/multiprocessing.rst:833 msgid "" "If a process is killed using :meth:`Process.terminate` or :func:`os.kill` " "while it is trying to use a :class:`Queue`, then the data in the queue is " @@ -1350,7 +1350,7 @@ msgid "" "exception when it tries to use the queue later on." msgstr "" -#: ../../library/multiprocessing.rst:834 +#: ../../library/multiprocessing.rst:840 msgid "" "As mentioned above, if a child process has put items on a queue (and it has " "not used :meth:`JoinableQueue.cancel_join_thread ` flag or :envvar:`PYTHON_CPU_COUNT` as this is merely a wrapper around " "the :mod:`os` cpu count APIs." msgstr "" -#: ../../library/multiprocessing.rst:1075 +#: ../../library/multiprocessing.rst:1081 msgid "" "Return the :class:`Process` object corresponding to the current process." msgstr "" -#: ../../library/multiprocessing.rst:1077 +#: ../../library/multiprocessing.rst:1083 msgid "An analogue of :func:`threading.current_thread`." msgstr "" -#: ../../library/multiprocessing.rst:1081 +#: ../../library/multiprocessing.rst:1087 msgid "" "Return the :class:`Process` object corresponding to the parent process of " "the :func:`current_process`. For the main process, ``parent_process`` will " "be ``None``." msgstr "" -#: ../../library/multiprocessing.rst:1089 +#: ../../library/multiprocessing.rst:1095 msgid "" "Add support for when a program which uses :mod:`multiprocessing` has been " "frozen to produce an executable. (Has been tested with **py2exe**, " "**PyInstaller** and **cx_Freeze**.)" msgstr "" -#: ../../library/multiprocessing.rst:1093 +#: ../../library/multiprocessing.rst:1099 msgid "" "One needs to call this function straight after the ``if __name__ == " "'__main__'`` line of the main module. For example::" msgstr "" -#: ../../library/multiprocessing.rst:1096 +#: ../../library/multiprocessing.rst:1102 msgid "" "from multiprocessing import Process, freeze_support\n" "\n" @@ -1710,13 +1710,13 @@ msgstr "" " freeze_support()\n" " Process(target=f).start()" -#: ../../library/multiprocessing.rst:1105 +#: ../../library/multiprocessing.rst:1111 msgid "" "If the ``freeze_support()`` line is omitted then trying to run the frozen " "executable will raise :exc:`RuntimeError`." msgstr "" -#: ../../library/multiprocessing.rst:1108 +#: ../../library/multiprocessing.rst:1114 msgid "" "Calling ``freeze_support()`` has no effect when the start method is not " "*spawn*. In addition, if the module is being run normally by the Python " @@ -1724,7 +1724,7 @@ msgid "" "no effect." msgstr "" -#: ../../library/multiprocessing.rst:1115 +#: ../../library/multiprocessing.rst:1121 msgid "" "Returns a list of the supported start methods, the first of which is the " "default. The possible start methods are ``'fork'``, ``'spawn'`` and " @@ -1732,13 +1732,13 @@ msgid "" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1124 +#: ../../library/multiprocessing.rst:1130 msgid "" "Return a context object which has the same attributes as the :mod:" "`multiprocessing` module." msgstr "" -#: ../../library/multiprocessing.rst:1127 +#: ../../library/multiprocessing.rst:1133 msgid "" "If *method* is ``None`` then the default context is returned. Note that if " "the global start method has not been set, this will set it to the default " @@ -1747,11 +1747,11 @@ msgid "" "is not available. See :ref:`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1138 +#: ../../library/multiprocessing.rst:1144 msgid "Return the name of start method used for starting processes." msgstr "" -#: ../../library/multiprocessing.rst:1140 +#: ../../library/multiprocessing.rst:1146 msgid "" "If the global start method has not been set and *allow_none* is ``False``, " "then the start method is set to the default and the name is returned. If the " @@ -1759,43 +1759,43 @@ msgid "" "returned." msgstr "" -#: ../../library/multiprocessing.rst:1145 +#: ../../library/multiprocessing.rst:1151 msgid "" "The return value can be ``'fork'``, ``'spawn'``, ``'forkserver'`` or " "``None``. See :ref:`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1152 +#: ../../library/multiprocessing.rst:1158 msgid "" "On macOS, the *spawn* start method is now the default. The *fork* start " "method should be considered unsafe as it can lead to crashes of the " "subprocess. See :issue:`33725`." msgstr "" -#: ../../library/multiprocessing.rst:1158 +#: ../../library/multiprocessing.rst:1164 msgid "" "Set the path of the Python interpreter to use when starting a child process. " "(By default :data:`sys.executable` is used). Embedders will probably need " "to do some thing like ::" msgstr "" -#: ../../library/multiprocessing.rst:1162 +#: ../../library/multiprocessing.rst:1168 msgid "set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe'))" msgstr "set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe'))" -#: ../../library/multiprocessing.rst:1164 +#: ../../library/multiprocessing.rst:1170 msgid "before they can create child processes." msgstr "" -#: ../../library/multiprocessing.rst:1166 +#: ../../library/multiprocessing.rst:1172 msgid "Now supported on POSIX when the ``'spawn'`` start method is used." msgstr "" -#: ../../library/multiprocessing.rst:1169 +#: ../../library/multiprocessing.rst:1175 msgid "Accepts a :term:`path-like object`." msgstr "接受一個\\ :term:`類路徑物件 `。" -#: ../../library/multiprocessing.rst:1174 +#: ../../library/multiprocessing.rst:1180 msgid "" "Set a list of module names for the forkserver main process to attempt to " "import so that their already imported state is inherited by forked " @@ -1804,19 +1804,19 @@ msgid "" "process." msgstr "" -#: ../../library/multiprocessing.rst:1180 +#: ../../library/multiprocessing.rst:1186 msgid "" "For this to work, it must be called before the forkserver process has been " "launched (before creating a :class:`Pool` or starting a :class:`Process`)." msgstr "" -#: ../../library/multiprocessing.rst:1183 +#: ../../library/multiprocessing.rst:1189 msgid "" "Only meaningful when using the ``'forkserver'`` start method. See :ref:" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1190 +#: ../../library/multiprocessing.rst:1196 msgid "" "Set the method which should be used to start child processes. The *method* " "argument can be ``'fork'``, ``'spawn'`` or ``'forkserver'``. Raises :exc:" @@ -1826,17 +1826,17 @@ msgid "" "then the context is set to the default context." msgstr "" -#: ../../library/multiprocessing.rst:1197 +#: ../../library/multiprocessing.rst:1203 msgid "" "Note that this should be called at most once, and it should be protected " "inside the ``if __name__ == '__main__'`` clause of the main module." msgstr "" -#: ../../library/multiprocessing.rst:1201 +#: ../../library/multiprocessing.rst:1207 msgid "See :ref:`multiprocessing-start-methods`." msgstr "參閱 :ref:`multiprocessing-start-methods`。" -#: ../../library/multiprocessing.rst:1207 +#: ../../library/multiprocessing.rst:1213 msgid "" ":mod:`multiprocessing` contains no analogues of :func:`threading." "active_count`, :func:`threading.enumerate`, :func:`threading.settrace`, :" @@ -1844,75 +1844,75 @@ msgid "" "local`." msgstr "" -#: ../../library/multiprocessing.rst:1214 +#: ../../library/multiprocessing.rst:1220 msgid "Connection Objects" msgstr "" -#: ../../library/multiprocessing.rst:1218 +#: ../../library/multiprocessing.rst:1224 msgid "" "Connection objects allow the sending and receiving of picklable objects or " "strings. They can be thought of as message oriented connected sockets." msgstr "" -#: ../../library/multiprocessing.rst:1221 +#: ../../library/multiprocessing.rst:1227 msgid "" "Connection objects are usually created using :func:`Pipe ` -- see also :ref:`multiprocessing-listeners-clients`." msgstr "" -#: ../../library/multiprocessing.rst:1229 +#: ../../library/multiprocessing.rst:1235 msgid "" "Send an object to the other end of the connection which should be read " "using :meth:`recv`." msgstr "" -#: ../../library/multiprocessing.rst:1232 +#: ../../library/multiprocessing.rst:1238 msgid "" "The object must be picklable. Very large pickles (approximately 32 MiB+, " "though it depends on the OS) may raise a :exc:`ValueError` exception." msgstr "" -#: ../../library/multiprocessing.rst:1237 +#: ../../library/multiprocessing.rst:1243 msgid "" "Return an object sent from the other end of the connection using :meth:" "`send`. Blocks until there is something to receive. Raises :exc:`EOFError` " "if there is nothing left to receive and the other end was closed." msgstr "" -#: ../../library/multiprocessing.rst:1244 +#: ../../library/multiprocessing.rst:1250 msgid "Return the file descriptor or handle used by the connection." msgstr "" -#: ../../library/multiprocessing.rst:1248 +#: ../../library/multiprocessing.rst:1254 msgid "Close the connection." msgstr "" -#: ../../library/multiprocessing.rst:1250 +#: ../../library/multiprocessing.rst:1256 msgid "This is called automatically when the connection is garbage collected." msgstr "" -#: ../../library/multiprocessing.rst:1254 +#: ../../library/multiprocessing.rst:1260 msgid "Return whether there is any data available to be read." msgstr "" -#: ../../library/multiprocessing.rst:1256 +#: ../../library/multiprocessing.rst:1262 msgid "" "If *timeout* is not specified then it will return immediately. If *timeout* " "is a number then this specifies the maximum time in seconds to block. If " "*timeout* is ``None`` then an infinite timeout is used." msgstr "" -#: ../../library/multiprocessing.rst:1260 +#: ../../library/multiprocessing.rst:1266 msgid "" "Note that multiple connection objects may be polled at once by using :func:" "`multiprocessing.connection.wait`." msgstr "" -#: ../../library/multiprocessing.rst:1265 +#: ../../library/multiprocessing.rst:1271 msgid "Send byte data from a :term:`bytes-like object` as a complete message." msgstr "" -#: ../../library/multiprocessing.rst:1267 +#: ../../library/multiprocessing.rst:1273 msgid "" "If *offset* is given then data is read from that position in *buffer*. If " "*size* is given then that many bytes will be read from buffer. Very large " @@ -1920,7 +1920,7 @@ msgid "" "exc:`ValueError` exception" msgstr "" -#: ../../library/multiprocessing.rst:1274 +#: ../../library/multiprocessing.rst:1280 msgid "" "Return a complete message of byte data sent from the other end of the " "connection as a string. Blocks until there is something to receive. Raises :" @@ -1928,19 +1928,19 @@ msgid "" "closed." msgstr "" -#: ../../library/multiprocessing.rst:1279 +#: ../../library/multiprocessing.rst:1285 msgid "" "If *maxlength* is specified and the message is longer than *maxlength* then :" "exc:`OSError` is raised and the connection will no longer be readable." msgstr "" -#: ../../library/multiprocessing.rst:1283 +#: ../../library/multiprocessing.rst:1289 msgid "" "This function used to raise :exc:`IOError`, which is now an alias of :exc:" "`OSError`." msgstr "" -#: ../../library/multiprocessing.rst:1290 +#: ../../library/multiprocessing.rst:1296 msgid "" "Read into *buffer* a complete message of byte data sent from the other end " "of the connection and return the number of bytes in the message. Blocks " @@ -1948,38 +1948,38 @@ msgid "" "nothing left to receive and the other end was closed." msgstr "" -#: ../../library/multiprocessing.rst:1296 +#: ../../library/multiprocessing.rst:1302 msgid "" "*buffer* must be a writable :term:`bytes-like object`. If *offset* is given " "then the message will be written into the buffer from that position. Offset " "must be a non-negative integer less than the length of *buffer* (in bytes)." msgstr "" -#: ../../library/multiprocessing.rst:1301 +#: ../../library/multiprocessing.rst:1307 msgid "" "If the buffer is too short then a :exc:`BufferTooShort` exception is raised " "and the complete message is available as ``e.args[0]`` where ``e`` is the " "exception instance." msgstr "" -#: ../../library/multiprocessing.rst:1305 +#: ../../library/multiprocessing.rst:1311 msgid "" "Connection objects themselves can now be transferred between processes " "using :meth:`Connection.send` and :meth:`Connection.recv`." msgstr "" -#: ../../library/multiprocessing.rst:1309 +#: ../../library/multiprocessing.rst:1315 msgid "" "Connection objects also now support the context management protocol -- see :" "ref:`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the " "connection object, and :meth:`~contextmanager.__exit__` calls :meth:`close`." msgstr "" -#: ../../library/multiprocessing.rst:1313 +#: ../../library/multiprocessing.rst:1319 msgid "For example:" msgstr "舉例來說:" -#: ../../library/multiprocessing.rst:1315 +#: ../../library/multiprocessing.rst:1321 msgid "" ">>> from multiprocessing import Pipe\n" ">>> a, b = Pipe()\n" @@ -2015,14 +2015,14 @@ msgstr "" ">>> arr2\n" "array('i', [0, 1, 2, 3, 4, 0, 0, 0, 0, 0])" -#: ../../library/multiprocessing.rst:1338 +#: ../../library/multiprocessing.rst:1344 msgid "" "The :meth:`Connection.recv` method automatically unpickles the data it " "receives, which can be a security risk unless you can trust the process " "which sent the message." msgstr "" -#: ../../library/multiprocessing.rst:1342 +#: ../../library/multiprocessing.rst:1348 msgid "" "Therefore, unless the connection object was produced using :func:`Pipe` you " "should only use the :meth:`~Connection.recv` and :meth:`~Connection.send` " @@ -2030,73 +2030,73 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:1349 +#: ../../library/multiprocessing.rst:1355 msgid "" "If a process is killed while it is trying to read or write to a pipe then " "the data in the pipe is likely to become corrupted, because it may become " "impossible to be sure where the message boundaries lie." msgstr "" -#: ../../library/multiprocessing.rst:1355 +#: ../../library/multiprocessing.rst:1361 msgid "Synchronization primitives" msgstr "" -#: ../../library/multiprocessing.rst:1359 +#: ../../library/multiprocessing.rst:1365 msgid "" "Generally synchronization primitives are not as necessary in a multiprocess " "program as they are in a multithreaded program. See the documentation for :" "mod:`threading` module." msgstr "" -#: ../../library/multiprocessing.rst:1363 +#: ../../library/multiprocessing.rst:1369 msgid "" "Note that one can also create synchronization primitives by using a manager " "object -- see :ref:`multiprocessing-managers`." msgstr "" -#: ../../library/multiprocessing.rst:1368 +#: ../../library/multiprocessing.rst:1374 msgid "A barrier object: a clone of :class:`threading.Barrier`." msgstr "" -#: ../../library/multiprocessing.rst:1374 +#: ../../library/multiprocessing.rst:1380 msgid "" "A bounded semaphore object: a close analog of :class:`threading." "BoundedSemaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1377 -#: ../../library/multiprocessing.rst:1515 +#: ../../library/multiprocessing.rst:1383 +#: ../../library/multiprocessing.rst:1521 msgid "" "A solitary difference from its close analog exists: its ``acquire`` method's " "first argument is named *block*, as is consistent with :meth:`Lock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1381 +#: ../../library/multiprocessing.rst:1387 msgid "" "On macOS, this is indistinguishable from :class:`Semaphore` because " "``sem_getvalue()`` is not implemented on that platform." msgstr "" -#: ../../library/multiprocessing.rst:1386 +#: ../../library/multiprocessing.rst:1392 msgid "A condition variable: an alias for :class:`threading.Condition`." msgstr "" -#: ../../library/multiprocessing.rst:1388 +#: ../../library/multiprocessing.rst:1394 msgid "" "If *lock* is specified then it should be a :class:`Lock` or :class:`RLock` " "object from :mod:`multiprocessing`." msgstr "" -#: ../../library/multiprocessing.rst:1391 -#: ../../library/multiprocessing.rst:1929 +#: ../../library/multiprocessing.rst:1397 +#: ../../library/multiprocessing.rst:1935 msgid "The :meth:`~threading.Condition.wait_for` method was added." msgstr "" -#: ../../library/multiprocessing.rst:1396 +#: ../../library/multiprocessing.rst:1402 msgid "A clone of :class:`threading.Event`." msgstr "" -#: ../../library/multiprocessing.rst:1401 +#: ../../library/multiprocessing.rst:1407 msgid "" "A non-recursive lock object: a close analog of :class:`threading.Lock`. Once " "a process or thread has acquired a lock, subsequent attempts to acquire it " @@ -2107,25 +2107,25 @@ msgid "" "as noted." msgstr "" -#: ../../library/multiprocessing.rst:1409 +#: ../../library/multiprocessing.rst:1415 msgid "" "Note that :class:`Lock` is actually a factory function which returns an " "instance of ``multiprocessing.synchronize.Lock`` initialized with a default " "context." msgstr "" -#: ../../library/multiprocessing.rst:1413 +#: ../../library/multiprocessing.rst:1419 msgid "" ":class:`Lock` supports the :term:`context manager` protocol and thus may be " "used in :keyword:`with` statements." msgstr "" -#: ../../library/multiprocessing.rst:1418 -#: ../../library/multiprocessing.rst:1469 +#: ../../library/multiprocessing.rst:1424 +#: ../../library/multiprocessing.rst:1475 msgid "Acquire a lock, blocking or non-blocking." msgstr "" -#: ../../library/multiprocessing.rst:1420 +#: ../../library/multiprocessing.rst:1426 msgid "" "With the *block* argument set to ``True`` (the default), the method call " "will block until the lock is in an unlocked state, then set it to locked and " @@ -2133,14 +2133,14 @@ msgid "" "that in :meth:`threading.Lock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1425 +#: ../../library/multiprocessing.rst:1431 msgid "" "With the *block* argument set to ``False``, the method call does not block. " "If the lock is currently in a locked state, return ``False``; otherwise set " "the lock to a locked state and return ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1429 +#: ../../library/multiprocessing.rst:1435 msgid "" "When invoked with a positive, floating-point value for *timeout*, block for " "at most the number of seconds specified by *timeout* as long as the lock can " @@ -2154,19 +2154,19 @@ msgid "" "acquired or ``False`` if the timeout period has elapsed." msgstr "" -#: ../../library/multiprocessing.rst:1444 +#: ../../library/multiprocessing.rst:1450 msgid "" "Release a lock. This can be called from any process or thread, not only the " "process or thread which originally acquired the lock." msgstr "" -#: ../../library/multiprocessing.rst:1447 +#: ../../library/multiprocessing.rst:1453 msgid "" "Behavior is the same as in :meth:`threading.Lock.release` except that when " "invoked on an unlocked lock, a :exc:`ValueError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:1453 +#: ../../library/multiprocessing.rst:1459 msgid "" "A recursive lock object: a close analog of :class:`threading.RLock`. A " "recursive lock must be released by the process or thread that acquired it. " @@ -2175,20 +2175,20 @@ msgid "" "release it once for each time it has been acquired." msgstr "" -#: ../../library/multiprocessing.rst:1459 +#: ../../library/multiprocessing.rst:1465 msgid "" "Note that :class:`RLock` is actually a factory function which returns an " "instance of ``multiprocessing.synchronize.RLock`` initialized with a default " "context." msgstr "" -#: ../../library/multiprocessing.rst:1463 +#: ../../library/multiprocessing.rst:1469 msgid "" ":class:`RLock` supports the :term:`context manager` protocol and thus may be " "used in :keyword:`with` statements." msgstr "" -#: ../../library/multiprocessing.rst:1471 +#: ../../library/multiprocessing.rst:1477 msgid "" "When invoked with the *block* argument set to ``True``, block until the lock " "is in an unlocked state (not owned by any process or thread) unless the lock " @@ -2201,7 +2201,7 @@ msgid "" "itself." msgstr "" -#: ../../library/multiprocessing.rst:1481 +#: ../../library/multiprocessing.rst:1487 msgid "" "When invoked with the *block* argument set to ``False``, do not block. If " "the lock has already been acquired (and thus is owned) by another process or " @@ -2212,14 +2212,14 @@ msgid "" "a return value of ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1489 +#: ../../library/multiprocessing.rst:1495 msgid "" "Use and behaviors of the *timeout* argument are the same as in :meth:`Lock." "acquire`. Note that some of these behaviors of *timeout* differ from the " "implemented behaviors in :meth:`threading.RLock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1496 +#: ../../library/multiprocessing.rst:1502 msgid "" "Release a lock, decrementing the recursion level. If after the decrement " "the recursion level is zero, reset the lock to unlocked (not owned by any " @@ -2229,7 +2229,7 @@ msgid "" "locked and owned by the calling process or thread." msgstr "" -#: ../../library/multiprocessing.rst:1504 +#: ../../library/multiprocessing.rst:1510 msgid "" "Only call this method when the calling process or thread owns the lock. An :" "exc:`AssertionError` is raised if this method is called by a process or " @@ -2238,17 +2238,17 @@ msgid "" "from the implemented behavior in :meth:`threading.RLock.release`." msgstr "" -#: ../../library/multiprocessing.rst:1513 +#: ../../library/multiprocessing.rst:1519 msgid "A semaphore object: a close analog of :class:`threading.Semaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1520 +#: ../../library/multiprocessing.rst:1526 msgid "" "On macOS, ``sem_timedwait`` is unsupported, so calling ``acquire()`` with a " "timeout will emulate that function's behavior using a sleeping loop." msgstr "" -#: ../../library/multiprocessing.rst:1525 +#: ../../library/multiprocessing.rst:1531 msgid "" "Some of this package's functionality requires a functioning shared semaphore " "implementation on the host operating system. Without one, the :mod:" @@ -2257,32 +2257,32 @@ msgid "" "additional information." msgstr "" -#: ../../library/multiprocessing.rst:1533 +#: ../../library/multiprocessing.rst:1539 msgid "Shared :mod:`ctypes` Objects" msgstr "共享的 :mod:`ctypes` 物件" -#: ../../library/multiprocessing.rst:1535 +#: ../../library/multiprocessing.rst:1541 msgid "" "It is possible to create shared objects using shared memory which can be " "inherited by child processes." msgstr "" -#: ../../library/multiprocessing.rst:1540 +#: ../../library/multiprocessing.rst:1546 msgid "" "Return a :mod:`ctypes` object allocated from shared memory. By default the " "return value is actually a synchronized wrapper for the object. The object " "itself can be accessed via the *value* attribute of a :class:`Value`." msgstr "" -#: ../../library/multiprocessing.rst:1544 -#: ../../library/multiprocessing.rst:1631 +#: ../../library/multiprocessing.rst:1550 +#: ../../library/multiprocessing.rst:1637 msgid "" "*typecode_or_type* determines the type of the returned object: it is either " "a ctypes type or a one character typecode of the kind used by the :mod:" "`array` module. *\\*args* is passed on to the constructor for the type." msgstr "" -#: ../../library/multiprocessing.rst:1548 +#: ../../library/multiprocessing.rst:1554 msgid "" "If *lock* is ``True`` (the default) then a new recursive lock object is " "created to synchronize access to the value. If *lock* is a :class:`Lock` " @@ -2292,24 +2292,24 @@ msgid "" "\"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1555 +#: ../../library/multiprocessing.rst:1561 msgid "" "Operations like ``+=`` which involve a read and write are not atomic. So " "if, for instance, you want to atomically increment a shared value it is " "insufficient to just do ::" msgstr "" -#: ../../library/multiprocessing.rst:1559 +#: ../../library/multiprocessing.rst:1565 msgid "counter.value += 1" msgstr "counter.value += 1" -#: ../../library/multiprocessing.rst:1561 +#: ../../library/multiprocessing.rst:1567 msgid "" "Assuming the associated lock is recursive (which it is by default) you can " "instead do ::" msgstr "" -#: ../../library/multiprocessing.rst:1564 +#: ../../library/multiprocessing.rst:1570 msgid "" "with counter.get_lock():\n" " counter.value += 1" @@ -2317,19 +2317,19 @@ msgstr "" "with counter.get_lock():\n" " counter.value += 1" -#: ../../library/multiprocessing.rst:1567 -#: ../../library/multiprocessing.rst:1657 -#: ../../library/multiprocessing.rst:1672 +#: ../../library/multiprocessing.rst:1573 +#: ../../library/multiprocessing.rst:1663 +#: ../../library/multiprocessing.rst:1678 msgid "Note that *lock* is a keyword-only argument." msgstr "" -#: ../../library/multiprocessing.rst:1571 +#: ../../library/multiprocessing.rst:1577 msgid "" "Return a ctypes array allocated from shared memory. By default the return " "value is actually a synchronized wrapper for the array." msgstr "" -#: ../../library/multiprocessing.rst:1574 +#: ../../library/multiprocessing.rst:1580 msgid "" "*typecode_or_type* determines the type of the elements of the returned " "array: it is either a ctypes type or a one character typecode of the kind " @@ -2339,7 +2339,7 @@ msgid "" "initialize the array and whose length determines the length of the array." msgstr "" -#: ../../library/multiprocessing.rst:1581 +#: ../../library/multiprocessing.rst:1587 msgid "" "If *lock* is ``True`` (the default) then a new lock object is created to " "synchronize access to the value. If *lock* is a :class:`Lock` or :class:" @@ -2349,28 +2349,28 @@ msgid "" "safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1588 +#: ../../library/multiprocessing.rst:1594 msgid "Note that *lock* is a keyword only argument." msgstr "" -#: ../../library/multiprocessing.rst:1590 +#: ../../library/multiprocessing.rst:1596 msgid "" "Note that an array of :data:`ctypes.c_char` has *value* and *raw* attributes " "which allow one to use it to store and retrieve strings." msgstr "" -#: ../../library/multiprocessing.rst:1595 +#: ../../library/multiprocessing.rst:1601 msgid "The :mod:`multiprocessing.sharedctypes` module" msgstr ":mod:`multiprocessing.sharedctypes` 模組" -#: ../../library/multiprocessing.rst:1600 +#: ../../library/multiprocessing.rst:1606 msgid "" "The :mod:`multiprocessing.sharedctypes` module provides functions for " "allocating :mod:`ctypes` objects from shared memory which can be inherited " "by child processes." msgstr "" -#: ../../library/multiprocessing.rst:1606 +#: ../../library/multiprocessing.rst:1612 msgid "" "Although it is possible to store a pointer in shared memory remember that " "this will refer to a location in the address space of a specific process. " @@ -2379,11 +2379,11 @@ msgid "" "may cause a crash." msgstr "" -#: ../../library/multiprocessing.rst:1614 +#: ../../library/multiprocessing.rst:1620 msgid "Return a ctypes array allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1616 +#: ../../library/multiprocessing.rst:1622 msgid "" "*typecode_or_type* determines the type of the elements of the returned " "array: it is either a ctypes type or a one character typecode of the kind " @@ -2393,40 +2393,40 @@ msgid "" "initialize the array and whose length determines the length of the array." msgstr "" -#: ../../library/multiprocessing.rst:1623 +#: ../../library/multiprocessing.rst:1629 msgid "" "Note that setting and getting an element is potentially non-atomic -- use :" "func:`Array` instead to make sure that access is automatically synchronized " "using a lock." msgstr "" -#: ../../library/multiprocessing.rst:1629 +#: ../../library/multiprocessing.rst:1635 msgid "Return a ctypes object allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1635 +#: ../../library/multiprocessing.rst:1641 msgid "" "Note that setting and getting the value is potentially non-atomic -- use :" "func:`Value` instead to make sure that access is automatically synchronized " "using a lock." msgstr "" -#: ../../library/multiprocessing.rst:1639 +#: ../../library/multiprocessing.rst:1645 msgid "" "Note that an array of :data:`ctypes.c_char` has ``value`` and ``raw`` " "attributes which allow one to use it to store and retrieve strings -- see " "documentation for :mod:`ctypes`." msgstr "" -#: ../../library/multiprocessing.rst:1645 +#: ../../library/multiprocessing.rst:1651 msgid "" "The same as :func:`RawArray` except that depending on the value of *lock* a " "process-safe synchronization wrapper may be returned instead of a raw ctypes " "array." msgstr "" -#: ../../library/multiprocessing.rst:1649 -#: ../../library/multiprocessing.rst:1665 +#: ../../library/multiprocessing.rst:1655 +#: ../../library/multiprocessing.rst:1671 msgid "" "If *lock* is ``True`` (the default) then a new lock object is created to " "synchronize access to the value. If *lock* is a :class:`~multiprocessing." @@ -2436,113 +2436,113 @@ msgid "" "not necessarily be \"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1661 +#: ../../library/multiprocessing.rst:1667 msgid "" "The same as :func:`RawValue` except that depending on the value of *lock* a " "process-safe synchronization wrapper may be returned instead of a raw ctypes " "object." msgstr "" -#: ../../library/multiprocessing.rst:1676 +#: ../../library/multiprocessing.rst:1682 msgid "" "Return a ctypes object allocated from shared memory which is a copy of the " "ctypes object *obj*." msgstr "" -#: ../../library/multiprocessing.rst:1681 +#: ../../library/multiprocessing.rst:1687 msgid "" "Return a process-safe wrapper object for a ctypes object which uses *lock* " "to synchronize access. If *lock* is ``None`` (the default) then a :class:" "`multiprocessing.RLock` object is created automatically." msgstr "" -#: ../../library/multiprocessing.rst:1685 +#: ../../library/multiprocessing.rst:1691 msgid "" "A synchronized wrapper will have two methods in addition to those of the " "object it wraps: :meth:`get_obj` returns the wrapped object and :meth:" "`get_lock` returns the lock object used for synchronization." msgstr "" -#: ../../library/multiprocessing.rst:1689 +#: ../../library/multiprocessing.rst:1695 msgid "" "Note that accessing the ctypes object through the wrapper can be a lot " "slower than accessing the raw ctypes object." msgstr "" -#: ../../library/multiprocessing.rst:1692 +#: ../../library/multiprocessing.rst:1698 msgid "Synchronized objects support the :term:`context manager` protocol." msgstr "" -#: ../../library/multiprocessing.rst:1696 +#: ../../library/multiprocessing.rst:1702 msgid "" "The table below compares the syntax for creating shared ctypes objects from " "shared memory with the normal ctypes syntax. (In the table ``MyStruct`` is " "some subclass of :class:`ctypes.Structure`.)" msgstr "" -#: ../../library/multiprocessing.rst:1701 +#: ../../library/multiprocessing.rst:1707 msgid "ctypes" msgstr "ctypes" -#: ../../library/multiprocessing.rst:1701 +#: ../../library/multiprocessing.rst:1707 msgid "sharedctypes using type" msgstr "" -#: ../../library/multiprocessing.rst:1701 +#: ../../library/multiprocessing.rst:1707 msgid "sharedctypes using typecode" msgstr "" -#: ../../library/multiprocessing.rst:1703 +#: ../../library/multiprocessing.rst:1709 msgid "c_double(2.4)" msgstr "c_double(2.4)" -#: ../../library/multiprocessing.rst:1703 +#: ../../library/multiprocessing.rst:1709 msgid "RawValue(c_double, 2.4)" msgstr "RawValue(c_double, 2.4)" -#: ../../library/multiprocessing.rst:1703 +#: ../../library/multiprocessing.rst:1709 msgid "RawValue('d', 2.4)" msgstr "RawValue('d', 2.4)" -#: ../../library/multiprocessing.rst:1704 +#: ../../library/multiprocessing.rst:1710 msgid "MyStruct(4, 6)" msgstr "MyStruct(4, 6)" -#: ../../library/multiprocessing.rst:1704 +#: ../../library/multiprocessing.rst:1710 msgid "RawValue(MyStruct, 4, 6)" msgstr "RawValue(MyStruct, 4, 6)" -#: ../../library/multiprocessing.rst:1705 +#: ../../library/multiprocessing.rst:1711 msgid "(c_short * 7)()" msgstr "(c_short * 7)()" -#: ../../library/multiprocessing.rst:1705 +#: ../../library/multiprocessing.rst:1711 msgid "RawArray(c_short, 7)" msgstr "RawArray(c_short, 7)" -#: ../../library/multiprocessing.rst:1705 +#: ../../library/multiprocessing.rst:1711 msgid "RawArray('h', 7)" msgstr "RawArray('h', 7)" -#: ../../library/multiprocessing.rst:1706 +#: ../../library/multiprocessing.rst:1712 msgid "(c_int * 3)(9, 2, 8)" msgstr "(c_int * 3)(9, 2, 8)" -#: ../../library/multiprocessing.rst:1706 +#: ../../library/multiprocessing.rst:1712 msgid "RawArray(c_int, (9, 2, 8))" msgstr "RawArray(c_int, (9, 2, 8))" -#: ../../library/multiprocessing.rst:1706 +#: ../../library/multiprocessing.rst:1712 msgid "RawArray('i', (9, 2, 8))" msgstr "RawArray('i', (9, 2, 8))" -#: ../../library/multiprocessing.rst:1710 +#: ../../library/multiprocessing.rst:1716 msgid "" "Below is an example where a number of ctypes objects are modified by a child " "process::" msgstr "" -#: ../../library/multiprocessing.rst:1713 +#: ../../library/multiprocessing.rst:1719 msgid "" "from multiprocessing import Process, Lock\n" "from multiprocessing.sharedctypes import Value, Array\n" @@ -2608,11 +2608,11 @@ msgstr "" " print(s.value)\n" " print([(a.x, a.y) for a in A])" -#: ../../library/multiprocessing.rst:1748 +#: ../../library/multiprocessing.rst:1754 msgid "The results printed are ::" msgstr "" -#: ../../library/multiprocessing.rst:1750 +#: ../../library/multiprocessing.rst:1756 msgid "" "49\n" "0.1111111111111111\n" @@ -2624,11 +2624,11 @@ msgstr "" "HELLO WORLD\n" "[(3.515625, 39.0625), (33.0625, 4.0), (5.640625, 90.25)]" -#: ../../library/multiprocessing.rst:1761 +#: ../../library/multiprocessing.rst:1767 msgid "Managers" msgstr "" -#: ../../library/multiprocessing.rst:1763 +#: ../../library/multiprocessing.rst:1769 msgid "" "Managers provide a way to create data which can be shared between different " "processes, including sharing over a network between processes running on " @@ -2637,7 +2637,7 @@ msgid "" "proxies." msgstr "" -#: ../../library/multiprocessing.rst:1772 +#: ../../library/multiprocessing.rst:1778 msgid "" "Returns a started :class:`~multiprocessing.managers.SyncManager` object " "which can be used for sharing objects between processes. The returned " @@ -2645,31 +2645,31 @@ msgid "" "will create shared objects and return corresponding proxies." msgstr "" -#: ../../library/multiprocessing.rst:1780 +#: ../../library/multiprocessing.rst:1786 msgid "" "Manager processes will be shutdown as soon as they are garbage collected or " "their parent process exits. The manager classes are defined in the :mod:" "`multiprocessing.managers` module:" msgstr "" -#: ../../library/multiprocessing.rst:1786 +#: ../../library/multiprocessing.rst:1792 msgid "Create a BaseManager object." msgstr "建立一個 BaseManager 物件。" -#: ../../library/multiprocessing.rst:1788 +#: ../../library/multiprocessing.rst:1794 msgid "" "Once created one should call :meth:`start` or ``get_server()." "serve_forever()`` to ensure that the manager object refers to a started " "manager process." msgstr "" -#: ../../library/multiprocessing.rst:1791 +#: ../../library/multiprocessing.rst:1797 msgid "" "*address* is the address on which the manager process listens for new " "connections. If *address* is ``None`` then an arbitrary one is chosen." msgstr "" -#: ../../library/multiprocessing.rst:1794 +#: ../../library/multiprocessing.rst:1800 msgid "" "*authkey* is the authentication key which will be used to check the validity " "of incoming connections to the server process. If *authkey* is ``None`` " @@ -2677,19 +2677,19 @@ msgid "" "it must be a byte string." msgstr "" -#: ../../library/multiprocessing.rst:1799 +#: ../../library/multiprocessing.rst:1805 msgid "" "*serializer* must be ``'pickle'`` (use :mod:`pickle` serialization) or " "``'xmlrpclib'`` (use :mod:`xmlrpc.client` serialization)." msgstr "" -#: ../../library/multiprocessing.rst:1802 +#: ../../library/multiprocessing.rst:1808 msgid "" "*ctx* is a context object, or ``None`` (use the current context). See the :" "func:`get_context` function." msgstr "" -#: ../../library/multiprocessing.rst:1805 +#: ../../library/multiprocessing.rst:1811 msgid "" "*shutdown_timeout* is a timeout in seconds used to wait until the process " "used by the manager completes in the :meth:`shutdown` method. If the " @@ -2697,24 +2697,24 @@ msgid "" "also times out, the process is killed." msgstr "" -#: ../../library/multiprocessing.rst:1810 +#: ../../library/multiprocessing.rst:1816 msgid "Added the *shutdown_timeout* parameter." msgstr "新增 *shutdown_timeout* 參數。" -#: ../../library/multiprocessing.rst:1815 +#: ../../library/multiprocessing.rst:1821 msgid "" "Start a subprocess to start the manager. If *initializer* is not ``None`` " "then the subprocess will call ``initializer(*initargs)`` when it starts." msgstr "" -#: ../../library/multiprocessing.rst:1820 +#: ../../library/multiprocessing.rst:1826 msgid "" "Returns a :class:`Server` object which represents the actual server under " "the control of the Manager. The :class:`Server` object supports the :meth:" "`serve_forever` method::" msgstr "" -#: ../../library/multiprocessing.rst:1824 +#: ../../library/multiprocessing.rst:1830 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> manager = BaseManager(address=('', 50000), authkey=b'abc')\n" @@ -2726,15 +2726,15 @@ msgstr "" ">>> server = manager.get_server()\n" ">>> server.serve_forever()" -#: ../../library/multiprocessing.rst:1829 +#: ../../library/multiprocessing.rst:1835 msgid ":class:`Server` additionally has an :attr:`address` attribute." msgstr "" -#: ../../library/multiprocessing.rst:1833 +#: ../../library/multiprocessing.rst:1839 msgid "Connect a local manager object to a remote manager process::" msgstr "" -#: ../../library/multiprocessing.rst:1835 +#: ../../library/multiprocessing.rst:1841 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" @@ -2744,29 +2744,29 @@ msgstr "" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" ">>> m.connect()" -#: ../../library/multiprocessing.rst:1841 +#: ../../library/multiprocessing.rst:1847 msgid "" "Stop the process used by the manager. This is only available if :meth:" "`start` has been used to start the server process." msgstr "" -#: ../../library/multiprocessing.rst:1844 +#: ../../library/multiprocessing.rst:1850 msgid "This can be called multiple times." msgstr "" -#: ../../library/multiprocessing.rst:1848 +#: ../../library/multiprocessing.rst:1854 msgid "" "A classmethod which can be used for registering a type or callable with the " "manager class." msgstr "" -#: ../../library/multiprocessing.rst:1851 +#: ../../library/multiprocessing.rst:1857 msgid "" "*typeid* is a \"type identifier\" which is used to identify a particular " "type of shared object. This must be a string." msgstr "" -#: ../../library/multiprocessing.rst:1854 +#: ../../library/multiprocessing.rst:1860 msgid "" "*callable* is a callable used for creating objects for this type " "identifier. If a manager instance will be connected to the server using " @@ -2774,14 +2774,14 @@ msgid "" "then this can be left as ``None``." msgstr "" -#: ../../library/multiprocessing.rst:1860 +#: ../../library/multiprocessing.rst:1866 msgid "" "*proxytype* is a subclass of :class:`BaseProxy` which is used to create " "proxies for shared objects with this *typeid*. If ``None`` then a proxy " "class is created automatically." msgstr "" -#: ../../library/multiprocessing.rst:1864 +#: ../../library/multiprocessing.rst:1870 msgid "" "*exposed* is used to specify a sequence of method names which proxies for " "this typeid should be allowed to access using :meth:`BaseProxy." @@ -2792,7 +2792,7 @@ msgid "" "method and whose name does not begin with ``'_'``.)" msgstr "" -#: ../../library/multiprocessing.rst:1873 +#: ../../library/multiprocessing.rst:1879 msgid "" "*method_to_typeid* is a mapping used to specify the return type of those " "exposed methods which should return a proxy. It maps method names to typeid " @@ -2802,22 +2802,22 @@ msgid "" "returned by the method will be copied by value." msgstr "" -#: ../../library/multiprocessing.rst:1880 +#: ../../library/multiprocessing.rst:1886 msgid "" "*create_method* determines whether a method should be created with name " "*typeid* which can be used to tell the server process to create a new shared " "object and return a proxy for it. By default it is ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1884 +#: ../../library/multiprocessing.rst:1890 msgid ":class:`BaseManager` instances also have one read-only property:" msgstr "" -#: ../../library/multiprocessing.rst:1888 +#: ../../library/multiprocessing.rst:1894 msgid "The address used by the manager." msgstr "" -#: ../../library/multiprocessing.rst:1890 +#: ../../library/multiprocessing.rst:1896 msgid "" "Manager objects support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` starts the server " @@ -2825,121 +2825,121 @@ msgid "" "object. :meth:`~contextmanager.__exit__` calls :meth:`shutdown`." msgstr "" -#: ../../library/multiprocessing.rst:1896 +#: ../../library/multiprocessing.rst:1902 msgid "" "In previous versions :meth:`~contextmanager.__enter__` did not start the " "manager's server process if it was not already started." msgstr "" -#: ../../library/multiprocessing.rst:1901 +#: ../../library/multiprocessing.rst:1907 msgid "" "A subclass of :class:`BaseManager` which can be used for the synchronization " "of processes. Objects of this type are returned by :func:`multiprocessing." "Manager`." msgstr "" -#: ../../library/multiprocessing.rst:1905 +#: ../../library/multiprocessing.rst:1911 msgid "" "Its methods create and return :ref:`multiprocessing-proxy_objects` for a " "number of commonly used data types to be synchronized across processes. This " "notably includes shared lists and dictionaries." msgstr "" -#: ../../library/multiprocessing.rst:1911 +#: ../../library/multiprocessing.rst:1917 msgid "" "Create a shared :class:`threading.Barrier` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1918 +#: ../../library/multiprocessing.rst:1924 msgid "" "Create a shared :class:`threading.BoundedSemaphore` object and return a " "proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1923 +#: ../../library/multiprocessing.rst:1929 msgid "" "Create a shared :class:`threading.Condition` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1926 +#: ../../library/multiprocessing.rst:1932 msgid "" "If *lock* is supplied then it should be a proxy for a :class:`threading." "Lock` or :class:`threading.RLock` object." msgstr "" -#: ../../library/multiprocessing.rst:1934 +#: ../../library/multiprocessing.rst:1940 msgid "" "Create a shared :class:`threading.Event` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1938 +#: ../../library/multiprocessing.rst:1944 msgid "" "Create a shared :class:`threading.Lock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1942 +#: ../../library/multiprocessing.rst:1948 msgid "Create a shared :class:`Namespace` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1946 +#: ../../library/multiprocessing.rst:1952 msgid "Create a shared :class:`queue.Queue` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1950 +#: ../../library/multiprocessing.rst:1956 msgid "" "Create a shared :class:`threading.RLock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1954 +#: ../../library/multiprocessing.rst:1960 msgid "" "Create a shared :class:`threading.Semaphore` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1959 +#: ../../library/multiprocessing.rst:1965 msgid "Create an array and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1963 +#: ../../library/multiprocessing.rst:1969 msgid "" "Create an object with a writable ``value`` attribute and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1970 +#: ../../library/multiprocessing.rst:1976 msgid "Create a shared :class:`dict` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1975 +#: ../../library/multiprocessing.rst:1981 msgid "Create a shared :class:`list` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1977 +#: ../../library/multiprocessing.rst:1983 msgid "" "Shared objects are capable of being nested. For example, a shared container " "object such as a shared list can contain other shared objects which will all " "be managed and synchronized by the :class:`SyncManager`." msgstr "" -#: ../../library/multiprocessing.rst:1984 +#: ../../library/multiprocessing.rst:1990 msgid "A type that can register with :class:`SyncManager`." msgstr "" -#: ../../library/multiprocessing.rst:1986 +#: ../../library/multiprocessing.rst:1992 msgid "" "A namespace object has no public methods, but does have writable attributes. " "Its representation shows the values of its attributes." msgstr "" -#: ../../library/multiprocessing.rst:1989 +#: ../../library/multiprocessing.rst:1995 msgid "" "However, when using a proxy for a namespace object, an attribute beginning " "with ``'_'`` will be an attribute of the proxy and not an attribute of the " "referent:" msgstr "" -#: ../../library/multiprocessing.rst:1993 +#: ../../library/multiprocessing.rst:1999 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -2951,18 +2951,18 @@ msgid "" "Namespace(x=10, y='hello')" msgstr "" -#: ../../library/multiprocessing.rst:2006 +#: ../../library/multiprocessing.rst:2012 msgid "Customized managers" msgstr "" -#: ../../library/multiprocessing.rst:2008 +#: ../../library/multiprocessing.rst:2014 msgid "" "To create one's own manager, one creates a subclass of :class:`BaseManager` " "and uses the :meth:`~BaseManager.register` classmethod to register new types " "or callables with the manager class. For example::" msgstr "" -#: ../../library/multiprocessing.rst:2012 +#: ../../library/multiprocessing.rst:2018 msgid "" "from multiprocessing.managers import BaseManager\n" "\n" @@ -3002,23 +3002,23 @@ msgstr "" " print(maths.add(4, 3)) # 印出 7\n" " print(maths.mul(7, 8)) # 印出 56" -#: ../../library/multiprocessing.rst:2033 +#: ../../library/multiprocessing.rst:2039 msgid "Using a remote manager" msgstr "" -#: ../../library/multiprocessing.rst:2035 +#: ../../library/multiprocessing.rst:2041 msgid "" "It is possible to run a manager server on one machine and have clients use " "it from other machines (assuming that the firewalls involved allow it)." msgstr "" -#: ../../library/multiprocessing.rst:2038 +#: ../../library/multiprocessing.rst:2044 msgid "" "Running the following commands creates a server for a single shared queue " "which remote clients can access::" msgstr "" -#: ../../library/multiprocessing.rst:2041 +#: ../../library/multiprocessing.rst:2047 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> from queue import Queue\n" @@ -3038,11 +3038,11 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2050 +#: ../../library/multiprocessing.rst:2056 msgid "One client can access the server as follows::" msgstr "" -#: ../../library/multiprocessing.rst:2052 +#: ../../library/multiprocessing.rst:2058 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -3062,11 +3062,11 @@ msgstr "" ">>> queue = m.get_queue()\n" ">>> queue.put('hello')" -#: ../../library/multiprocessing.rst:2060 +#: ../../library/multiprocessing.rst:2066 msgid "Another client can also use it::" msgstr "" -#: ../../library/multiprocessing.rst:2062 +#: ../../library/multiprocessing.rst:2068 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -3088,13 +3088,13 @@ msgstr "" ">>> queue.get()\n" "'hello'" -#: ../../library/multiprocessing.rst:2071 +#: ../../library/multiprocessing.rst:2077 msgid "" "Local processes can also access that queue, using the code from above on the " "client to access it remotely::" msgstr "" -#: ../../library/multiprocessing.rst:2074 +#: ../../library/multiprocessing.rst:2080 msgid "" ">>> from multiprocessing import Process, Queue\n" ">>> from multiprocessing.managers import BaseManager\n" @@ -3134,18 +3134,18 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2096 +#: ../../library/multiprocessing.rst:2102 msgid "Proxy Objects" msgstr "" -#: ../../library/multiprocessing.rst:2098 +#: ../../library/multiprocessing.rst:2104 msgid "" "A proxy is an object which *refers* to a shared object which lives " "(presumably) in a different process. The shared object is said to be the " "*referent* of the proxy. Multiple proxy objects may have the same referent." msgstr "" -#: ../../library/multiprocessing.rst:2102 +#: ../../library/multiprocessing.rst:2108 msgid "" "A proxy object has methods which invoke corresponding methods of its " "referent (although not every method of the referent will necessarily be " @@ -3153,7 +3153,7 @@ msgid "" "its referent can:" msgstr "" -#: ../../library/multiprocessing.rst:2106 +#: ../../library/multiprocessing.rst:2112 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -3179,14 +3179,14 @@ msgstr "" ">>> l[2:5]\n" "[4, 9, 16]" -#: ../../library/multiprocessing.rst:2120 +#: ../../library/multiprocessing.rst:2126 msgid "" "Notice that applying :func:`str` to a proxy will return the representation " "of the referent, whereas applying :func:`repr` will return the " "representation of the proxy." msgstr "" -#: ../../library/multiprocessing.rst:2124 +#: ../../library/multiprocessing.rst:2130 msgid "" "An important feature of proxy objects is that they are picklable so they can " "be passed between processes. As such, a referent can contain :ref:" @@ -3194,7 +3194,7 @@ msgid "" "lists, dicts, and other :ref:`multiprocessing-proxy_objects`:" msgstr "" -#: ../../library/multiprocessing.rst:2129 +#: ../../library/multiprocessing.rst:2135 msgid "" ">>> a = manager.list()\n" ">>> b = manager.list()\n" @@ -3206,11 +3206,11 @@ msgid "" "['hello'] ['hello']" msgstr "" -#: ../../library/multiprocessing.rst:2140 +#: ../../library/multiprocessing.rst:2146 msgid "Similarly, dict and list proxies may be nested inside one another::" msgstr "" -#: ../../library/multiprocessing.rst:2142 +#: ../../library/multiprocessing.rst:2148 msgid "" ">>> l_outer = manager.list([ manager.dict() for i in range(2) ])\n" ">>> d_first_inner = l_outer[0]\n" @@ -3234,7 +3234,7 @@ msgstr "" ">>> print(l_outer[1])\n" "{'c': 3, 'z': 26}" -#: ../../library/multiprocessing.rst:2153 +#: ../../library/multiprocessing.rst:2159 msgid "" "If standard (non-proxy) :class:`list` or :class:`dict` objects are contained " "in a referent, modifications to those mutable values will not be propagated " @@ -3245,7 +3245,7 @@ msgid "" "assign the modified value to the container proxy::" msgstr "" -#: ../../library/multiprocessing.rst:2161 +#: ../../library/multiprocessing.rst:2167 msgid "" "# create a list proxy and append a mutable object (a dictionary)\n" "lproxy = manager.list()\n" @@ -3259,20 +3259,20 @@ msgid "" "lproxy[0] = d" msgstr "" -#: ../../library/multiprocessing.rst:2172 +#: ../../library/multiprocessing.rst:2178 msgid "" "This approach is perhaps less convenient than employing nested :ref:" "`multiprocessing-proxy_objects` for most use cases but also demonstrates a " "level of control over the synchronization." msgstr "" -#: ../../library/multiprocessing.rst:2178 +#: ../../library/multiprocessing.rst:2184 msgid "" "The proxy types in :mod:`multiprocessing` do nothing to support comparisons " "by value. So, for instance, we have:" msgstr "" -#: ../../library/multiprocessing.rst:2181 +#: ../../library/multiprocessing.rst:2187 msgid "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" @@ -3280,48 +3280,48 @@ msgstr "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" -#: ../../library/multiprocessing.rst:2186 +#: ../../library/multiprocessing.rst:2192 msgid "" "One should just use a copy of the referent instead when making comparisons." msgstr "" -#: ../../library/multiprocessing.rst:2190 +#: ../../library/multiprocessing.rst:2196 msgid "Proxy objects are instances of subclasses of :class:`BaseProxy`." msgstr "" -#: ../../library/multiprocessing.rst:2194 +#: ../../library/multiprocessing.rst:2200 msgid "Call and return the result of a method of the proxy's referent." msgstr "" -#: ../../library/multiprocessing.rst:2196 +#: ../../library/multiprocessing.rst:2202 msgid "" "If ``proxy`` is a proxy whose referent is ``obj`` then the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2198 +#: ../../library/multiprocessing.rst:2204 msgid "proxy._callmethod(methodname, args, kwds)" msgstr "proxy._callmethod(methodname, args, kwds)" -#: ../../library/multiprocessing.rst:2200 +#: ../../library/multiprocessing.rst:2206 msgid "will evaluate the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2202 +#: ../../library/multiprocessing.rst:2208 msgid "getattr(obj, methodname)(*args, **kwds)" msgstr "getattr(obj, methodname)(*args, **kwds)" -#: ../../library/multiprocessing.rst:2204 +#: ../../library/multiprocessing.rst:2210 msgid "in the manager's process." msgstr "" -#: ../../library/multiprocessing.rst:2206 +#: ../../library/multiprocessing.rst:2212 msgid "" "The returned value will be a copy of the result of the call or a proxy to a " "new shared object -- see documentation for the *method_to_typeid* argument " "of :meth:`BaseManager.register`." msgstr "" -#: ../../library/multiprocessing.rst:2210 +#: ../../library/multiprocessing.rst:2216 msgid "" "If an exception is raised by the call, then is re-raised by :meth:" "`_callmethod`. If some other exception is raised in the manager's process " @@ -3329,17 +3329,17 @@ msgid "" "meth:`_callmethod`." msgstr "" -#: ../../library/multiprocessing.rst:2215 +#: ../../library/multiprocessing.rst:2221 msgid "" "Note in particular that an exception will be raised if *methodname* has not " "been *exposed*." msgstr "" -#: ../../library/multiprocessing.rst:2218 +#: ../../library/multiprocessing.rst:2224 msgid "An example of the usage of :meth:`_callmethod`:" msgstr "" -#: ../../library/multiprocessing.rst:2220 +#: ../../library/multiprocessing.rst:2226 msgid "" ">>> l = manager.list(range(10))\n" ">>> l._callmethod('__len__')\n" @@ -3361,69 +3361,69 @@ msgstr "" "...\n" "IndexError: list index out of range" -#: ../../library/multiprocessing.rst:2234 +#: ../../library/multiprocessing.rst:2240 msgid "Return a copy of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2236 +#: ../../library/multiprocessing.rst:2242 msgid "If the referent is unpicklable then this will raise an exception." msgstr "" -#: ../../library/multiprocessing.rst:2240 +#: ../../library/multiprocessing.rst:2246 msgid "Return a representation of the proxy object." msgstr "" -#: ../../library/multiprocessing.rst:2244 +#: ../../library/multiprocessing.rst:2250 msgid "Return the representation of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2248 +#: ../../library/multiprocessing.rst:2254 msgid "Cleanup" msgstr "" -#: ../../library/multiprocessing.rst:2250 +#: ../../library/multiprocessing.rst:2256 msgid "" "A proxy object uses a weakref callback so that when it gets garbage " "collected it deregisters itself from the manager which owns its referent." msgstr "" -#: ../../library/multiprocessing.rst:2253 +#: ../../library/multiprocessing.rst:2259 msgid "" "A shared object gets deleted from the manager process when there are no " "longer any proxies referring to it." msgstr "" -#: ../../library/multiprocessing.rst:2258 +#: ../../library/multiprocessing.rst:2264 msgid "Process Pools" msgstr "" -#: ../../library/multiprocessing.rst:2263 +#: ../../library/multiprocessing.rst:2269 msgid "" "One can create a pool of processes which will carry out tasks submitted to " "it with the :class:`Pool` class." msgstr "" -#: ../../library/multiprocessing.rst:2268 +#: ../../library/multiprocessing.rst:2274 msgid "" "A process pool object which controls a pool of worker processes to which " "jobs can be submitted. It supports asynchronous results with timeouts and " "callbacks and has a parallel map implementation." msgstr "" -#: ../../library/multiprocessing.rst:2272 +#: ../../library/multiprocessing.rst:2278 msgid "" "*processes* is the number of worker processes to use. If *processes* is " "``None`` then the number returned by :func:`os.process_cpu_count` is used." msgstr "" -#: ../../library/multiprocessing.rst:2275 -#: ../../library/multiprocessing.rst:2839 +#: ../../library/multiprocessing.rst:2281 +#: ../../library/multiprocessing.rst:2845 msgid "" "If *initializer* is not ``None`` then each worker process will call " "``initializer(*initargs)`` when it starts." msgstr "" -#: ../../library/multiprocessing.rst:2278 +#: ../../library/multiprocessing.rst:2284 msgid "" "*maxtasksperchild* is the number of tasks a worker process can complete " "before it will exit and be replaced with a fresh worker process, to enable " @@ -3431,7 +3431,7 @@ msgid "" "which means worker processes will live as long as the pool." msgstr "" -#: ../../library/multiprocessing.rst:2283 +#: ../../library/multiprocessing.rst:2289 msgid "" "*context* can be used to specify the context used for starting the worker " "processes. Usually a pool is created using the function :func:" @@ -3439,13 +3439,13 @@ msgid "" "both cases *context* is set appropriately." msgstr "" -#: ../../library/multiprocessing.rst:2289 +#: ../../library/multiprocessing.rst:2295 msgid "" "Note that the methods of the pool object should only be called by the " "process which created the pool." msgstr "" -#: ../../library/multiprocessing.rst:2293 +#: ../../library/multiprocessing.rst:2299 msgid "" ":class:`multiprocessing.pool` objects have internal resources that need to " "be properly managed (like any other resource) by using the pool as a context " @@ -3453,28 +3453,28 @@ msgid "" "to do this can lead to the process hanging on finalization." msgstr "" -#: ../../library/multiprocessing.rst:2298 +#: ../../library/multiprocessing.rst:2304 msgid "" "Note that it is **not correct** to rely on the garbage collector to destroy " "the pool as CPython does not assure that the finalizer of the pool will be " "called (see :meth:`object.__del__` for more information)." msgstr "" -#: ../../library/multiprocessing.rst:2302 +#: ../../library/multiprocessing.rst:2308 msgid "Added the *maxtasksperchild* parameter." msgstr "新增 *maxtasksperchild* 參數。" -#: ../../library/multiprocessing.rst:2305 +#: ../../library/multiprocessing.rst:2311 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" -#: ../../library/multiprocessing.rst:2308 +#: ../../library/multiprocessing.rst:2314 msgid "" "*processes* uses :func:`os.process_cpu_count` by default, instead of :func:" "`os.cpu_count`." msgstr "" -#: ../../library/multiprocessing.rst:2314 +#: ../../library/multiprocessing.rst:2320 msgid "" "Worker processes within a :class:`Pool` typically live for the complete " "duration of the Pool's work queue. A frequent pattern found in other systems " @@ -3485,7 +3485,7 @@ msgid "" "ability to the end user." msgstr "" -#: ../../library/multiprocessing.rst:2324 +#: ../../library/multiprocessing.rst:2330 msgid "" "Call *func* with arguments *args* and keyword arguments *kwds*. It blocks " "until the result is ready. Given this blocks, :meth:`apply_async` is better " @@ -3493,14 +3493,14 @@ msgid "" "executed in one of the workers of the pool." msgstr "" -#: ../../library/multiprocessing.rst:2331 +#: ../../library/multiprocessing.rst:2337 msgid "" "A variant of the :meth:`apply` method which returns a :class:" "`~multiprocessing.pool.AsyncResult` object." msgstr "" -#: ../../library/multiprocessing.rst:2334 -#: ../../library/multiprocessing.rst:2365 +#: ../../library/multiprocessing.rst:2340 +#: ../../library/multiprocessing.rst:2371 msgid "" "If *callback* is specified then it should be a callable which accepts a " "single argument. When the result becomes ready *callback* is applied to it, " @@ -3508,60 +3508,60 @@ msgid "" "applied instead." msgstr "" -#: ../../library/multiprocessing.rst:2339 -#: ../../library/multiprocessing.rst:2370 +#: ../../library/multiprocessing.rst:2345 +#: ../../library/multiprocessing.rst:2376 msgid "" "If *error_callback* is specified then it should be a callable which accepts " "a single argument. If the target function fails, then the *error_callback* " "is called with the exception instance." msgstr "" -#: ../../library/multiprocessing.rst:2343 -#: ../../library/multiprocessing.rst:2374 +#: ../../library/multiprocessing.rst:2349 +#: ../../library/multiprocessing.rst:2380 msgid "" "Callbacks should complete immediately since otherwise the thread which " "handles the results will get blocked." msgstr "" -#: ../../library/multiprocessing.rst:2348 +#: ../../library/multiprocessing.rst:2354 msgid "" "A parallel equivalent of the :func:`map` built-in function (it supports only " "one *iterable* argument though, for multiple iterables see :meth:`starmap`). " "It blocks until the result is ready." msgstr "" -#: ../../library/multiprocessing.rst:2352 +#: ../../library/multiprocessing.rst:2358 msgid "" "This method chops the iterable into a number of chunks which it submits to " "the process pool as separate tasks. The (approximate) size of these chunks " "can be specified by setting *chunksize* to a positive integer." msgstr "" -#: ../../library/multiprocessing.rst:2356 +#: ../../library/multiprocessing.rst:2362 msgid "" "Note that it may cause high memory usage for very long iterables. Consider " "using :meth:`imap` or :meth:`imap_unordered` with explicit *chunksize* " "option for better efficiency." msgstr "" -#: ../../library/multiprocessing.rst:2362 +#: ../../library/multiprocessing.rst:2368 msgid "" "A variant of the :meth:`.map` method which returns a :class:" "`~multiprocessing.pool.AsyncResult` object." msgstr "" -#: ../../library/multiprocessing.rst:2379 +#: ../../library/multiprocessing.rst:2385 msgid "A lazier version of :meth:`.map`." msgstr "" -#: ../../library/multiprocessing.rst:2381 +#: ../../library/multiprocessing.rst:2387 msgid "" "The *chunksize* argument is the same as the one used by the :meth:`.map` " "method. For very long iterables using a large value for *chunksize* can " "make the job complete **much** faster than using the default value of ``1``." msgstr "" -#: ../../library/multiprocessing.rst:2386 +#: ../../library/multiprocessing.rst:2392 msgid "" "Also if *chunksize* is ``1`` then the :meth:`!next` method of the iterator " "returned by the :meth:`imap` method has an optional *timeout* parameter: " @@ -3569,65 +3569,65 @@ msgid "" "result cannot be returned within *timeout* seconds." msgstr "" -#: ../../library/multiprocessing.rst:2393 +#: ../../library/multiprocessing.rst:2399 msgid "" "The same as :meth:`imap` except that the ordering of the results from the " "returned iterator should be considered arbitrary. (Only when there is only " "one worker process is the order guaranteed to be \"correct\".)" msgstr "" -#: ../../library/multiprocessing.rst:2399 +#: ../../library/multiprocessing.rst:2405 msgid "" "Like :meth:`~multiprocessing.pool.Pool.map` except that the elements of the " "*iterable* are expected to be iterables that are unpacked as arguments." msgstr "" -#: ../../library/multiprocessing.rst:2403 +#: ../../library/multiprocessing.rst:2409 msgid "" "Hence an *iterable* of ``[(1,2), (3, 4)]`` results in ``[func(1,2), " "func(3,4)]``." msgstr "" -#: ../../library/multiprocessing.rst:2410 +#: ../../library/multiprocessing.rst:2416 msgid "" "A combination of :meth:`starmap` and :meth:`map_async` that iterates over " "*iterable* of iterables and calls *func* with the iterables unpacked. " "Returns a result object." msgstr "" -#: ../../library/multiprocessing.rst:2418 +#: ../../library/multiprocessing.rst:2424 msgid "" "Prevents any more tasks from being submitted to the pool. Once all the " "tasks have been completed the worker processes will exit." msgstr "" -#: ../../library/multiprocessing.rst:2423 +#: ../../library/multiprocessing.rst:2429 msgid "" "Stops the worker processes immediately without completing outstanding work. " "When the pool object is garbage collected :meth:`terminate` will be called " "immediately." msgstr "" -#: ../../library/multiprocessing.rst:2429 +#: ../../library/multiprocessing.rst:2435 msgid "" "Wait for the worker processes to exit. One must call :meth:`close` or :meth:" "`terminate` before using :meth:`join`." msgstr "" -#: ../../library/multiprocessing.rst:2432 +#: ../../library/multiprocessing.rst:2438 msgid "" "Pool objects now support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the pool " "object, and :meth:`~contextmanager.__exit__` calls :meth:`terminate`." msgstr "" -#: ../../library/multiprocessing.rst:2440 +#: ../../library/multiprocessing.rst:2446 msgid "" "The class of the result returned by :meth:`Pool.apply_async` and :meth:`Pool." "map_async`." msgstr "" -#: ../../library/multiprocessing.rst:2445 +#: ../../library/multiprocessing.rst:2451 msgid "" "Return the result when it arrives. If *timeout* is not ``None`` and the " "result does not arrive within *timeout* seconds then :exc:`multiprocessing." @@ -3635,31 +3635,31 @@ msgid "" "exception will be reraised by :meth:`get`." msgstr "" -#: ../../library/multiprocessing.rst:2452 +#: ../../library/multiprocessing.rst:2458 msgid "Wait until the result is available or until *timeout* seconds pass." msgstr "" -#: ../../library/multiprocessing.rst:2456 +#: ../../library/multiprocessing.rst:2462 msgid "Return whether the call has completed." msgstr "" -#: ../../library/multiprocessing.rst:2460 +#: ../../library/multiprocessing.rst:2466 msgid "" "Return whether the call completed without raising an exception. Will raise :" "exc:`ValueError` if the result is not ready." msgstr "" -#: ../../library/multiprocessing.rst:2463 +#: ../../library/multiprocessing.rst:2469 msgid "" "If the result is not ready, :exc:`ValueError` is raised instead of :exc:" "`AssertionError`." msgstr "" -#: ../../library/multiprocessing.rst:2467 +#: ../../library/multiprocessing.rst:2473 msgid "The following example demonstrates the use of a pool::" msgstr "" -#: ../../library/multiprocessing.rst:2469 +#: ../../library/multiprocessing.rst:2475 msgid "" "from multiprocessing import Pool\n" "import time\n" @@ -3687,17 +3687,17 @@ msgid "" "TimeoutError" msgstr "" -#: ../../library/multiprocessing.rst:2494 +#: ../../library/multiprocessing.rst:2500 msgid "Listeners and Clients" msgstr "" -#: ../../library/multiprocessing.rst:2499 +#: ../../library/multiprocessing.rst:2505 msgid "" "Usually message passing between processes is done using queues or by using :" "class:`~Connection` objects returned by :func:`~multiprocessing.Pipe`." msgstr "" -#: ../../library/multiprocessing.rst:2503 +#: ../../library/multiprocessing.rst:2509 msgid "" "However, the :mod:`multiprocessing.connection` module allows some extra " "flexibility. It basically gives a high level message oriented API for " @@ -3706,46 +3706,46 @@ msgid "" "multiple connections at the same time." msgstr "" -#: ../../library/multiprocessing.rst:2512 +#: ../../library/multiprocessing.rst:2518 msgid "" "Send a randomly generated message to the other end of the connection and " "wait for a reply." msgstr "" -#: ../../library/multiprocessing.rst:2515 +#: ../../library/multiprocessing.rst:2521 msgid "" "If the reply matches the digest of the message using *authkey* as the key " "then a welcome message is sent to the other end of the connection. " "Otherwise :exc:`~multiprocessing.AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2521 +#: ../../library/multiprocessing.rst:2527 msgid "" "Receive a message, calculate the digest of the message using *authkey* as " "the key, and then send the digest back." msgstr "" -#: ../../library/multiprocessing.rst:2524 +#: ../../library/multiprocessing.rst:2530 msgid "" "If a welcome message is not received, then :exc:`~multiprocessing." "AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2529 +#: ../../library/multiprocessing.rst:2535 msgid "" "Attempt to set up a connection to the listener which is using address " "*address*, returning a :class:`~Connection`." msgstr "" -#: ../../library/multiprocessing.rst:2532 +#: ../../library/multiprocessing.rst:2538 msgid "" "The type of the connection is determined by *family* argument, but this can " "generally be omitted since it can usually be inferred from the format of " "*address*. (See :ref:`multiprocessing-address-formats`)" msgstr "" -#: ../../library/multiprocessing.rst:2536 -#: ../../library/multiprocessing.rst:2571 +#: ../../library/multiprocessing.rst:2542 +#: ../../library/multiprocessing.rst:2577 msgid "" "If *authkey* is given and not ``None``, it should be a byte string and will " "be used as the secret key for an HMAC-based authentication challenge. No " @@ -3754,26 +3754,26 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:2544 +#: ../../library/multiprocessing.rst:2550 msgid "" "A wrapper for a bound socket or Windows named pipe which is 'listening' for " "connections." msgstr "" -#: ../../library/multiprocessing.rst:2547 +#: ../../library/multiprocessing.rst:2553 msgid "" "*address* is the address to be used by the bound socket or named pipe of the " "listener object." msgstr "" -#: ../../library/multiprocessing.rst:2552 +#: ../../library/multiprocessing.rst:2558 msgid "" "If an address of '0.0.0.0' is used, the address will not be a connectable " "end point on Windows. If you require a connectable end-point, you should use " "'127.0.0.1'." msgstr "" -#: ../../library/multiprocessing.rst:2556 +#: ../../library/multiprocessing.rst:2562 msgid "" "*family* is the type of socket (or named pipe) to use. This can be one of " "the strings ``'AF_INET'`` (for a TCP socket), ``'AF_UNIX'`` (for a Unix " @@ -3787,49 +3787,49 @@ msgid "" "using :func:`tempfile.mkstemp`." msgstr "" -#: ../../library/multiprocessing.rst:2567 +#: ../../library/multiprocessing.rst:2573 msgid "" "If the listener object uses a socket then *backlog* (1 by default) is passed " "to the :meth:`~socket.socket.listen` method of the socket once it has been " "bound." msgstr "" -#: ../../library/multiprocessing.rst:2579 +#: ../../library/multiprocessing.rst:2585 msgid "" "Accept a connection on the bound socket or named pipe of the listener object " "and return a :class:`~Connection` object. If authentication is attempted and " "fails, then :exc:`~multiprocessing.AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2586 +#: ../../library/multiprocessing.rst:2592 msgid "" "Close the bound socket or named pipe of the listener object. This is called " "automatically when the listener is garbage collected. However it is " "advisable to call it explicitly." msgstr "" -#: ../../library/multiprocessing.rst:2590 +#: ../../library/multiprocessing.rst:2596 msgid "Listener objects have the following read-only properties:" msgstr "" -#: ../../library/multiprocessing.rst:2594 +#: ../../library/multiprocessing.rst:2600 msgid "The address which is being used by the Listener object." msgstr "" -#: ../../library/multiprocessing.rst:2598 +#: ../../library/multiprocessing.rst:2604 msgid "" "The address from which the last accepted connection came. If this is " "unavailable then it is ``None``." msgstr "" -#: ../../library/multiprocessing.rst:2601 +#: ../../library/multiprocessing.rst:2607 msgid "" "Listener objects now support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the " "listener object, and :meth:`~contextmanager.__exit__` calls :meth:`close`." msgstr "" -#: ../../library/multiprocessing.rst:2608 +#: ../../library/multiprocessing.rst:2614 msgid "" "Wait till an object in *object_list* is ready. Returns the list of those " "objects in *object_list* which are ready. If *timeout* is a float then the " @@ -3838,32 +3838,32 @@ msgid "" "zero timeout." msgstr "" -#: ../../library/multiprocessing.rst:2614 +#: ../../library/multiprocessing.rst:2620 msgid "" "For both POSIX and Windows, an object can appear in *object_list* if it is" msgstr "" -#: ../../library/multiprocessing.rst:2617 +#: ../../library/multiprocessing.rst:2623 msgid "a readable :class:`~multiprocessing.connection.Connection` object;" msgstr "" -#: ../../library/multiprocessing.rst:2618 +#: ../../library/multiprocessing.rst:2624 msgid "a connected and readable :class:`socket.socket` object; or" msgstr "" -#: ../../library/multiprocessing.rst:2619 +#: ../../library/multiprocessing.rst:2625 msgid "" "the :attr:`~multiprocessing.Process.sentinel` attribute of a :class:" "`~multiprocessing.Process` object." msgstr "" -#: ../../library/multiprocessing.rst:2622 +#: ../../library/multiprocessing.rst:2628 msgid "" "A connection or socket object is ready when there is data available to be " "read from it, or the other end has been closed." msgstr "" -#: ../../library/multiprocessing.rst:2625 +#: ../../library/multiprocessing.rst:2631 msgid "" "**POSIX**: ``wait(object_list, timeout)`` almost equivalent ``select." "select(object_list, [], [], timeout)``. The difference is that, if :func:" @@ -3871,7 +3871,7 @@ msgid "" "an error number of ``EINTR``, whereas :func:`wait` will not." msgstr "" -#: ../../library/multiprocessing.rst:2631 +#: ../../library/multiprocessing.rst:2637 msgid "" "**Windows**: An item in *object_list* must either be an integer handle which " "is waitable (according to the definition used by the documentation of the " @@ -3881,18 +3881,18 @@ msgid "" "handles.)" msgstr "" -#: ../../library/multiprocessing.rst:2641 +#: ../../library/multiprocessing.rst:2647 msgid "**Examples**" msgstr "" -#: ../../library/multiprocessing.rst:2643 +#: ../../library/multiprocessing.rst:2649 msgid "" "The following server code creates a listener which uses ``'secret " "password'`` as an authentication key. It then waits for a connection and " "sends some data to the client::" msgstr "" -#: ../../library/multiprocessing.rst:2647 +#: ../../library/multiprocessing.rst:2653 msgid "" "from multiprocessing.connection import Listener\n" "from array import array\n" @@ -3910,13 +3910,13 @@ msgid "" " conn.send_bytes(array('i', [42, 1729]))" msgstr "" -#: ../../library/multiprocessing.rst:2662 +#: ../../library/multiprocessing.rst:2668 msgid "" "The following code connects to the server and receives some data from the " "server::" msgstr "" -#: ../../library/multiprocessing.rst:2665 +#: ../../library/multiprocessing.rst:2671 msgid "" "from multiprocessing.connection import Client\n" "from array import array\n" @@ -3946,13 +3946,13 @@ msgstr "" " print(conn.recv_bytes_into(arr)) # => 8\n" " print(arr) # => array('i', [42, 1729, 0, 0, 0])" -#: ../../library/multiprocessing.rst:2679 +#: ../../library/multiprocessing.rst:2685 msgid "" "The following code uses :func:`~multiprocessing.connection.wait` to wait for " "messages from multiple processes at once::" msgstr "" -#: ../../library/multiprocessing.rst:2682 +#: ../../library/multiprocessing.rst:2688 msgid "" "from multiprocessing import Process, Pipe, current_process\n" "from multiprocessing.connection import wait\n" @@ -3986,23 +3986,23 @@ msgid "" " print(msg)" msgstr "" -#: ../../library/multiprocessing.rst:2717 +#: ../../library/multiprocessing.rst:2723 msgid "Address Formats" msgstr "" -#: ../../library/multiprocessing.rst:2719 +#: ../../library/multiprocessing.rst:2725 msgid "" "An ``'AF_INET'`` address is a tuple of the form ``(hostname, port)`` where " "*hostname* is a string and *port* is an integer." msgstr "" -#: ../../library/multiprocessing.rst:2722 +#: ../../library/multiprocessing.rst:2728 msgid "" "An ``'AF_UNIX'`` address is a string representing a filename on the " "filesystem." msgstr "" -#: ../../library/multiprocessing.rst:2725 +#: ../../library/multiprocessing.rst:2731 msgid "" "An ``'AF_PIPE'`` address is a string of the form :samp:`r'\\\\\\\\\\\\.\\" "\\pipe\\\\\\\\{PipeName}'`. To use :func:`Client` to connect to a named " @@ -4011,17 +4011,17 @@ msgid "" "instead." msgstr "" -#: ../../library/multiprocessing.rst:2730 +#: ../../library/multiprocessing.rst:2736 msgid "" "Note that any string beginning with two backslashes is assumed by default to " "be an ``'AF_PIPE'`` address rather than an ``'AF_UNIX'`` address." msgstr "" -#: ../../library/multiprocessing.rst:2737 +#: ../../library/multiprocessing.rst:2743 msgid "Authentication keys" msgstr "" -#: ../../library/multiprocessing.rst:2739 +#: ../../library/multiprocessing.rst:2745 msgid "" "When one uses :meth:`Connection.recv `, the data received " "is automatically unpickled. Unfortunately unpickling data from an untrusted " @@ -4029,7 +4029,7 @@ msgid "" "use the :mod:`hmac` module to provide digest authentication." msgstr "" -#: ../../library/multiprocessing.rst:2745 +#: ../../library/multiprocessing.rst:2751 msgid "" "An authentication key is a byte string which can be thought of as a " "password: once a connection is established both ends will demand proof that " @@ -4037,7 +4037,7 @@ msgid "" "using the same key does **not** involve sending the key over the connection.)" msgstr "" -#: ../../library/multiprocessing.rst:2751 +#: ../../library/multiprocessing.rst:2757 msgid "" "If authentication is requested but no authentication key is specified then " "the return value of ``current_process().authkey`` is used (see :class:" @@ -4048,17 +4048,17 @@ msgid "" "setting up connections between themselves." msgstr "" -#: ../../library/multiprocessing.rst:2759 +#: ../../library/multiprocessing.rst:2765 msgid "" "Suitable authentication keys can also be generated by using :func:`os." "urandom`." msgstr "" -#: ../../library/multiprocessing.rst:2763 +#: ../../library/multiprocessing.rst:2769 msgid "Logging" msgstr "" -#: ../../library/multiprocessing.rst:2765 +#: ../../library/multiprocessing.rst:2771 msgid "" "Some support for logging is available. Note, however, that the :mod:" "`logging` package does not use process shared locks so it is possible " @@ -4066,27 +4066,27 @@ msgid "" "mixed up." msgstr "" -#: ../../library/multiprocessing.rst:2772 +#: ../../library/multiprocessing.rst:2778 msgid "" "Returns the logger used by :mod:`multiprocessing`. If necessary, a new one " "will be created." msgstr "" -#: ../../library/multiprocessing.rst:2775 +#: ../../library/multiprocessing.rst:2781 msgid "" "When first created the logger has level :const:`logging.NOTSET` and no " "default handler. Messages sent to this logger will not by default propagate " "to the root logger." msgstr "" -#: ../../library/multiprocessing.rst:2779 +#: ../../library/multiprocessing.rst:2785 msgid "" "Note that on Windows child processes will only inherit the level of the " "parent process's logger -- any other customization of the logger will not be " "inherited." msgstr "" -#: ../../library/multiprocessing.rst:2786 +#: ../../library/multiprocessing.rst:2792 msgid "" "This function performs a call to :func:`get_logger` but in addition to " "returning the logger created by get_logger, it adds a handler which sends " @@ -4095,11 +4095,11 @@ msgid "" "``level`` argument." msgstr "" -#: ../../library/multiprocessing.rst:2792 +#: ../../library/multiprocessing.rst:2798 msgid "Below is an example session with logging turned on::" msgstr "" -#: ../../library/multiprocessing.rst:2794 +#: ../../library/multiprocessing.rst:2800 msgid "" ">>> import multiprocessing, logging\n" ">>> logger = multiprocessing.log_to_stderr()\n" @@ -4127,21 +4127,21 @@ msgstr "" "[INFO/MainProcess] sending shutdown message to manager\n" "[INFO/SyncManager-...] manager exiting with exitcode 0" -#: ../../library/multiprocessing.rst:2807 +#: ../../library/multiprocessing.rst:2813 msgid "For a full table of logging levels, see the :mod:`logging` module." msgstr "" -#: ../../library/multiprocessing.rst:2811 +#: ../../library/multiprocessing.rst:2817 msgid "The :mod:`multiprocessing.dummy` module" msgstr ":mod:`multiprocessing.dummy` 模組" -#: ../../library/multiprocessing.rst:2816 +#: ../../library/multiprocessing.rst:2822 msgid "" ":mod:`multiprocessing.dummy` replicates the API of :mod:`multiprocessing` " "but is no more than a wrapper around the :mod:`threading` module." msgstr "" -#: ../../library/multiprocessing.rst:2821 +#: ../../library/multiprocessing.rst:2827 msgid "" "In particular, the ``Pool`` function provided by :mod:`multiprocessing." "dummy` returns an instance of :class:`ThreadPool`, which is a subclass of :" @@ -4149,7 +4149,7 @@ msgid "" "worker threads rather than worker processes." msgstr "" -#: ../../library/multiprocessing.rst:2829 +#: ../../library/multiprocessing.rst:2835 msgid "" "A thread pool object which controls a pool of worker threads to which jobs " "can be submitted. :class:`ThreadPool` instances are fully interface " @@ -4159,18 +4159,18 @@ msgid "" "pool.Pool.terminate` manually." msgstr "" -#: ../../library/multiprocessing.rst:2836 +#: ../../library/multiprocessing.rst:2842 msgid "" "*processes* is the number of worker threads to use. If *processes* is " "``None`` then the number returned by :func:`os.process_cpu_count` is used." msgstr "" -#: ../../library/multiprocessing.rst:2842 +#: ../../library/multiprocessing.rst:2848 msgid "" "Unlike :class:`Pool`, *maxtasksperchild* and *context* cannot be provided." msgstr "" -#: ../../library/multiprocessing.rst:2846 +#: ../../library/multiprocessing.rst:2852 msgid "" "A :class:`ThreadPool` shares the same interface as :class:`Pool`, which is " "designed around a pool of processes and predates the introduction of the :" @@ -4180,7 +4180,7 @@ msgid "" "is not understood by any other libraries." msgstr "" -#: ../../library/multiprocessing.rst:2853 +#: ../../library/multiprocessing.rst:2859 msgid "" "Users should generally prefer to use :class:`concurrent.futures." "ThreadPoolExecutor`, which has a simpler interface that was designed around " @@ -4189,69 +4189,69 @@ msgid "" "`asyncio`." msgstr "" -#: ../../library/multiprocessing.rst:2863 +#: ../../library/multiprocessing.rst:2869 msgid "Programming guidelines" msgstr "" -#: ../../library/multiprocessing.rst:2865 +#: ../../library/multiprocessing.rst:2871 msgid "" "There are certain guidelines and idioms which should be adhered to when " "using :mod:`multiprocessing`." msgstr "" -#: ../../library/multiprocessing.rst:2870 +#: ../../library/multiprocessing.rst:2876 msgid "All start methods" msgstr "" -#: ../../library/multiprocessing.rst:2872 +#: ../../library/multiprocessing.rst:2878 msgid "The following applies to all start methods." msgstr "" -#: ../../library/multiprocessing.rst:2874 +#: ../../library/multiprocessing.rst:2880 msgid "Avoid shared state" msgstr "" -#: ../../library/multiprocessing.rst:2876 +#: ../../library/multiprocessing.rst:2882 msgid "" "As far as possible one should try to avoid shifting large amounts of data " "between processes." msgstr "" -#: ../../library/multiprocessing.rst:2879 +#: ../../library/multiprocessing.rst:2885 msgid "" "It is probably best to stick to using queues or pipes for communication " "between processes rather than using the lower level synchronization " "primitives." msgstr "" -#: ../../library/multiprocessing.rst:2883 +#: ../../library/multiprocessing.rst:2889 msgid "Picklability" msgstr "" -#: ../../library/multiprocessing.rst:2885 +#: ../../library/multiprocessing.rst:2891 msgid "Ensure that the arguments to the methods of proxies are picklable." msgstr "" -#: ../../library/multiprocessing.rst:2887 +#: ../../library/multiprocessing.rst:2893 msgid "Thread safety of proxies" msgstr "" -#: ../../library/multiprocessing.rst:2889 +#: ../../library/multiprocessing.rst:2895 msgid "" "Do not use a proxy object from more than one thread unless you protect it " "with a lock." msgstr "" -#: ../../library/multiprocessing.rst:2892 +#: ../../library/multiprocessing.rst:2898 msgid "" "(There is never a problem with different processes using the *same* proxy.)" msgstr "" -#: ../../library/multiprocessing.rst:2894 +#: ../../library/multiprocessing.rst:2900 msgid "Joining zombie processes" msgstr "" -#: ../../library/multiprocessing.rst:2896 +#: ../../library/multiprocessing.rst:2902 msgid "" "On POSIX when a process finishes but has not been joined it becomes a " "zombie. There should never be very many because each time a new process " @@ -4262,11 +4262,11 @@ msgid "" "explicitly join all the processes that you start." msgstr "" -#: ../../library/multiprocessing.rst:2904 +#: ../../library/multiprocessing.rst:2910 msgid "Better to inherit than pickle/unpickle" msgstr "" -#: ../../library/multiprocessing.rst:2906 +#: ../../library/multiprocessing.rst:2912 msgid "" "When using the *spawn* or *forkserver* start methods many types from :mod:" "`multiprocessing` need to be picklable so that child processes can use " @@ -4276,11 +4276,11 @@ msgid "" "inherit it from an ancestor process." msgstr "" -#: ../../library/multiprocessing.rst:2914 +#: ../../library/multiprocessing.rst:2920 msgid "Avoid terminating processes" msgstr "" -#: ../../library/multiprocessing.rst:2916 +#: ../../library/multiprocessing.rst:2922 msgid "" "Using the :meth:`Process.terminate ` " "method to stop a process is liable to cause any shared resources (such as " @@ -4288,18 +4288,18 @@ msgid "" "become broken or unavailable to other processes." msgstr "" -#: ../../library/multiprocessing.rst:2922 +#: ../../library/multiprocessing.rst:2928 msgid "" "Therefore it is probably best to only consider using :meth:`Process." "terminate ` on processes which never use " "any shared resources." msgstr "" -#: ../../library/multiprocessing.rst:2926 +#: ../../library/multiprocessing.rst:2932 msgid "Joining processes that use queues" msgstr "" -#: ../../library/multiprocessing.rst:2928 +#: ../../library/multiprocessing.rst:2934 msgid "" "Bear in mind that a process that has put items in a queue will wait before " "terminating until all the buffered items are fed by the \"feeder\" thread to " @@ -4308,7 +4308,7 @@ msgid "" "queue to avoid this behaviour.)" msgstr "" -#: ../../library/multiprocessing.rst:2934 +#: ../../library/multiprocessing.rst:2940 msgid "" "This means that whenever you use a queue you need to make sure that all " "items which have been put on the queue will eventually be removed before the " @@ -4317,11 +4317,11 @@ msgid "" "processes will be joined automatically." msgstr "" -#: ../../library/multiprocessing.rst:2940 +#: ../../library/multiprocessing.rst:2946 msgid "An example which will deadlock is the following::" msgstr "" -#: ../../library/multiprocessing.rst:2942 +#: ../../library/multiprocessing.rst:2948 msgid "" "from multiprocessing import Process, Queue\n" "\n" @@ -4336,17 +4336,17 @@ msgid "" " obj = queue.get()" msgstr "" -#: ../../library/multiprocessing.rst:2954 +#: ../../library/multiprocessing.rst:2960 msgid "" "A fix here would be to swap the last two lines (or simply remove the ``p." "join()`` line)." msgstr "" -#: ../../library/multiprocessing.rst:2957 +#: ../../library/multiprocessing.rst:2963 msgid "Explicitly pass resources to child processes" msgstr "" -#: ../../library/multiprocessing.rst:2959 +#: ../../library/multiprocessing.rst:2965 msgid "" "On POSIX using the *fork* start method, a child process can make use of a " "shared resource created in a parent process using a global resource. " @@ -4354,7 +4354,7 @@ msgid "" "for the child process." msgstr "" -#: ../../library/multiprocessing.rst:2964 +#: ../../library/multiprocessing.rst:2970 msgid "" "Apart from making the code (potentially) compatible with Windows and the " "other start methods this also ensures that as long as the child process is " @@ -4363,11 +4363,11 @@ msgid "" "collected in the parent process." msgstr "" -#: ../../library/multiprocessing.rst:2971 +#: ../../library/multiprocessing.rst:2977 msgid "So for instance ::" msgstr "" -#: ../../library/multiprocessing.rst:2973 +#: ../../library/multiprocessing.rst:2979 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4389,11 +4389,11 @@ msgstr "" " for i in range(10):\n" " Process(target=f).start()" -#: ../../library/multiprocessing.rst:2983 +#: ../../library/multiprocessing.rst:2989 msgid "should be rewritten as ::" msgstr "" -#: ../../library/multiprocessing.rst:2985 +#: ../../library/multiprocessing.rst:2991 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4415,25 +4415,25 @@ msgstr "" " for i in range(10):\n" " Process(target=f, args=(lock,)).start()" -#: ../../library/multiprocessing.rst:2995 +#: ../../library/multiprocessing.rst:3001 msgid "Beware of replacing :data:`sys.stdin` with a \"file like object\"" msgstr "" -#: ../../library/multiprocessing.rst:2997 +#: ../../library/multiprocessing.rst:3003 msgid ":mod:`multiprocessing` originally unconditionally called::" msgstr "" -#: ../../library/multiprocessing.rst:2999 +#: ../../library/multiprocessing.rst:3005 msgid "os.close(sys.stdin.fileno())" msgstr "os.close(sys.stdin.fileno())" -#: ../../library/multiprocessing.rst:3001 +#: ../../library/multiprocessing.rst:3007 msgid "" "in the :meth:`multiprocessing.Process._bootstrap` method --- this resulted " "in issues with processes-in-processes. This has been changed to::" msgstr "" -#: ../../library/multiprocessing.rst:3004 +#: ../../library/multiprocessing.rst:3010 msgid "" "sys.stdin.close()\n" "sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)" @@ -4441,7 +4441,7 @@ msgstr "" "sys.stdin.close()\n" "sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)" -#: ../../library/multiprocessing.rst:3007 +#: ../../library/multiprocessing.rst:3013 msgid "" "Which solves the fundamental issue of processes colliding with each other " "resulting in a bad file descriptor error, but introduces a potential danger " @@ -4451,14 +4451,14 @@ msgid "" "data being flushed to the object multiple times, resulting in corruption." msgstr "" -#: ../../library/multiprocessing.rst:3014 +#: ../../library/multiprocessing.rst:3020 msgid "" "If you write a file-like object and implement your own caching, you can make " "it fork-safe by storing the pid whenever you append to the cache, and " "discarding the cache when the pid changes. For example::" msgstr "" -#: ../../library/multiprocessing.rst:3018 +#: ../../library/multiprocessing.rst:3024 msgid "" "@property\n" "def cache(self):\n" @@ -4476,26 +4476,26 @@ msgstr "" " self._cache = []\n" " return self._cache" -#: ../../library/multiprocessing.rst:3026 +#: ../../library/multiprocessing.rst:3032 msgid "" "For more information, see :issue:`5155`, :issue:`5313` and :issue:`5331`" msgstr "" -#: ../../library/multiprocessing.rst:3029 +#: ../../library/multiprocessing.rst:3038 msgid "The *spawn* and *forkserver* start methods" msgstr "" -#: ../../library/multiprocessing.rst:3031 +#: ../../library/multiprocessing.rst:3040 msgid "" "There are a few extra restrictions which don't apply to the *fork* start " "method." msgstr "" -#: ../../library/multiprocessing.rst:3034 +#: ../../library/multiprocessing.rst:3043 msgid "More picklability" msgstr "" -#: ../../library/multiprocessing.rst:3036 +#: ../../library/multiprocessing.rst:3045 msgid "" "Ensure that all arguments to :class:`~multiprocessing.Process` are " "picklable. Also, if you subclass ``Process.__init__``, you must make sure " @@ -4503,11 +4503,11 @@ msgid "" "` method is called." msgstr "" -#: ../../library/multiprocessing.rst:3041 +#: ../../library/multiprocessing.rst:3050 msgid "Global variables" msgstr "" -#: ../../library/multiprocessing.rst:3043 +#: ../../library/multiprocessing.rst:3052 msgid "" "Bear in mind that if code run in a child process tries to access a global " "variable, then the value it sees (if any) may not be the same as the value " @@ -4515,30 +4515,30 @@ msgid "" "Process.start>` was called." msgstr "" -#: ../../library/multiprocessing.rst:3048 +#: ../../library/multiprocessing.rst:3057 msgid "" "However, global variables which are just module level constants cause no " "problems." msgstr "" -#: ../../library/multiprocessing.rst:3053 +#: ../../library/multiprocessing.rst:3062 msgid "Safe importing of main module" msgstr "" -#: ../../library/multiprocessing.rst:3055 +#: ../../library/multiprocessing.rst:3064 msgid "" "Make sure that the main module can be safely imported by a new Python " "interpreter without causing unintended side effects (such as starting a new " "process)." msgstr "" -#: ../../library/multiprocessing.rst:3059 +#: ../../library/multiprocessing.rst:3068 msgid "" "For example, using the *spawn* or *forkserver* start method running the " "following module would fail with a :exc:`RuntimeError`::" msgstr "" -#: ../../library/multiprocessing.rst:3063 +#: ../../library/multiprocessing.rst:3072 msgid "" "from multiprocessing import Process\n" "\n" @@ -4556,13 +4556,13 @@ msgstr "" "p = Process(target=foo)\n" "p.start()" -#: ../../library/multiprocessing.rst:3071 +#: ../../library/multiprocessing.rst:3080 msgid "" "Instead one should protect the \"entry point\" of the program by using ``if " "__name__ == '__main__':`` as follows::" msgstr "" -#: ../../library/multiprocessing.rst:3074 +#: ../../library/multiprocessing.rst:3083 msgid "" "from multiprocessing import Process, freeze_support, set_start_method\n" "\n" @@ -4586,33 +4586,33 @@ msgstr "" " p = Process(target=foo)\n" " p.start()" -#: ../../library/multiprocessing.rst:3085 +#: ../../library/multiprocessing.rst:3094 msgid "" "(The ``freeze_support()`` line can be omitted if the program will be run " "normally instead of frozen.)" msgstr "" -#: ../../library/multiprocessing.rst:3088 +#: ../../library/multiprocessing.rst:3097 msgid "" "This allows the newly spawned Python interpreter to safely import the module " "and then run the module's ``foo()`` function." msgstr "" -#: ../../library/multiprocessing.rst:3091 +#: ../../library/multiprocessing.rst:3100 msgid "" "Similar restrictions apply if a pool or manager is created in the main " "module." msgstr "" -#: ../../library/multiprocessing.rst:3098 +#: ../../library/multiprocessing.rst:3107 msgid "Examples" msgstr "範例" -#: ../../library/multiprocessing.rst:3100 +#: ../../library/multiprocessing.rst:3109 msgid "Demonstration of how to create and use customized managers and proxies:" msgstr "" -#: ../../library/multiprocessing.rst:3102 +#: ../../library/multiprocessing.rst:3111 msgid "" "from multiprocessing import freeze_support\n" "from multiprocessing.managers import BaseManager, BaseProxy\n" @@ -4706,11 +4706,11 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3106 +#: ../../library/multiprocessing.rst:3115 msgid "Using :class:`~multiprocessing.pool.Pool`:" msgstr "使用 :class:`~multiprocessing.pool.Pool`:" -#: ../../library/multiprocessing.rst:3108 +#: ../../library/multiprocessing.rst:3117 msgid "" "import multiprocessing\n" "import time\n" @@ -4870,13 +4870,13 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3112 +#: ../../library/multiprocessing.rst:3121 msgid "" "An example showing how to use queues to feed tasks to a collection of worker " "processes and collect the results:" msgstr "" -#: ../../library/multiprocessing.rst:3115 +#: ../../library/multiprocessing.rst:3124 msgid "" "import time\n" "import random\n" From d66eab695676d15f87140fb8373b631a16b6bb72 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 30 Jul 2025 00:19:50 +0000 Subject: [PATCH 02/23] sync with cpython d61f8b84 --- library/array.po | 142 ++++++++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 70 deletions(-) diff --git a/library/array.po b/library/array.po index c9aa3ec262..746000dca2 100644 --- a/library/array.po +++ b/library/array.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-07-30 00:18+0000\n" "PO-Revision-Date: 2021-11-23 18:40+0800\n" "Last-Translator: Benson Chen \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -123,6 +123,10 @@ msgstr "Py_UCS4" msgid "4" msgstr "4" +#: ../../library/array.rst:27 +msgid "\\(2)" +msgstr "" + #: ../../library/array.rst:29 msgid "``'h'``" msgstr "``'h'``" @@ -230,7 +234,7 @@ msgstr "" msgid "Please migrate to ``'w'`` typecode." msgstr "" -#: ../../library/array.rst:64 +#: ../../library/array.rst:67 msgid "" "The actual representation of values is determined by the machine " "architecture (strictly speaking, by the C implementation). The actual size " @@ -239,30 +243,30 @@ msgstr "" "實際上數值的表示方法是被機器的架構所決定(更精準地說,被 C 的實作方法決定)。" "實際的大小可以透過 :attr:`array.itemsize` 屬性存取。" -#: ../../library/array.rst:68 +#: ../../library/array.rst:71 msgid "The module defines the following item:" msgstr "這個模組定義了以下項目:" -#: ../../library/array.rst:73 +#: ../../library/array.rst:76 msgid "A string with all available type codes." msgstr "一個包含所有可用的 type codes 的字串。" -#: ../../library/array.rst:76 +#: ../../library/array.rst:79 msgid "The module defines the following type:" msgstr "這個模組定義了下方的型別:" -#: ../../library/array.rst:81 +#: ../../library/array.rst:84 msgid "" "A new array whose items are restricted by *typecode*, and initialized from " -"the optional *initializer* value, which must be a :class:`bytes` " -"or :class:`bytearray` object, a Unicode string, or iterable over elements of " -"the appropriate type." +"the optional *initializer* value, which must be a :class:`bytes` or :class:" +"`bytearray` object, a Unicode string, or iterable over elements of the " +"appropriate type." msgstr "" "一個新的陣列中的元素被 *typecode* 限制,並由選用的 *initializer* 參數初始化," "*initializer* 必須是一個 :class:`bytes` 或 :class:`bytearray` 物件、一個 " "Unicode 字串或包含適當型別元素的可疊代物件 (iterable)。" -#: ../../library/array.rst:86 +#: ../../library/array.rst:89 msgid "" "If given a :class:`bytes` or :class:`bytearray` object, the initializer is " "passed to the new array's :meth:`frombytes` method; if given a Unicode " @@ -275,7 +279,7 @@ msgstr "" "方法;其他情況時, 一個 initializer 的可疊代物件將被傳入 :meth:`extend` 方法" "之中來將初始項目新增至陣列。" -#: ../../library/array.rst:93 +#: ../../library/array.rst:96 msgid "" "Array objects support the ordinary sequence operations of indexing, slicing, " "concatenation, and multiplication. When using slice assignment, the " @@ -290,7 +294,7 @@ msgstr "" "了緩衝區介面,可以在任何支援 :term:`bytes-like objects ` " "的地方使用。" -#: ../../library/array.rst:99 +#: ../../library/array.rst:102 msgid "" "Raises an :ref:`auditing event ` ``array.__new__`` with arguments " "``typecode``, ``initializer``." @@ -298,19 +302,19 @@ msgstr "" "引發\\ :ref:`稽核事件 (auditing event) ` ``array.__new__`` 並附帶引" "數 ``typecode``、``initializer``。" -#: ../../library/array.rst:104 +#: ../../library/array.rst:107 msgid "The typecode character used to create the array." msgstr "typecode 字元被用在建立陣列時。" -#: ../../library/array.rst:109 +#: ../../library/array.rst:112 msgid "The length in bytes of one array item in the internal representation." msgstr "陣列當中的一個元素在內部需要的位元組長度。" -#: ../../library/array.rst:114 +#: ../../library/array.rst:117 msgid "Append a new item with value *x* to the end of the array." msgstr "新增一個元素 *x* 到陣列的最尾端。" -#: ../../library/array.rst:119 +#: ../../library/array.rst:122 msgid "" "Return a tuple ``(address, length)`` giving the current memory address and " "the length in elements of the buffer used to hold array's contents. The " @@ -327,7 +331,7 @@ msgstr "" "用,例如 :c:func:`!ioctl` 指令。只要陣列存在且沒有使用任何更改長度的操作時," "回傳的數值就有效。" -#: ../../library/array.rst:129 +#: ../../library/array.rst:132 msgid "" "When using array objects from code written in C or C++ (the only way to " "effectively make use of this information), it makes more sense to use the " @@ -339,67 +343,66 @@ msgstr "" "適當的做法是使用陣列物件支援的緩衝區介面。這個方法維護了向後兼容性,並應該在" "新的程式碼中避免。關於緩衝區介面的文件在\\ :ref:`bufferobjects`。" -#: ../../library/array.rst:138 +#: ../../library/array.rst:141 msgid "" "\"Byteswap\" all items of the array. This is only supported for values " -"which are 1, 2, 4, or 8 bytes in size; for other types of " -"values, :exc:`RuntimeError` is raised. It is useful when reading data from " -"a file written on a machine with a different byte order." +"which are 1, 2, 4, or 8 bytes in size; for other types of values, :exc:" +"`RuntimeError` is raised. It is useful when reading data from a file " +"written on a machine with a different byte order." msgstr "" "\"Byteswap\" 所有陣列中的物件。這只有支援物件長度為 1、2、4 或 8 位元組的陣" "列,其他型別的值會導致 :exc:`RuntimeError`。這在從機器讀取位元順序不同的檔案" "時很有用。" -#: ../../library/array.rst:146 +#: ../../library/array.rst:149 msgid "Return the number of occurrences of *x* in the array." msgstr "回傳 *x* 在陣列中出現了幾次。" -#: ../../library/array.rst:151 +#: ../../library/array.rst:154 msgid "" "Append items from *iterable* to the end of the array. If *iterable* is " -"another array, it must have *exactly* the same type code; if " -"not, :exc:`TypeError` will be raised. If *iterable* is not an array, it " -"must be iterable and its elements must be the right type to be appended to " -"the array." +"another array, it must have *exactly* the same type code; if not, :exc:" +"`TypeError` will be raised. If *iterable* is not an array, it must be " +"iterable and its elements must be the right type to be appended to the array." msgstr "" "從 *iterable* 中新增元素到陣列的尾端,如果 *iterable* 是另一個陣列,它必須有" "完全相同的 type code,如果不同會導致 :exc:`TypeError`。如果 *iterable* 不是一" "個陣列,它必須可以被疊代 (iterable) 且其中的元素必須是可以被加入陣列中的正確" "型別。" -#: ../../library/array.rst:159 +#: ../../library/array.rst:162 msgid "" "Appends items from the :term:`bytes-like object`, interpreting its content " -"as an array of machine values (as if it had been read from a file using " -"the :meth:`fromfile` method)." +"as an array of machine values (as if it had been read from a file using the :" +"meth:`fromfile` method)." msgstr "" "從 :term:`bytes-like object` 中新增元素。讀取時會將其內容當作一個機器數值組成" "的陣列(就像從檔案中使用 :meth:`fromfile` 方法讀出的資料)。" -#: ../../library/array.rst:163 +#: ../../library/array.rst:166 msgid ":meth:`!fromstring` is renamed to :meth:`frombytes` for clarity." msgstr "將 :meth:`!fromstring` 更名為 :meth:`frombytes`,使其更加清晰易懂。" -#: ../../library/array.rst:169 +#: ../../library/array.rst:172 msgid "" "Read *n* items (as machine values) from the :term:`file object` *f* and " -"append them to the end of the array. If less than *n* items are " -"available, :exc:`EOFError` is raised, but the items that were available are " -"still inserted into the array." +"append them to the end of the array. If less than *n* items are available, :" +"exc:`EOFError` is raised, but the items that were available are still " +"inserted into the array." msgstr "" "從 :term:`file object` *f* 讀取 *n* 個元素(作為機器數值),接著將這些元素加" "入陣列的最尾端。如果只有少於 *n* 個有效的元素會導致 :exc:`EOFError`,但有效的" "元素仍然會被加入陣列中。" -#: ../../library/array.rst:177 +#: ../../library/array.rst:180 msgid "" -"Append items from the list. This is equivalent to ``for x in list: " -"a.append(x)`` except that if there is a type error, the array is unchanged." +"Append items from the list. This is equivalent to ``for x in list: a." +"append(x)`` except that if there is a type error, the array is unchanged." msgstr "" "從 list 中新增元素。這等價於 ``for x in list: a.append(x)``,除了有型別錯誤產" "生時,陣列會保持原狀不會被更改。" -#: ../../library/array.rst:183 +#: ../../library/array.rst:186 msgid "" "Extends this array with data from the given Unicode string. The array must " "have type code ``'u'`` or ``'w'``; otherwise a :exc:`ValueError` is raised. " @@ -407,32 +410,32 @@ msgid "" "an array of some other type." msgstr "" "用給定的 Unicode 字串擴展這個陣列。陣列的 type code 必須是 ``u`` 或 ``'w'``;" -"其他的型別會導致 :exc:`ValueError` 被引發。使用 " -"``array.frombytes(unicodestring.encode(enc))`` 來新增 Unicode 資料到一個其他" -"型別的陣列。" +"其他的型別會導致 :exc:`ValueError` 被引發。使用 ``array." +"frombytes(unicodestring.encode(enc))`` 來新增 Unicode 資料到一個其他型別的陣" +"列。" -#: ../../library/array.rst:191 +#: ../../library/array.rst:194 msgid "" "Return the smallest *i* such that *i* is the index of the first occurrence " "of *x* in the array. The optional arguments *start* and *stop* can be " -"specified to search for *x* within a subsection of the array. " -"Raise :exc:`ValueError` if *x* is not found." +"specified to search for *x* within a subsection of the array. Raise :exc:" +"`ValueError` if *x* is not found." msgstr "" "回傳 *i* 的最小數值,使得 *i* 成為陣列之中第一次出現 *x* 的索引。選擇性的引" "數 *start* 及 *stop* 則可以被用來在指定的陣列空間中搜尋 *x*。如果 *x* 不存在" "將導致 :exc:`ValueError`。" -#: ../../library/array.rst:196 +#: ../../library/array.rst:199 msgid "Added optional *start* and *stop* parameters." msgstr "新增選擇性的參數 *start* 及 *stop*。" -#: ../../library/array.rst:202 +#: ../../library/array.rst:205 msgid "" "Insert a new item with value *x* in the array before position *i*. Negative " "values are treated as being relative to the end of the array." msgstr "在位置 *i* 之前插入一個元素 *x*。負數的索引值會從陣列尾端開始數。" -#: ../../library/array.rst:208 +#: ../../library/array.rst:211 msgid "" "Removes the item with the index *i* from the array and returns it. The " "optional argument defaults to ``-1``, so that by default the last item is " @@ -441,20 +444,20 @@ msgstr "" "移除並回傳陣列索引值 *i* 的元素。選擇性的引數 *i* 預設為 ``-1``,所以預設會刪" "除並回傳最後一個元素。" -#: ../../library/array.rst:215 +#: ../../library/array.rst:218 msgid "Remove the first occurrence of *x* from the array." msgstr "從陣列中刪除第一個出現的 *x*。" -#: ../../library/array.rst:220 +#: ../../library/array.rst:223 #, fuzzy msgid "Remove all elements from the array." msgstr "從陣列中刪除第一個出現的 *x*。" -#: ../../library/array.rst:227 +#: ../../library/array.rst:230 msgid "Reverse the order of the items in the array." msgstr "反轉陣列中元素的順序。" -#: ../../library/array.rst:232 +#: ../../library/array.rst:235 msgid "" "Convert the array to an array of machine values and return the bytes " "representation (the same sequence of bytes that would be written to a file " @@ -463,31 +466,30 @@ msgstr "" "將陣列轉為另一個機器數值組成的陣列並回傳它的位元組表示(跟用 :meth:`tofile` " "方法寫入檔案時的位元序列相同)。" -#: ../../library/array.rst:236 +#: ../../library/array.rst:239 msgid ":meth:`!tostring` is renamed to :meth:`tobytes` for clarity." msgstr "為了明確性,過去的 :meth:`!tostring` 已更名為 :meth:`tobytes`。" -#: ../../library/array.rst:242 +#: ../../library/array.rst:245 msgid "Write all items (as machine values) to the :term:`file object` *f*." msgstr "將所有元素(作為機器數值)寫入 :term:`file object` *f*。" -#: ../../library/array.rst:247 +#: ../../library/array.rst:250 msgid "Convert the array to an ordinary list with the same items." msgstr "不更改元素,將陣列轉為一般的 list。" -#: ../../library/array.rst:252 +#: ../../library/array.rst:255 #, fuzzy msgid "" "Convert the array to a Unicode string. The array must have a type ``'u'`` " -"or ``'w'``; otherwise a :exc:`ValueError` is raised. Use " -"``array.tobytes().decode(enc)`` to obtain a Unicode string from an array of " -"some other type." +"or ``'w'``; otherwise a :exc:`ValueError` is raised. Use ``array.tobytes()." +"decode(enc)`` to obtain a Unicode string from an array of some other type." msgstr "" -"將陣列轉為一個 Unicode 字串。陣列的型別必須為 ``u``。其他型別的陣列會導" -"致 :exc:`ValueError` 錯誤。請使用 ``array.tobytes().decode(enc)`` 來為其他型" -"別的陣列轉為 Unicode 字串。" +"將陣列轉為一個 Unicode 字串。陣列的型別必須為 ``u``。其他型別的陣列會導致 :" +"exc:`ValueError` 錯誤。請使用 ``array.tobytes().decode(enc)`` 來為其他型別的" +"陣列轉為 Unicode 字串。" -#: ../../library/array.rst:257 +#: ../../library/array.rst:260 #, fuzzy msgid "" "The string representation of array objects has the form ``array(typecode, " @@ -503,10 +505,10 @@ msgstr "" "陣列物件的字串表示形式為 ``array(typecode, initializer)``。若為空陣列則參數 " "*initializer* 被省略,若 *typecode* 是 ``'u'`` 將被表示為 Unicode 字串,其他" "情況則被表示為由數字組成的 list。只要 :class:`~array.array` class(類別)透" -"過 ``from array import array`` 的方式引入,便能確保該字串表示能透" -"過 :func:`eval` 轉換回一個擁有相同型別及數值的陣列。範例: ::" +"過 ``from array import array`` 的方式引入,便能確保該字串表示能透過 :func:" +"`eval` 轉換回一個擁有相同型別及數值的陣列。範例: ::" -#: ../../library/array.rst:269 +#: ../../library/array.rst:272 #, fuzzy msgid "" "array('l')\n" @@ -519,19 +521,19 @@ msgstr "" "array('l', [1, 2, 3, 4, 5])\n" "array('d', [1.0, 2.0, 3.14, -inf, nan])" -#: ../../library/array.rst:277 +#: ../../library/array.rst:280 msgid "Module :mod:`struct`" msgstr ":mod:`struct` 模組" -#: ../../library/array.rst:278 +#: ../../library/array.rst:281 msgid "Packing and unpacking of heterogeneous binary data." msgstr "將包含不同資料類型的二進位資料包裝與解開包裝。" -#: ../../library/array.rst:280 +#: ../../library/array.rst:283 msgid "`NumPy `_" msgstr "`NumPy `_" -#: ../../library/array.rst:281 +#: ../../library/array.rst:284 msgid "The NumPy package defines another array type." msgstr "NumPy 套件定義了另一個陣列型別" From f3fb9ca8b8584c230f90214e7f1c25c647b1a49c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 31 Jul 2025 00:18:12 +0000 Subject: [PATCH 03/23] sync with cpython 5c16f699 --- library/bisect.po | 74 +++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/library/bisect.po b/library/bisect.po index c423cc4f89..1f1e756f26 100644 --- a/library/bisect.po +++ b/library/bisect.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-31 00:16+0000\n" "PO-Revision-Date: 2023-08-01 12:53+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -57,10 +57,20 @@ msgstr "" "叫 :meth:`~object.__lt__` 方法,並在陣列中的值回傳一個插入點。" #: ../../library/bisect.rst:29 +msgid "" +"The functions in this module are not thread-safe. If multiple threads " +"concurrently use :mod:`bisect` functions on the same sequence, this may " +"result in undefined behaviour. Likewise, if the provided sequence is mutated " +"by a different thread while a :mod:`bisect` function is operating on it, the " +"result is undefined. For example, using :py:func:`~bisect.insort_left` on " +"the same list from multiple threads may result in the list becoming unsorted." +msgstr "" + +#: ../../library/bisect.rst:39 msgid "The following functions are provided:" msgstr "此模組提供下面的函式:" -#: ../../library/bisect.rst:34 +#: ../../library/bisect.rst:44 msgid "" "Locate the insertion point for *x* in *a* to maintain sorted order. The " "parameters *lo* and *hi* may be used to specify a subset of the list which " @@ -74,7 +84,7 @@ msgstr "" "有 *x* 出現,插入的位置會在所有 *x* 的前面(左邊)。回傳值可以被當作 ``list." "insert()`` 的第一個參數,但列表 *a* 必須先排序過。" -#: ../../library/bisect.rst:41 +#: ../../library/bisect.rst:51 msgid "" "The returned insertion point *ip* partitions the array *a* into two slices " "such that ``all(elem < x for elem in a[lo : ip])`` is true for the left " @@ -85,7 +95,7 @@ msgstr "" "``all(elem < x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem >= " "x for elem in a[ip : hi])`` 為真。" -#: ../../library/bisect.rst:46 +#: ../../library/bisect.rst:56 msgid "" "*key* specifies a :term:`key function` of one argument that is used to " "extract a comparison key from each element in the array. To support " @@ -95,18 +105,18 @@ msgstr "" "所有元素以得到比較值來計算順位。注意此 function 只會套用在陣列中的元素,不會" "套用在 *x*。" -#: ../../library/bisect.rst:50 +#: ../../library/bisect.rst:60 msgid "" "If *key* is ``None``, the elements are compared directly and no key function " "is called." msgstr "若 *key* 為 ``None``,元素將直接進行比較,不會呼叫任何鍵函式。" -#: ../../library/bisect.rst:53 ../../library/bisect.rst:67 -#: ../../library/bisect.rst:85 ../../library/bisect.rst:105 +#: ../../library/bisect.rst:63 ../../library/bisect.rst:77 +#: ../../library/bisect.rst:95 ../../library/bisect.rst:115 msgid "Added the *key* parameter." msgstr "新增 *key* 參數。" -#: ../../library/bisect.rst:60 +#: ../../library/bisect.rst:70 msgid "" "Similar to :py:func:`~bisect.bisect_left`, but returns an insertion point " "which comes after (to the right of) any existing entries of *x* in *a*." @@ -114,7 +124,7 @@ msgstr "" "類似 :py:func:`~bisect.bisect_left`,但回傳的插入位置會在所有 *a* 當中的 *x* " "的後面(右邊)。" -#: ../../library/bisect.rst:63 +#: ../../library/bisect.rst:73 msgid "" "The returned insertion point *ip* partitions the array *a* into two slices " "such that ``all(elem <= x for elem in a[lo : ip])`` is true for the left " @@ -125,11 +135,11 @@ msgstr "" "``all(elem <= x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem > " "x for elem in a[ip : hi])`` 為真。" -#: ../../library/bisect.rst:73 +#: ../../library/bisect.rst:83 msgid "Insert *x* in *a* in sorted order." msgstr "將元素 *x* 插入 list *a*,並維持順序。" -#: ../../library/bisect.rst:75 +#: ../../library/bisect.rst:85 msgid "" "This function first runs :py:func:`~bisect.bisect_left` to locate an " "insertion point. Next, it runs the :meth:`!insert` method on *a* to insert " @@ -138,13 +148,13 @@ msgstr "" "此函式先使用 :py:func:`~bisect.bisect_left` 搜尋插入位置,接著用 :meth:`!" "insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。" -#: ../../library/bisect.rst:79 ../../library/bisect.rst:99 +#: ../../library/bisect.rst:89 ../../library/bisect.rst:109 msgid "" "To support inserting records in a table, the *key* function (if any) is " "applied to *x* for the search step but not for the insertion step." msgstr "此函式只有在搜尋時會使用 *key* 函式,插入時不會。" -#: ../../library/bisect.rst:82 ../../library/bisect.rst:102 +#: ../../library/bisect.rst:92 ../../library/bisect.rst:112 msgid "" "Keep in mind that the *O*\\ (log *n*) search is dominated by the slow *O*\\ " "(*n*) insertion step." @@ -152,7 +162,7 @@ msgstr "" "注意雖然搜尋是 *O*\\ (log *n*),但插入是 *O*\\ (*n*),因此此函式整體時間複雜" "度是 *O*\\ (*n*)。" -#: ../../library/bisect.rst:92 +#: ../../library/bisect.rst:102 msgid "" "Similar to :py:func:`~bisect.insort_left`, but inserting *x* in *a* after " "any existing entries of *x*." @@ -160,7 +170,7 @@ msgstr "" "類似 :py:func:`~bisect.insort_left`,但插入的位置會在所有 *a* 當中的 *x* 的後" "面(右邊)。" -#: ../../library/bisect.rst:95 +#: ../../library/bisect.rst:105 msgid "" "This function first runs :py:func:`~bisect.bisect_right` to locate an " "insertion point. Next, it runs the :meth:`!insert` method on *a* to insert " @@ -169,11 +179,11 @@ msgstr "" "此函式先使用 :py:func:`~bisect.bisect_right` 搜尋插入位置,接著用 :meth:`!" "insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。" -#: ../../library/bisect.rst:110 +#: ../../library/bisect.rst:120 msgid "Performance Notes" msgstr "效能考量" -#: ../../library/bisect.rst:112 +#: ../../library/bisect.rst:122 msgid "" "When writing time sensitive code using *bisect()* and *insort()*, keep these " "thoughts in mind:" @@ -181,7 +191,7 @@ msgstr "" "若在需要關注寫入時間的程式當中使用 *bisect()* 和 *insort()*,請特別注意幾個事" "項:" -#: ../../library/bisect.rst:115 +#: ../../library/bisect.rst:125 msgid "" "Bisection is effective for searching ranges of values. For locating specific " "values, dictionaries are more performant." @@ -189,7 +199,7 @@ msgstr "" "二分法在一段範圍的數值中做搜尋的效率較佳,但若是要存取特定數值,使用字典的表" "現還是比較好。" -#: ../../library/bisect.rst:118 +#: ../../library/bisect.rst:128 msgid "" "The *insort()* functions are *O*\\ (*n*) because the logarithmic search step " "is dominated by the linear time insertion step." @@ -197,7 +207,7 @@ msgstr "" "*insort()* 函式的複雜度為 *O*\\ (*n*),因為對數搜尋是以線性時間的插入步驟所主" "導 (dominate)。" -#: ../../library/bisect.rst:121 +#: ../../library/bisect.rst:131 msgid "" "The search functions are stateless and discard key function results after " "they are used. Consequently, if the search functions are used in a loop, " @@ -213,7 +223,7 @@ msgstr "" "另外,也可以透過搜尋預先計算好的鍵列表 (array of precomputed keys) 來定位插入" "點(如下方範例所示)。" -#: ../../library/bisect.rst:131 +#: ../../library/bisect.rst:141 msgid "" "`Sorted Collections `_ is a " "high performance module that uses *bisect* to managed sorted collections of " @@ -222,7 +232,7 @@ msgstr "" "`有序容器 (Sorted Collections) `_ 是一個使用 *bisect* 來管理資料之有序集合的高效能模組。" -#: ../../library/bisect.rst:135 +#: ../../library/bisect.rst:145 msgid "" "The `SortedCollection recipe `_ uses bisect to build a full-featured collection class " @@ -235,11 +245,11 @@ msgstr "" "class) 並帶有符合直覺的搜尋方法 (search methods) 與支援鍵函式。鍵會預先被計算" "好,以減少搜尋過程中多餘的鍵函式呼叫。" -#: ../../library/bisect.rst:143 +#: ../../library/bisect.rst:153 msgid "Searching Sorted Lists" msgstr "搜尋一個已排序的 list" -#: ../../library/bisect.rst:145 +#: ../../library/bisect.rst:155 msgid "" "The above `bisect functions`_ are useful for finding insertion points but " "can be tricky or awkward to use for common searching tasks. The following " @@ -249,7 +259,7 @@ msgstr "" "上面的 `bisect functions`_ 在找到數值插入點上很有用,但一般的數值搜尋任務上就" "不是那麼的方便。以下的五個函式展示了如何將其轉換成標準的有序列表查找函式: ::" -#: ../../library/bisect.rst:150 +#: ../../library/bisect.rst:160 msgid "" "def index(a, x):\n" " 'Locate the leftmost value exactly equal to x'\n" @@ -287,11 +297,11 @@ msgid "" " raise ValueError" msgstr "" -#: ../../library/bisect.rst:187 +#: ../../library/bisect.rst:197 msgid "Examples" msgstr "範例" -#: ../../library/bisect.rst:191 +#: ../../library/bisect.rst:201 msgid "" "The :py:func:`~bisect.bisect` function can be useful for numeric table " "lookups. This example uses :py:func:`~bisect.bisect` to look up a letter " @@ -302,7 +312,7 @@ msgstr "" "個範例使用 :py:func:`~bisect.bisect` 以基於一組有序的數值分界點來為一個考試成" "績找到相對應的字母等級:90 以上是 'A'、80 到 89 為 'B',依此類推: ::" -#: ../../library/bisect.rst:196 +#: ../../library/bisect.rst:206 msgid "" ">>> def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):\n" "... i = bisect(breakpoints, score)\n" @@ -318,7 +328,7 @@ msgstr "" ">>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]\n" "['F', 'A', 'C', 'C', 'B', 'A', 'A']" -#: ../../library/bisect.rst:203 +#: ../../library/bisect.rst:213 msgid "" "The :py:func:`~bisect.bisect` and :py:func:`~bisect.insort` functions also " "work with lists of tuples. The *key* argument can serve to extract the " @@ -328,7 +338,7 @@ msgstr "" "tuples(元組)的 lists,*key* 引數可被用以取出在數值表中作為排序依據的欄" "位: ::" -#: ../../library/bisect.rst:207 +#: ../../library/bisect.rst:217 msgid "" ">>> from collections import namedtuple\n" ">>> from operator import attrgetter\n" @@ -361,7 +371,7 @@ msgid "" " Movie(name='Titanic', released=1997, director='Cameron')]" msgstr "" -#: ../../library/bisect.rst:237 +#: ../../library/bisect.rst:247 msgid "" "If the key function is expensive, it is possible to avoid repeated function " "calls by searching a list of precomputed keys to find the index of a record::" @@ -369,7 +379,7 @@ msgstr "" "如果鍵函式會消耗較多運算資源,那可以在預先計算好的鍵列表中搜尋該紀錄的索引" "值,以減少重複的函式呼叫: ::" -#: ../../library/bisect.rst:240 +#: ../../library/bisect.rst:250 msgid "" ">>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]\n" ">>> data.sort(key=lambda r: r[1]) # Or use operator.itemgetter(1).\n" From 51e85cf3b2f9f8ed15721a09559fdd36c1e29e56 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 3 Aug 2025 00:20:52 +0000 Subject: [PATCH 04/23] sync with cpython 3b28cb0f --- c-api/code.po | 137 +++++++++++++++++++++++++++++++----- c-api/veryhigh.po | 10 +-- library/__future__.po | 157 ++++++++++++++++++++---------------------- 3 files changed, 200 insertions(+), 104 deletions(-) diff --git a/c-api/code.po b/c-api/code.po index 3ce283f533..65d8572ff6 100644 --- a/c-api/code.po +++ b/c-api/code.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-03 00:19+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -252,85 +252,184 @@ msgid "" "it before returning." msgstr "" -#: ../../c-api/code.rst:215 +#: ../../c-api/code.rst:217 +#, fuzzy +msgid "Code Object Flags" +msgstr "程式碼物件" + +#: ../../c-api/code.rst:219 +msgid "" +"Code objects contain a bit-field of flags, which can be retrieved as the :" +"attr:`~codeobject.co_flags` Python attribute (for example using :c:func:" +"`PyObject_GetAttrString`), and set using a *flags* argument to :c:func:" +"`PyUnstable_Code_New` and similar functions." +msgstr "" + +#: ../../c-api/code.rst:224 +msgid "" +"Flags whose names start with ``CO_FUTURE_`` correspond to features normally " +"selectable by :ref:`future statements `. These flags can be used in :" +"c:member:`PyCompilerFlags.cf_flags`. Note that many ``CO_FUTURE_`` flags are " +"mandatory in current versions of Python, and setting them has no effect." +msgstr "" + +#: ../../c-api/code.rst:230 +msgid "" +"The following flags are available. For their meaning, see the linked " +"documentation of their Python equivalents." +msgstr "" + +#: ../../c-api/code.rst:238 +msgid "Flag" +msgstr "" + +#: ../../c-api/code.rst:239 +msgid "Meaning" +msgstr "" + +#: ../../c-api/code.rst:241 +msgid ":py:data:`inspect.CO_OPTIMIZED`" +msgstr "" + +#: ../../c-api/code.rst:243 +msgid ":py:data:`inspect.CO_NEWLOCALS`" +msgstr "" + +#: ../../c-api/code.rst:245 +msgid ":py:data:`inspect.CO_VARARGS`" +msgstr "" + +#: ../../c-api/code.rst:247 +msgid ":py:data:`inspect.CO_VARKEYWORDS`" +msgstr "" + +#: ../../c-api/code.rst:249 +msgid ":py:data:`inspect.CO_NESTED`" +msgstr "" + +#: ../../c-api/code.rst:251 +msgid ":py:data:`inspect.CO_GENERATOR`" +msgstr "" + +#: ../../c-api/code.rst:253 +msgid ":py:data:`inspect.CO_COROUTINE`" +msgstr "" + +#: ../../c-api/code.rst:255 +msgid ":py:data:`inspect.CO_ITERABLE_COROUTINE`" +msgstr "" + +#: ../../c-api/code.rst:257 +msgid ":py:data:`inspect.CO_ASYNC_GENERATOR`" +msgstr "" + +#: ../../c-api/code.rst:260 +msgid "no effect (:py:data:`__future__.division`)" +msgstr "" + +#: ../../c-api/code.rst:262 +msgid "no effect (:py:data:`__future__.absolute_import`)" +msgstr "" + +#: ../../c-api/code.rst:264 +msgid "no effect (:py:data:`__future__.with_statement`)" +msgstr "" + +#: ../../c-api/code.rst:266 +msgid "no effect (:py:data:`__future__.print_function`)" +msgstr "" + +#: ../../c-api/code.rst:268 +msgid "no effect (:py:data:`__future__.unicode_literals`)" +msgstr "" + +#: ../../c-api/code.rst:270 +msgid "no effect (:py:data:`__future__.generator_stop`)" +msgstr "" + +#: ../../c-api/code.rst:272 +msgid ":py:data:`__future__.annotations`" +msgstr "" + +#: ../../c-api/code.rst:276 msgid "Extra information" msgstr "" -#: ../../c-api/code.rst:217 +#: ../../c-api/code.rst:278 msgid "" "To support low-level extensions to frame evaluation, such as external just-" "in-time compilers, it is possible to attach arbitrary extra data to code " "objects." msgstr "" -#: ../../c-api/code.rst:221 +#: ../../c-api/code.rst:282 msgid "" "These functions are part of the unstable C API tier: this functionality is a " "CPython implementation detail, and the API may change without deprecation " "warnings." msgstr "" -#: ../../c-api/code.rst:227 +#: ../../c-api/code.rst:288 msgid "Return a new an opaque index value used to adding data to code objects." msgstr "" -#: ../../c-api/code.rst:229 +#: ../../c-api/code.rst:290 msgid "" "You generally call this function once (per interpreter) and use the result " "with ``PyCode_GetExtra`` and ``PyCode_SetExtra`` to manipulate data on " "individual code objects." msgstr "" -#: ../../c-api/code.rst:233 +#: ../../c-api/code.rst:294 msgid "" "If *free* is not ``NULL``: when a code object is deallocated, *free* will be " "called on non-``NULL`` data stored under the new index. Use :c:func:" "`Py_DecRef` when storing :c:type:`PyObject`." msgstr "" -#: ../../c-api/code.rst:239 +#: ../../c-api/code.rst:300 msgid "as ``_PyEval_RequestCodeExtraIndex``" msgstr "" -#: ../../c-api/code.rst:243 +#: ../../c-api/code.rst:304 msgid "" "Renamed to ``PyUnstable_Eval_RequestCodeExtraIndex``. The old private name " "is deprecated, but will be available until the API changes." msgstr "" -#: ../../c-api/code.rst:249 +#: ../../c-api/code.rst:310 msgid "" "Set *extra* to the extra data stored under the given index. Return 0 on " "success. Set an exception and return -1 on failure." msgstr "" -#: ../../c-api/code.rst:252 +#: ../../c-api/code.rst:313 msgid "" "If no data was set under the index, set *extra* to ``NULL`` and return 0 " "without setting an exception." msgstr "" -#: ../../c-api/code.rst:257 +#: ../../c-api/code.rst:318 msgid "as ``_PyCode_GetExtra``" msgstr "" -#: ../../c-api/code.rst:261 +#: ../../c-api/code.rst:322 msgid "" "Renamed to ``PyUnstable_Code_GetExtra``. The old private name is deprecated, " "but will be available until the API changes." msgstr "" -#: ../../c-api/code.rst:267 +#: ../../c-api/code.rst:328 msgid "" "Set the extra data stored under the given index to *extra*. Return 0 on " "success. Set an exception and return -1 on failure." msgstr "" -#: ../../c-api/code.rst:272 +#: ../../c-api/code.rst:333 msgid "as ``_PyCode_SetExtra``" msgstr "" -#: ../../c-api/code.rst:276 +#: ../../c-api/code.rst:337 msgid "" "Renamed to ``PyUnstable_Code_SetExtra``. The old private name is deprecated, " "but will be available until the API changes." @@ -356,14 +455,14 @@ msgstr "PyCode_New(C 函式)" msgid "PyCode_NewWithPosOnlyArgs (C function)" msgstr "PyCode_NewWithPosOnlyArgs(C 函式)" -#: ../../c-api/code.rst:237 +#: ../../c-api/code.rst:298 msgid "_PyEval_RequestCodeExtraIndex (C function)" msgstr "_PyEval_RequestCodeExtraIndex(C 函式)" -#: ../../c-api/code.rst:255 +#: ../../c-api/code.rst:316 msgid "_PyCode_GetExtra (C function)" msgstr "_PyCode_GetExtra(C 函式)" -#: ../../c-api/code.rst:270 +#: ../../c-api/code.rst:331 msgid "_PyCode_SetExtra (C function)" msgstr "_PyCode_SetExtra(C 函式)" diff --git a/c-api/veryhigh.po b/c-api/veryhigh.po index 80cabb8b50..4901187f50 100644 --- a/c-api/veryhigh.po +++ b/c-api/veryhigh.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-01-22 00:13+0000\n" +"POT-Creation-Date: 2025-08-03 00:19+0000\n" "PO-Revision-Date: 2018-05-23 14:08+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -400,10 +400,12 @@ msgid "" "mod:`!ast` Python module, which exports these constants under the same names." msgstr "" -#: ../../c-api/veryhigh.rst:366 +#: ../../c-api/veryhigh.rst:364 msgid "" -"This bit can be set in *flags* to cause division operator ``/`` to be " -"interpreted as \"true division\" according to :pep:`238`." +"The \"``PyCF``\" flags above can be combined with \"``CO_FUTURE``\" flags " +"such as :c:macro:`CO_FUTURE_ANNOTATIONS` to enable features normally " +"selectable using :ref:`future statements `. See :ref:" +"`c_codeobject_flags` for a complete list." msgstr "" #: ../../c-api/veryhigh.rst:301 ../../c-api/veryhigh.rst:309 diff --git a/library/__future__.po b/library/__future__.po index a1267b3397..762845fc30 100644 --- a/library/__future__.po +++ b/library/__future__.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-08-03 00:19+0000\n" "PO-Revision-Date: 2024-02-06 02:12+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -88,157 +88,122 @@ msgstr "" "不會從 :mod:`__future__` 中刪除任何功能描述。自從在 Python 2.1 中引入以來,以" "下功能已透過這種機制引入到該語言中:" -#: ../../library/__future__.rst:41 +#: ../../library/__future__.rst:45 msgid "feature" msgstr "功能" -#: ../../library/__future__.rst:41 +#: ../../library/__future__.rst:46 msgid "optional in" msgstr "可選的版本" -#: ../../library/__future__.rst:41 +#: ../../library/__future__.rst:47 msgid "mandatory in" msgstr "強制性的版本" -#: ../../library/__future__.rst:41 +#: ../../library/__future__.rst:48 msgid "effect" msgstr "影響" -#: ../../library/__future__.rst:43 -msgid "nested_scopes" -msgstr "nested_scopes" - -#: ../../library/__future__.rst:43 +#: ../../library/__future__.rst:50 msgid "2.1.0b1" msgstr "2.1.0b1" -#: ../../library/__future__.rst:43 +#: ../../library/__future__.rst:51 msgid "2.2" msgstr "2.2" -#: ../../library/__future__.rst:43 +#: ../../library/__future__.rst:52 msgid ":pep:`227`: *Statically Nested Scopes*" msgstr ":pep:`227`: *靜態巢狀作用域 (Statically Nested Scopes)*" -#: ../../library/__future__.rst:46 -msgid "generators" -msgstr "generators" - -#: ../../library/__future__.rst:46 +#: ../../library/__future__.rst:54 msgid "2.2.0a1" msgstr "2.2.0a1" -#: ../../library/__future__.rst:46 +#: ../../library/__future__.rst:55 msgid "2.3" msgstr "2.3" -#: ../../library/__future__.rst:46 +#: ../../library/__future__.rst:56 msgid ":pep:`255`: *Simple Generators*" msgstr ":pep:`255`: *簡單產生器 (Simple Generators)*" -#: ../../library/__future__.rst:49 -msgid "division" -msgstr "division" - -#: ../../library/__future__.rst:49 +#: ../../library/__future__.rst:58 msgid "2.2.0a2" msgstr "2.2.0a2" -#: ../../library/__future__.rst:49 ../../library/__future__.rst:52 -#: ../../library/__future__.rst:58 ../../library/__future__.rst:61 +#: ../../library/__future__.rst:59 ../../library/__future__.rst:63 +#: ../../library/__future__.rst:71 ../../library/__future__.rst:75 msgid "3.0" msgstr "3.0" -#: ../../library/__future__.rst:49 +#: ../../library/__future__.rst:60 msgid ":pep:`238`: *Changing the Division Operator*" msgstr ":pep:`238`: *更改除法運算子 (Changing the Division Operator)*" -#: ../../library/__future__.rst:52 -msgid "absolute_import" -msgstr "absolute_import" - -#: ../../library/__future__.rst:52 ../../library/__future__.rst:55 +#: ../../library/__future__.rst:62 ../../library/__future__.rst:66 msgid "2.5.0a1" msgstr "2.5.0a1" -#: ../../library/__future__.rst:52 +#: ../../library/__future__.rst:64 msgid ":pep:`328`: *Imports: Multi-Line and Absolute/Relative*" msgstr "" ":pep:`328`: *引入:多列與絕對/相對 (Imports: Multi-Line and Absolute/" "Relative)*" -#: ../../library/__future__.rst:55 -msgid "with_statement" -msgstr "with_statement" - -#: ../../library/__future__.rst:55 +#: ../../library/__future__.rst:67 msgid "2.6" msgstr "2.6" -#: ../../library/__future__.rst:55 -msgid ":pep:`343`: *The \"with\" Statement*" +#: ../../library/__future__.rst:68 +#, fuzzy +msgid ":pep:`343`: *The “with” Statement*" msgstr ":pep:`343`: *\"with\" 陳述式 (The \"with\" Statement)*" -#: ../../library/__future__.rst:58 -msgid "print_function" -msgstr "print_function" - -#: ../../library/__future__.rst:58 ../../library/__future__.rst:61 +#: ../../library/__future__.rst:70 ../../library/__future__.rst:74 msgid "2.6.0a2" msgstr "2.6.0a2" -#: ../../library/__future__.rst:58 +#: ../../library/__future__.rst:72 msgid ":pep:`3105`: *Make print a function*" msgstr ":pep:`3105`: *使 print 成為一個函式 (Make print a function)*" -#: ../../library/__future__.rst:61 -msgid "unicode_literals" -msgstr "unicode_literals" - -#: ../../library/__future__.rst:61 +#: ../../library/__future__.rst:76 msgid ":pep:`3112`: *Bytes literals in Python 3000*" msgstr "" ":pep:`3112`: *Python 3000 中的位元組字面值 (Bytes literals in Python 3000)*" -#: ../../library/__future__.rst:64 -msgid "generator_stop" -msgstr "generator_stop" - -#: ../../library/__future__.rst:64 +#: ../../library/__future__.rst:78 msgid "3.5.0b1" msgstr "3.5.0b1" -#: ../../library/__future__.rst:64 +#: ../../library/__future__.rst:79 msgid "3.7" msgstr "3.7" -#: ../../library/__future__.rst:64 +#: ../../library/__future__.rst:80 msgid ":pep:`479`: *StopIteration handling inside generators*" msgstr "" ":pep:`479`: *產生器內部的 StopIteration 處理 (StopIteration handling inside " "generators)*" -#: ../../library/__future__.rst:67 -msgid "annotations" -msgstr "annotations" - -#: ../../library/__future__.rst:67 +#: ../../library/__future__.rst:82 msgid "3.7.0b1" msgstr "3.7.0b1" -#: ../../library/__future__.rst:67 -msgid "TBD [1]_" -msgstr "TBD [1]_" +#: ../../library/__future__.rst:83 +msgid "Never [1]_" +msgstr "" -#: ../../library/__future__.rst:67 +#: ../../library/__future__.rst:84 msgid ":pep:`563`: *Postponed evaluation of annotations*" msgstr ":pep:`563`: *推遲對註釋的求值 (Postponed evaluation of annotations)*" -#: ../../library/__future__.rst:77 +#: ../../library/__future__.rst:92 msgid "Each statement in :file:`__future__.py` is of the form::" msgstr ":file:`__future__.py` 中的每個陳述式的形式如下: ::" -#: ../../library/__future__.rst:79 +#: ../../library/__future__.rst:94 msgid "" "FeatureName = _Feature(OptionalRelease, MandatoryRelease,\n" " CompilerFlag)" @@ -246,7 +211,7 @@ msgstr "" "FeatureName = _Feature(OptionalRelease, MandatoryRelease,\n" " CompilerFlag)" -#: ../../library/__future__.rst:82 +#: ../../library/__future__.rst:97 msgid "" "where, normally, *OptionalRelease* is less than *MandatoryRelease*, and both " "are 5-tuples of the same form as :data:`sys.version_info`::" @@ -254,7 +219,7 @@ msgstr "" "通常,*OptionalRelease* 會小於 *MandatoryRelease*,且兩者都是與 :data:`sys." "version_info` 形式相同的 5 元組 (5-tuple): ::" -#: ../../library/__future__.rst:85 +#: ../../library/__future__.rst:100 msgid "" "(PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int\n" " PY_MINOR_VERSION, # the 1; an int\n" @@ -265,13 +230,13 @@ msgid "" ")" msgstr "" -#: ../../library/__future__.rst:94 +#: ../../library/__future__.rst:109 msgid "" "*OptionalRelease* records the first release in which the feature was " "accepted." msgstr "*OptionalRelease* 記錄該功能首次發布時的 Python 版本。" -#: ../../library/__future__.rst:98 +#: ../../library/__future__.rst:113 msgid "" "In the case of a *MandatoryRelease* that has not yet occurred, " "*MandatoryRelease* predicts the release in which the feature will become " @@ -280,7 +245,7 @@ msgstr "" "如果 *MandatoryRelease* 尚未發布,*MandatoryRelease* 會預測該功能將成為該語言" "一部分的版本。" -#: ../../library/__future__.rst:102 +#: ../../library/__future__.rst:117 msgid "" "Else *MandatoryRelease* records when the feature became part of the " "language; in releases at or after that, modules no longer need a future " @@ -290,7 +255,7 @@ msgstr "" "否則 *MandatoryRelease* 會記錄該功能是何時成為語言的一部分;在該版本或之後的" "版本中,模組不再需要 future 聲明來使用相關功能,但可以繼續使用此種引入方式。" -#: ../../library/__future__.rst:106 +#: ../../library/__future__.rst:121 msgid "" "*MandatoryRelease* may also be ``None``, meaning that a planned feature got " "dropped or that it is not yet decided." @@ -298,7 +263,7 @@ msgstr "" "*MandatoryRelease* 也可能是 ``None``,這意味著計劃中的功能被丟棄或者仍未決" "定。" -#: ../../library/__future__.rst:111 +#: ../../library/__future__.rst:126 msgid "" "*CompilerFlag* is the (bitfield) flag that should be passed in the fourth " "argument to the built-in function :func:`compile` to enable the feature in " @@ -309,7 +274,7 @@ msgstr "" "式 :func:`compile` 以在動態編譯的程式碼中啟用該功能。此旗標儲存在 :class:" "`_Feature` 實例上的 :attr:`_Feature.compiler_flag` 屬性中。" -#: ../../library/__future__.rst:117 +#: ../../library/__future__.rst:132 msgid "" "``from __future__ import annotations`` was previously scheduled to become " "mandatory in Python 3.10, but the Python Steering Council twice decided to " @@ -327,18 +292,48 @@ msgstr "" "VIZEBX5EYMSYIJNDBF6DMUMZOCWHARSO/>`__)。目前還尚未做出決定。另請參閱 :pep:" "`563` 和 :pep:`649`。" -#: ../../library/__future__.rst:127 +#: ../../library/__future__.rst:142 msgid ":ref:`future`" msgstr ":ref:`future`" -#: ../../library/__future__.rst:128 +#: ../../library/__future__.rst:143 msgid "How the compiler treats future imports." msgstr "編譯器如何處理 future 引入。" -#: ../../library/__future__.rst:130 +#: ../../library/__future__.rst:145 msgid ":pep:`236` - Back to the __future__" msgstr ":pep:`236` - 回到 __future__" -#: ../../library/__future__.rst:131 +#: ../../library/__future__.rst:146 msgid "The original proposal for the __future__ mechanism." msgstr "__future__ 機制的原始提案。" + +#~ msgid "nested_scopes" +#~ msgstr "nested_scopes" + +#~ msgid "generators" +#~ msgstr "generators" + +#~ msgid "division" +#~ msgstr "division" + +#~ msgid "absolute_import" +#~ msgstr "absolute_import" + +#~ msgid "with_statement" +#~ msgstr "with_statement" + +#~ msgid "print_function" +#~ msgstr "print_function" + +#~ msgid "unicode_literals" +#~ msgstr "unicode_literals" + +#~ msgid "generator_stop" +#~ msgstr "generator_stop" + +#~ msgid "annotations" +#~ msgstr "annotations" + +#~ msgid "TBD [1]_" +#~ msgstr "TBD [1]_" From 7165835b4fecfb0a3b4f3113d20f50afb74be9ef Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 4 Aug 2025 00:20:45 +0000 Subject: [PATCH 05/23] sync with cpython d29a9c55 --- library/urllib.request.po | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/urllib.request.po b/library/urllib.request.po index 93b77f5e59..fc66a11e9c 100644 --- a/library/urllib.request.po +++ b/library/urllib.request.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-23 00:17+0000\n" +"POT-Creation-Date: 2025-08-04 00:19+0000\n" "PO-Revision-Date: 2022-04-21 17:59+0800\n" "Last-Translator: Jordan Su \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1095,7 +1095,8 @@ msgid "the three-digit code of the error, as a string," msgstr "HTTP 錯誤的三位數代號字串," #: ../../library/urllib.request.rst:792 -msgid "the user-visible explanation of the code, as as string, and" +#, fuzzy +msgid "the user-visible explanation of the code, as a string, and" msgstr "HTTP 錯誤代號的使用者可見解釋字串,以及" #: ../../library/urllib.request.rst:793 From 1ac1d35b62bbb675bd893f58e790e05256fcb060 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 6 Aug 2025 00:19:14 +0000 Subject: [PATCH 06/23] sync with cpython 3a61ddf2 --- extending/extending.po | 504 ++++++++++++++++++-------------- glossary.po | 632 +++++++++++++++++++++-------------------- library/codecs.po | 8 +- library/fractions.po | 112 ++++---- library/numbers.po | 17 +- 5 files changed, 697 insertions(+), 576 deletions(-) diff --git a/extending/extending.po b/extending/extending.po index df2ba80946..9818750cbd 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-06 00:17+0000\n" "PO-Revision-Date: 2025-02-17 14:34+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -113,7 +113,7 @@ msgstr "" msgid "The first two lines of our file can be::" msgstr "我們檔案的前兩列可以為: ::" -#: ../../extending/extending.rst:60 ../../extending/extending.rst:681 +#: ../../extending/extending.rst:60 ../../extending/extending.rst:706 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include " @@ -152,21 +152,86 @@ msgstr "" #: ../../extending/extending.rst:77 msgid "" "All user-visible symbols defined by :file:`Python.h` have a prefix of ``Py`` " -"or ``PY``, except those defined in standard header files. For convenience, " -"and since they are used extensively by the Python interpreter, ``\"Python." -"h\"`` includes a few standard header files: ````, ````, " -"````, and ````. If the latter header file does not exist " -"on your system, it declares the functions :c:func:`malloc`, :c:func:`free` " -"and :c:func:`realloc` directly." -msgstr "" -"除了那些在標準標頭檔中定義的符號以外,所有由 :file:`Python.h` 定義的使用者可" -"見符號 (user-visible symbols) 的前綴都是 ``Py`` 或 ``PY``。為了方便,也因為 " -"Python 直譯器的大量使用,``\"Python.h\"`` 也引入了一些標準的標頭檔:````、````、```` 和 ````。如果 ```` 在" -"你的系統上不存在,它會直接宣告 :c:func:`malloc`、:c:func:`free` 和 :c:func:" -"`realloc` 函式。" - -#: ../../extending/extending.rst:85 +"or ``PY``, except those defined in standard header files." +msgstr "" + +#: ../../extending/extending.rst:82 +msgid "" +"For backward compatibility, :file:`Python.h` includes several standard " +"header files. C extensions should include the standard headers that they " +"use, and should not rely on these implicit includes. If using the limited C " +"API version 3.13 or newer, the implicit includes are:" +msgstr "" + +#: ../../extending/extending.rst:87 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:88 +msgid "```` (on Windows)" +msgstr "" + +#: ../../extending/extending.rst:89 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:90 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:91 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:92 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:93 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:94 +msgid "```` (if present)" +msgstr "" + +#: ../../extending/extending.rst:96 +msgid "" +"If :c:macro:`Py_LIMITED_API` is not defined, or is set to version 3.12 or " +"older, the headers below are also included:" +msgstr "" + +#: ../../extending/extending.rst:99 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:100 +msgid "```` (on POSIX)" +msgstr "" + +#: ../../extending/extending.rst:102 +msgid "" +"If :c:macro:`Py_LIMITED_API` is not defined, or is set to version 3.10 or " +"older, the headers below are also included:" +msgstr "" + +#: ../../extending/extending.rst:105 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:106 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:107 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:108 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:110 msgid "" "The next thing we add to our module file is the C function that will be " "called when the Python expression ``spam.system(string)`` is evaluated " @@ -176,7 +241,7 @@ msgstr "" "system(string)`` 要被求值 (evaluated) 時就會被呼叫(我們很快就會看到它最後是" "如何被呼叫的): ::" -#: ../../extending/extending.rst:89 +#: ../../extending/extending.rst:114 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -202,7 +267,7 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:101 +#: ../../extending/extending.rst:126 msgid "" "There is a straightforward translation from the argument list in Python (for " "example, the single expression ``\"ls -l\"``) to the arguments passed to the " @@ -212,7 +277,7 @@ msgstr "" "可以很直觀地從 Python 的引數串列(例如單一的運算式 ``\"ls -l\"``)直接轉換成" "傳給 C 函式的引數。C 函式總是有兩個引數,習慣上會命名為 *self* 和 *args*。" -#: ../../extending/extending.rst:106 +#: ../../extending/extending.rst:131 msgid "" "The *self* argument points to the module object for module-level functions; " "for a method it would point to the object instance." @@ -220,7 +285,7 @@ msgstr "" "對於模組層級的函式,*self* 引數會指向模組物件;而對於方法來說則是指向物件的實" "例。" -#: ../../extending/extending.rst:109 +#: ../../extending/extending.rst:134 msgid "" "The *args* argument will be a pointer to a Python tuple object containing " "the arguments. Each item of the tuple corresponds to an argument in the " @@ -237,7 +302,7 @@ msgstr "" "`PyArg_ParseTuple` 函式能夠檢查引數型別並將他們轉換為 C 值。它使用模板字串來" "決定所需的引數型別以及儲存轉換值的 C 變數型別。稍後會再詳細說明。" -#: ../../extending/extending.rst:118 +#: ../../extending/extending.rst:143 msgid "" ":c:func:`PyArg_ParseTuple` returns true (nonzero) if all arguments have the " "right type and its components have been stored in the variables whose " @@ -251,11 +316,11 @@ msgstr "" "(零)。在後者情況下,它也會產生適當的例外,因此呼叫函式可以立即回傳 " "``NULL``\\ (就像我們在範例中所看到的)。" -#: ../../extending/extending.rst:128 +#: ../../extending/extending.rst:153 msgid "Intermezzo: Errors and Exceptions" msgstr "插曲:錯誤與例外" -#: ../../extending/extending.rst:130 +#: ../../extending/extending.rst:155 msgid "" "An important convention throughout the Python interpreter is the following: " "when a function fails, it should set an exception condition and return an " @@ -272,13 +337,13 @@ msgstr "" "們是由 :meth:`sys.exc_info` 所回傳的 Python 元組中的 C 等效元組。它們是例外型" "別、例外實例和回溯物件。了解它們對於理解錯誤是如何傳遞是很重要的。" -#: ../../extending/extending.rst:139 +#: ../../extending/extending.rst:164 msgid "" "The Python API defines a number of functions to set various types of " "exceptions." msgstr "Python API 定義了許多能夠設定各種類型例外的函式。" -#: ../../extending/extending.rst:141 +#: ../../extending/extending.rst:166 msgid "" "The most common one is :c:func:`PyErr_SetString`. Its arguments are an " "exception object and a C string. The exception object is usually a " @@ -291,7 +356,7 @@ msgstr "" "指出錯誤的原因,並被轉換為 Python 字串物件且被儲存為例外的「關聯值 " "(associated value)」。" -#: ../../extending/extending.rst:147 +#: ../../extending/extending.rst:172 msgid "" "Another useful function is :c:func:`PyErr_SetFromErrno`, which only takes an " "exception argument and constructs the associated value by inspection of the " @@ -305,7 +370,7 @@ msgstr "" "`PyErr_SetObject`,它接受兩個物件引數,即例外和它的關聯值。你不需要對傳給任何" "這些函式的物件呼叫 :c:func:`Py_INCREF`。" -#: ../../extending/extending.rst:154 +#: ../../extending/extending.rst:179 msgid "" "You can test non-destructively whether an exception has been set with :c:" "func:`PyErr_Occurred`. This returns the current exception object, or " @@ -317,7 +382,7 @@ msgstr "" "回傳目前的例外物件,如果沒有例外發生則回傳 ``NULL``。你通常不需要呼叫 :c:" "func:`PyErr_Occurred` 來查看函式呼叫是否發生錯誤,因為你應可從回傳值就得知。" -#: ../../extending/extending.rst:160 +#: ../../extending/extending.rst:185 msgid "" "When a function *f* that calls another function *g* detects that the latter " "fails, *f* should itself return an error value (usually ``NULL`` or " @@ -336,7 +401,7 @@ msgstr "" "首先檢測到它的函式回報了。一旦錯誤到達 Python 直譯器的主要迴圈,這會中止目前" "執行的 Python 程式碼,並嘗試尋找 Python 程式設計者指定的例外處理程式。" -#: ../../extending/extending.rst:170 +#: ../../extending/extending.rst:195 msgid "" "(There are situations where a module can actually give a more detailed error " "message by calling another ``PyErr_*`` function, and in such cases it is " @@ -348,7 +413,7 @@ msgstr "" "息,在這種情況下這樣做是沒問題的。然而這一般來說並非必要,而且可能會導致錯誤" "原因資訊的遺失:大多數的操作都可能因為各種原因而失敗。)" -#: ../../extending/extending.rst:176 +#: ../../extending/extending.rst:201 msgid "" "To ignore an exception set by a function call that failed, the exception " "condition must be cleared explicitly by calling :c:func:`PyErr_Clear`. The " @@ -361,7 +426,7 @@ msgstr "" "給直譯器而想要完全是自己來處理它時(可能是要再嘗試其他東西,或者假裝什麼都沒" "出錯)。" -#: ../../extending/extending.rst:182 +#: ../../extending/extending.rst:207 msgid "" "Every failing :c:func:`malloc` call must be turned into an exception --- the " "direct caller of :c:func:`malloc` (or :c:func:`realloc`) must call :c:func:" @@ -375,7 +440,7 @@ msgstr "" "`PyLong_FromLong`)都已經這麼做了,所以這個注意事項只和那些直接呼叫 :c:func:" "`malloc` 的函式有關。" -#: ../../extending/extending.rst:188 +#: ../../extending/extending.rst:213 msgid "" "Also note that, with the important exception of :c:func:`PyArg_ParseTuple` " "and friends, functions that return an integer status usually return a " @@ -386,7 +451,7 @@ msgstr "" "整數狀態的函式通常會回傳一個正值或 0 表示成功、回傳 ``-1`` 表示失敗,就像 " "Unix 系統呼叫一樣。" -#: ../../extending/extending.rst:192 +#: ../../extending/extending.rst:217 msgid "" "Finally, be careful to clean up garbage (by making :c:func:`Py_XDECREF` or :" "c:func:`Py_DECREF` calls for objects you have already created) when you " @@ -395,7 +460,7 @@ msgstr "" "最後,在回傳錯誤指示器時要注意垃圾清理(透過對你已經建立的物件呼叫 :c:func:" "`Py_XDECREF` 或 :c:func:`Py_DECREF`)!" -#: ../../extending/extending.rst:196 +#: ../../extending/extending.rst:221 msgid "" "The choice of which exception to raise is entirely yours. There are " "predeclared C objects corresponding to all built-in Python exceptions, such " @@ -415,42 +480,43 @@ msgstr "" "的值必須在一個特定的範圍內或必須滿足其他條件,則可以使用 :c:data:" "`PyExc_ValueError`。" -#: ../../extending/extending.rst:206 +#: ../../extending/extending.rst:231 msgid "" "You can also define a new exception that is unique to your module. The " "simplest way to do this is to declare a static global object variable at the " "beginning of the file::" msgstr "" -"你也可以定義一個你的模組特有的新例外。最簡單的方式是在檔案的開頭宣告一個靜態全域物件變數: ::" +"你也可以定義一個你的模組特有的新例外。最簡單的方式是在檔案的開頭宣告一個靜態" +"全域物件變數: ::" -#: ../../extending/extending.rst:210 +#: ../../extending/extending.rst:235 msgid "static PyObject *SpamError = NULL;" msgstr "static PyObject *SpamError = NULL;" -#: ../../extending/extending.rst:212 +#: ../../extending/extending.rst:237 msgid "" "and initialize it by calling :c:func:`PyErr_NewException` in the module's :c:" "data:`Py_mod_exec` function (:c:func:`!spam_module_exec`)::" msgstr "" -#: ../../extending/extending.rst:215 +#: ../../extending/extending.rst:240 msgid "SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);" msgstr "" -#: ../../extending/extending.rst:217 +#: ../../extending/extending.rst:242 msgid "" "Since :c:data:`!SpamError` is a global variable, it will be overwitten every " "time the module is reinitialized, when the :c:data:`Py_mod_exec` function is " "called." msgstr "" -#: ../../extending/extending.rst:220 +#: ../../extending/extending.rst:245 msgid "" "For now, let's avoid the issue: we will block repeated initialization by " "raising an :py:exc:`ImportError`::" msgstr "" -#: ../../extending/extending.rst:223 +#: ../../extending/extending.rst:248 msgid "" "static PyObject *SpamError = NULL;\n" "\n" @@ -489,7 +555,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:259 +#: ../../extending/extending.rst:284 msgid "" "Note that the Python name for the exception object is :exc:`!spam.error`. " "The :c:func:`PyErr_NewException` function may create a class with the base " @@ -500,7 +566,7 @@ msgstr "" "exceptions`\\ 所述,:c:func:`PyErr_NewException` 函式可能會建立一個基底類別" "為 :exc:`Exception` 的類別(除非傳入另一個類別來代替 ``NULL``)。" -#: ../../extending/extending.rst:264 +#: ../../extending/extending.rst:289 msgid "" "Note also that the :c:data:`!SpamError` variable retains a reference to the " "newly created exception class; this is intentional! Since the exception " @@ -516,7 +582,7 @@ msgstr "" "如果它變成迷途指標,那產生例外的 C 程式碼可能會導致核心轉儲 (core dump) 或其" "他不預期的 side effect。" -#: ../../extending/extending.rst:271 +#: ../../extending/extending.rst:296 msgid "" "For now, the :c:func:`Py_DECREF` call to remove this reference is missing. " "Even when the Python interpreter shuts down, the global :c:data:`!SpamError` " @@ -524,13 +590,13 @@ msgid "" "ensure that this will happen at most once per process." msgstr "" -#: ../../extending/extending.rst:276 +#: ../../extending/extending.rst:301 msgid "" "We discuss the use of :c:macro:`PyMODINIT_FUNC` as a function return type " "later in this sample." msgstr "我們稍後會討論 :c:macro:`PyMODINIT_FUNC` 作為函式回傳型別的用法。" -#: ../../extending/extending.rst:279 +#: ../../extending/extending.rst:304 msgid "" "The :exc:`!spam.error` exception can be raised in your extension module " "using a call to :c:func:`PyErr_SetString` as shown below::" @@ -538,7 +604,7 @@ msgstr "" "可以在你的擴充模組中呼叫 :c:func:`PyErr_SetString` 來引發 :exc:`!spam.error` " "例外,如下所示: ::" -#: ../../extending/extending.rst:282 +#: ../../extending/extending.rst:307 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -572,17 +638,17 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:302 +#: ../../extending/extending.rst:327 msgid "Back to the Example" msgstr "回到範例" -#: ../../extending/extending.rst:304 +#: ../../extending/extending.rst:329 msgid "" "Going back to our example function, you should now be able to understand " "this statement::" msgstr "回到我們的範例函式,現在你應該可以理解這個陳述式了: ::" -#: ../../extending/extending.rst:307 +#: ../../extending/extending.rst:332 msgid "" "if (!PyArg_ParseTuple(args, \"s\", &command))\n" " return NULL;" @@ -590,7 +656,7 @@ msgstr "" "if (!PyArg_ParseTuple(args, \"s\", &command))\n" " return NULL;" -#: ../../extending/extending.rst:310 +#: ../../extending/extending.rst:335 msgid "" "It returns ``NULL`` (the error indicator for functions returning object " "pointers) if an error is detected in the argument list, relying on the " @@ -606,7 +672,7 @@ msgstr "" "的字串(所以在標準 C 中,:c:data:`!command` 變數應該正確地被宣告為 ``const " "char *command``)。" -#: ../../extending/extending.rst:318 +#: ../../extending/extending.rst:343 msgid "" "The next statement is a call to the Unix function :c:func:`system`, passing " "it the string we just got from :c:func:`PyArg_ParseTuple`::" @@ -614,11 +680,11 @@ msgstr "" "接下來的陳述式會呼叫 Unix 函式 :c:func:`system`,並將剛才從 :c:func:" "`PyArg_ParseTuple` 得到的字串傳給它:" -#: ../../extending/extending.rst:321 +#: ../../extending/extending.rst:346 msgid "sts = system(command);" msgstr "sts = system(command);" -#: ../../extending/extending.rst:323 +#: ../../extending/extending.rst:348 msgid "" "Our :func:`!spam.system` function must return the value of :c:data:`!sts` as " "a Python object. This is done using the function :c:func:" @@ -627,11 +693,11 @@ msgstr "" "我們的 :func:`!spam.system` 函式必須以 Python 物件的形式來回傳 :c:data:`!" "sts` 的值。這是透過 :c:func:`PyLong_FromLong` 函式來達成。 ::" -#: ../../extending/extending.rst:326 +#: ../../extending/extending.rst:351 msgid "return PyLong_FromLong(sts);" msgstr "return PyLong_FromLong(sts);" -#: ../../extending/extending.rst:328 +#: ../../extending/extending.rst:353 msgid "" "In this case, it will return an integer object. (Yes, even integers are " "objects on the heap in Python!)" @@ -639,7 +705,7 @@ msgstr "" "在這種情況下它會回傳一個整數物件。(是的,在 Python 中連整數也是堆積 (heap) 上" "的物件!)" -#: ../../extending/extending.rst:331 +#: ../../extending/extending.rst:356 msgid "" "If you have a C function that returns no useful argument (a function " "returning :c:expr:`void`), the corresponding Python function must return " @@ -650,7 +716,7 @@ msgstr "" "應的 Python 函式必須回傳 ``None``。你需要以下這個慣例來達成(由 :c:macro:" "`Py_RETURN_NONE` 巨集實作): ::" -#: ../../extending/extending.rst:336 +#: ../../extending/extending.rst:361 msgid "" "Py_INCREF(Py_None);\n" "return Py_None;" @@ -658,7 +724,7 @@ msgstr "" "Py_INCREF(Py_None);\n" "return Py_None;" -#: ../../extending/extending.rst:339 +#: ../../extending/extending.rst:364 msgid "" ":c:data:`Py_None` is the C name for the special Python object ``None``. It " "is a genuine Python object rather than a ``NULL`` pointer, which means " @@ -668,11 +734,11 @@ msgstr "" "Python 物件而不是一個 ``NULL`` 指標,在大多數的情況下它的意思是「錯誤」,如我" "們所見過的那樣。" -#: ../../extending/extending.rst:347 +#: ../../extending/extending.rst:372 msgid "The Module's Method Table and Initialization Function" msgstr "模組的方法表和初始化函式" -#: ../../extending/extending.rst:349 +#: ../../extending/extending.rst:374 msgid "" "I promised to show how :c:func:`!spam_system` is called from Python " "programs. First, we need to list its name and address in a \"method table\"::" @@ -680,7 +746,7 @@ msgstr "" "我承諾過要展示 :c:func:`!spam_system` 是如何從 Python 程式中呼叫的。首先,我" "們需要在「方法表」中列出它的名稱和位址: ::" -#: ../../extending/extending.rst:352 +#: ../../extending/extending.rst:377 msgid "" "static PyMethodDef spam_methods[] = {\n" " ...\n" @@ -698,7 +764,7 @@ msgstr "" " {NULL, NULL, 0, NULL} /* Sentinel */\n" "};" -#: ../../extending/extending.rst:360 +#: ../../extending/extending.rst:385 msgid "" "Note the third entry (``METH_VARARGS``). This is a flag telling the " "interpreter the calling convention to be used for the C function. It should " @@ -710,7 +776,7 @@ msgstr "" "標。通常應該是 ``METH_VARARGS`` 或 ``METH_VARARGS | METH_KEYWORDS``;``0`` 表" "示是使用 :c:func:`PyArg_ParseTuple` 的一個過時變體。" -#: ../../extending/extending.rst:365 +#: ../../extending/extending.rst:390 msgid "" "When using only ``METH_VARARGS``, the function should expect the Python-" "level parameters to be passed in as a tuple acceptable for parsing via :c:" @@ -720,7 +786,7 @@ msgstr "" "能夠接受以 :c:func:`PyArg_ParseTuple` 進行剖析;有關此函式的更多資訊將在下面" "提供。" -#: ../../extending/extending.rst:369 +#: ../../extending/extending.rst:394 msgid "" "The :c:macro:`METH_KEYWORDS` bit may be set in the third field if keyword " "arguments should be passed to the function. In this case, the C function " @@ -733,12 +799,12 @@ msgstr "" "是關鍵字的字典。可使用 :c:func:`PyArg_ParseTupleAndKeywords` 來剖析這種函式的" "引數。" -#: ../../extending/extending.rst:375 +#: ../../extending/extending.rst:400 msgid "" "The method table must be referenced in the module definition structure::" msgstr "方法表必須在模組定義結構中被參照: ::" -#: ../../extending/extending.rst:377 +#: ../../extending/extending.rst:402 msgid "" "static struct PyModuleDef spam_module = {\n" " ...\n" @@ -747,7 +813,7 @@ msgid "" "};" msgstr "" -#: ../../extending/extending.rst:383 +#: ../../extending/extending.rst:408 msgid "" "This structure, in turn, must be passed to the interpreter in the module's " "initialization function. The initialization function must be named :c:func:" @@ -758,7 +824,7 @@ msgstr "" "為 :c:func:`!PyInit_name`,其中 *name* 是模組的名稱,且應該是模組檔案中唯一定" "義的非「靜態 (``static``)」項目: ::" -#: ../../extending/extending.rst:388 +#: ../../extending/extending.rst:413 msgid "" "PyMODINIT_FUNC\n" "PyInit_spam(void)\n" @@ -772,7 +838,7 @@ msgstr "" " return PyModuleDef_Init(&spam_module);\n" "}" -#: ../../extending/extending.rst:394 +#: ../../extending/extending.rst:419 msgid "" "Note that :c:macro:`PyMODINIT_FUNC` declares the function as ``PyObject *`` " "return type, declares any special linkage declarations required by the " @@ -781,7 +847,7 @@ msgstr "" "請注意,:c:macro:`PyMODINIT_FUNC` 宣告函式的回傳型別為 ``PyObject *``、宣告平" "台所需的任何特殊連結宣告、並針對 C++ 宣告函式為 ``extern \"C\"``。" -#: ../../extending/extending.rst:398 +#: ../../extending/extending.rst:423 msgid "" ":c:func:`!PyInit_spam` is called when each interpreter imports its module :" "mod:`!spam` for the first time. (See below for comments about embedding " @@ -790,7 +856,7 @@ msgid "" "store it in ``sys.modules``." msgstr "" -#: ../../extending/extending.rst:403 +#: ../../extending/extending.rst:428 msgid "" "When embedding Python, the :c:func:`!PyInit_spam` function is not called " "automatically unless there's an entry in the :c:data:`PyImport_Inittab` " @@ -801,7 +867,7 @@ msgstr "" "動呼叫 :c:func:`!PyInit_spam` 函式。要將模組加入初始化表,請使用 :c:func:" "`PyImport_AppendInittab` 並在隨後選擇性地將該模組引入: ::" -#: ../../extending/extending.rst:408 +#: ../../extending/extending.rst:433 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -903,7 +969,7 @@ msgstr "" " Py_ExitStatusException(status);\n" "}" -#: ../../extending/extending.rst:458 +#: ../../extending/extending.rst:483 msgid "" "If you declare a global variable or a local static one, the module may " "experience unintended side-effects on re-initialisation, for example when " @@ -915,7 +981,7 @@ msgid "" "`Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED`)." msgstr "" -#: ../../extending/extending.rst:467 +#: ../../extending/extending.rst:492 msgid "" "A more substantial example module is included in the Python source " "distribution as :file:`Modules/xxlimited.c`. This file may be used as a " @@ -924,11 +990,11 @@ msgstr "" "Python 原始碼發行版本中包含了一個更實質的範例模組 :file:`Modules/xxlimited." "c`。這個檔案可以當作模板使用,也可以簡單地當作範例來閱讀。" -#: ../../extending/extending.rst:475 +#: ../../extending/extending.rst:500 msgid "Compilation and Linkage" msgstr "" -#: ../../extending/extending.rst:477 +#: ../../extending/extending.rst:502 msgid "" "There are two more things to do before you can use your new extension: " "compiling and linking it with the Python system. If you use dynamic " @@ -938,7 +1004,7 @@ msgid "" "Windows (chapter :ref:`building-on-windows`) for more information about this." msgstr "" -#: ../../extending/extending.rst:484 +#: ../../extending/extending.rst:509 msgid "" "If you can't use dynamic loading, or if you want to make your module a " "permanent part of the Python interpreter, you will have to change the " @@ -948,11 +1014,11 @@ msgid "" "line to the file :file:`Modules/Setup.local` describing your file:" msgstr "" -#: ../../extending/extending.rst:491 +#: ../../extending/extending.rst:516 msgid "spam spammodule.o" msgstr "spam spammodule.o" -#: ../../extending/extending.rst:495 +#: ../../extending/extending.rst:520 msgid "" "and rebuild the interpreter by running :program:`make` in the toplevel " "directory. You can also run :program:`make` in the :file:`Modules/` " @@ -961,21 +1027,21 @@ msgid "" "the :file:`Setup` file.)" msgstr "" -#: ../../extending/extending.rst:501 +#: ../../extending/extending.rst:526 msgid "" "If your module requires additional libraries to link with, these can be " "listed on the line in the configuration file as well, for instance:" msgstr "" -#: ../../extending/extending.rst:504 +#: ../../extending/extending.rst:529 msgid "spam spammodule.o -lX11" msgstr "spam spammodule.o -lX11" -#: ../../extending/extending.rst:512 +#: ../../extending/extending.rst:537 msgid "Calling Python Functions from C" msgstr "" -#: ../../extending/extending.rst:514 +#: ../../extending/extending.rst:539 msgid "" "So far we have concentrated on making C functions callable from Python. The " "reverse is also useful: calling Python functions from C. This is especially " @@ -986,7 +1052,7 @@ msgid "" "uses are also imaginable." msgstr "" -#: ../../extending/extending.rst:522 +#: ../../extending/extending.rst:547 msgid "" "Fortunately, the Python interpreter is easily called recursively, and there " "is a standard interface to call a Python function. (I won't dwell on how to " @@ -995,7 +1061,7 @@ msgid "" "line option in :file:`Modules/main.c` from the Python source code.)" msgstr "" -#: ../../extending/extending.rst:528 +#: ../../extending/extending.rst:553 msgid "" "Calling a Python function is easy. First, the Python program must somehow " "pass you the Python function object. You should provide a function (or some " @@ -1005,7 +1071,7 @@ msgid "" "function might be part of a module definition::" msgstr "" -#: ../../extending/extending.rst:535 +#: ../../extending/extending.rst:560 msgid "" "static PyObject *my_callback = NULL;\n" "\n" @@ -1032,7 +1098,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:558 +#: ../../extending/extending.rst:583 msgid "" "This function must be registered with the interpreter using the :c:macro:" "`METH_VARARGS` flag; this is described in section :ref:`methodtable`. The :" @@ -1040,7 +1106,7 @@ msgid "" "section :ref:`parsetuple`." msgstr "" -#: ../../extending/extending.rst:563 +#: ../../extending/extending.rst:588 msgid "" "The macros :c:func:`Py_XINCREF` and :c:func:`Py_XDECREF` increment/decrement " "the reference count of an object and are safe in the presence of ``NULL`` " @@ -1048,7 +1114,7 @@ msgid "" "info on them in section :ref:`refcounts`." msgstr "" -#: ../../extending/extending.rst:570 +#: ../../extending/extending.rst:595 msgid "" "Later, when it is time to call the function, you call the C function :c:func:" "`PyObject_CallObject`. This function has two arguments, both pointers to " @@ -1060,7 +1126,7 @@ msgid "" "or more format codes between parentheses. For example::" msgstr "" -#: ../../extending/extending.rst:579 +#: ../../extending/extending.rst:604 msgid "" "int arg;\n" "PyObject *arglist;\n" @@ -1074,7 +1140,7 @@ msgid "" "Py_DECREF(arglist);" msgstr "" -#: ../../extending/extending.rst:590 +#: ../../extending/extending.rst:615 msgid "" ":c:func:`PyObject_CallObject` returns a Python object pointer: this is the " "return value of the Python function. :c:func:`PyObject_CallObject` is " @@ -1083,7 +1149,7 @@ msgid "" "`Py_DECREF`\\ -ed immediately after the :c:func:`PyObject_CallObject` call." msgstr "" -#: ../../extending/extending.rst:597 +#: ../../extending/extending.rst:622 msgid "" "The return value of :c:func:`PyObject_CallObject` is \"new\": either it is a " "brand new object, or it is an existing object whose reference count has been " @@ -1092,7 +1158,7 @@ msgid "" "not interested in its value." msgstr "" -#: ../../extending/extending.rst:603 +#: ../../extending/extending.rst:628 msgid "" "Before you do this, however, it is important to check that the return value " "isn't ``NULL``. If it is, the Python function terminated by raising an " @@ -1103,7 +1169,7 @@ msgid "" "should be cleared by calling :c:func:`PyErr_Clear`. For example::" msgstr "" -#: ../../extending/extending.rst:611 +#: ../../extending/extending.rst:636 msgid "" "if (result == NULL)\n" " return NULL; /* Pass error back */\n" @@ -1111,7 +1177,7 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:616 +#: ../../extending/extending.rst:641 msgid "" "Depending on the desired interface to the Python callback function, you may " "also have to provide an argument list to :c:func:`PyObject_CallObject`. In " @@ -1123,7 +1189,7 @@ msgid "" "you want to pass an integral event code, you might use the following code::" msgstr "" -#: ../../extending/extending.rst:625 +#: ../../extending/extending.rst:650 msgid "" "PyObject *arglist;\n" "...\n" @@ -1136,7 +1202,7 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:635 +#: ../../extending/extending.rst:660 msgid "" "Note the placement of ``Py_DECREF(arglist)`` immediately after the call, " "before the error check! Also note that strictly speaking this code is not " @@ -1144,14 +1210,14 @@ msgid "" "checked." msgstr "" -#: ../../extending/extending.rst:639 +#: ../../extending/extending.rst:664 msgid "" "You may also call a function with keyword arguments by using :c:func:" "`PyObject_Call`, which supports arguments and keyword arguments. As in the " "above example, we use :c:func:`Py_BuildValue` to construct the dictionary. ::" msgstr "" -#: ../../extending/extending.rst:643 +#: ../../extending/extending.rst:668 msgid "" "PyObject *dict;\n" "...\n" @@ -1164,19 +1230,19 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:657 +#: ../../extending/extending.rst:682 msgid "Extracting Parameters in Extension Functions" msgstr "" -#: ../../extending/extending.rst:661 +#: ../../extending/extending.rst:686 msgid "The :c:func:`PyArg_ParseTuple` function is declared as follows::" msgstr "" -#: ../../extending/extending.rst:663 +#: ../../extending/extending.rst:688 msgid "int PyArg_ParseTuple(PyObject *arg, const char *format, ...);" msgstr "" -#: ../../extending/extending.rst:665 +#: ../../extending/extending.rst:690 msgid "" "The *arg* argument must be a tuple object containing an argument list passed " "from Python to a C function. The *format* argument must be a format string, " @@ -1185,7 +1251,7 @@ msgid "" "whose type is determined by the format string." msgstr "" -#: ../../extending/extending.rst:671 +#: ../../extending/extending.rst:696 msgid "" "Note that while :c:func:`PyArg_ParseTuple` checks that the Python arguments " "have the required types, it cannot check the validity of the addresses of C " @@ -1193,17 +1259,17 @@ msgid "" "probably crash or at least overwrite random bits in memory. So be careful!" msgstr "" -#: ../../extending/extending.rst:676 +#: ../../extending/extending.rst:701 msgid "" "Note that any Python object references which are provided to the caller are " "*borrowed* references; do not decrement their reference count!" msgstr "" -#: ../../extending/extending.rst:679 +#: ../../extending/extending.rst:704 msgid "Some example calls::" msgstr "一些呼叫範例: ::" -#: ../../extending/extending.rst:686 +#: ../../extending/extending.rst:711 msgid "" "int ok;\n" "int i, j;\n" @@ -1223,27 +1289,27 @@ msgstr "" "ok = PyArg_ParseTuple(args, \"\"); /* 沒有引數 */\n" " /* Python 呼叫:f() */" -#: ../../extending/extending.rst:697 +#: ../../extending/extending.rst:722 msgid "" "ok = PyArg_ParseTuple(args, \"s\", &s); /* A string */\n" " /* Possible Python call: f('whoops!') */" msgstr "" -#: ../../extending/extending.rst:702 +#: ../../extending/extending.rst:727 msgid "" "ok = PyArg_ParseTuple(args, \"lls\", &k, &l, &s); /* Two longs and a string " "*/\n" " /* Possible Python call: f(1, 2, 'three') */" msgstr "" -#: ../../extending/extending.rst:707 +#: ../../extending/extending.rst:732 msgid "" "ok = PyArg_ParseTuple(args, \"(ii)s#\", &i, &j, &s, &size);\n" " /* A pair of ints and a string, whose size is also returned */\n" " /* Possible Python call: f((1, 2), 'three') */" msgstr "" -#: ../../extending/extending.rst:713 +#: ../../extending/extending.rst:738 msgid "" "{\n" " const char *file;\n" @@ -1258,7 +1324,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:727 +#: ../../extending/extending.rst:752 msgid "" "{\n" " int left, top, right, bottom, h, v;\n" @@ -1270,7 +1336,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:738 +#: ../../extending/extending.rst:763 msgid "" "{\n" " Py_complex c;\n" @@ -1280,16 +1346,16 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:749 +#: ../../extending/extending.rst:774 msgid "Keyword Parameters for Extension Functions" msgstr "" -#: ../../extending/extending.rst:753 +#: ../../extending/extending.rst:778 msgid "" "The :c:func:`PyArg_ParseTupleAndKeywords` function is declared as follows::" msgstr "" -#: ../../extending/extending.rst:755 +#: ../../extending/extending.rst:780 msgid "" "int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,\n" " const char *format, char * const " @@ -1299,7 +1365,7 @@ msgstr "" " const char *format, char * const " "*kwlist, ...);" -#: ../../extending/extending.rst:758 +#: ../../extending/extending.rst:783 msgid "" "The *arg* and *format* parameters are identical to those of the :c:func:" "`PyArg_ParseTuple` function. The *kwdict* parameter is the dictionary of " @@ -1311,20 +1377,20 @@ msgid "" "raises an appropriate exception." msgstr "" -#: ../../extending/extending.rst:768 +#: ../../extending/extending.rst:793 msgid "" "Nested tuples cannot be parsed when using keyword arguments! Keyword " "parameters passed in which are not present in the *kwlist* will cause :exc:" "`TypeError` to be raised." msgstr "" -#: ../../extending/extending.rst:774 +#: ../../extending/extending.rst:799 msgid "" "Here is an example module which uses keywords, based on an example by Geoff " "Philbrick (philbrick@hks.com)::" msgstr "" -#: ../../extending/extending.rst:777 +#: ../../extending/extending.rst:802 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1377,21 +1443,21 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:828 +#: ../../extending/extending.rst:853 msgid "Building Arbitrary Values" msgstr "" -#: ../../extending/extending.rst:830 +#: ../../extending/extending.rst:855 msgid "" "This function is the counterpart to :c:func:`PyArg_ParseTuple`. It is " "declared as follows::" msgstr "" -#: ../../extending/extending.rst:833 +#: ../../extending/extending.rst:858 msgid "PyObject *Py_BuildValue(const char *format, ...);" msgstr "PyObject *Py_BuildValue(const char *format, ...);" -#: ../../extending/extending.rst:835 +#: ../../extending/extending.rst:860 msgid "" "It recognizes a set of format units similar to the ones recognized by :c:" "func:`PyArg_ParseTuple`, but the arguments (which are input to the function, " @@ -1399,7 +1465,7 @@ msgid "" "object, suitable for returning from a C function called from Python." msgstr "" -#: ../../extending/extending.rst:840 +#: ../../extending/extending.rst:865 msgid "" "One difference with :c:func:`PyArg_ParseTuple`: while the latter requires " "its first argument to be a tuple (since Python argument lists are always " @@ -1411,12 +1477,12 @@ msgid "" "parenthesize the format string." msgstr "" -#: ../../extending/extending.rst:848 +#: ../../extending/extending.rst:873 msgid "" "Examples (to the left the call, to the right the resulting Python value):" msgstr "" -#: ../../extending/extending.rst:850 +#: ../../extending/extending.rst:875 msgid "" "Py_BuildValue(\"\") None\n" "Py_BuildValue(\"i\", 123) 123\n" @@ -1454,11 +1520,11 @@ msgstr "" "Py_BuildValue(\"((ii)(ii)) (ii)\",\n" " 1, 2, 3, 4, 5, 6) (((1, 2), (3, 4)), (5, 6))" -#: ../../extending/extending.rst:874 +#: ../../extending/extending.rst:899 msgid "Reference Counts" msgstr "" -#: ../../extending/extending.rst:876 +#: ../../extending/extending.rst:901 msgid "" "In languages like C or C++, the programmer is responsible for dynamic " "allocation and deallocation of memory on the heap. In C, this is done using " @@ -1467,7 +1533,7 @@ msgid "" "restrict the following discussion to the C case." msgstr "" -#: ../../extending/extending.rst:882 +#: ../../extending/extending.rst:907 msgid "" "Every block of memory allocated with :c:func:`malloc` should eventually be " "returned to the pool of available memory by exactly one call to :c:func:" @@ -1482,7 +1548,7 @@ msgid "" "crashes." msgstr "" -#: ../../extending/extending.rst:893 +#: ../../extending/extending.rst:918 msgid "" "Common causes of memory leaks are unusual paths through the code. For " "instance, a function may allocate a block of memory, do some calculation, " @@ -1499,7 +1565,7 @@ msgid "" "of errors." msgstr "" -#: ../../extending/extending.rst:906 +#: ../../extending/extending.rst:931 msgid "" "Since Python makes heavy use of :c:func:`malloc` and :c:func:`free`, it " "needs a strategy to avoid memory leaks as well as the use of freed memory. " @@ -1510,7 +1576,7 @@ msgid "" "reference to the object has been deleted and the object is freed." msgstr "" -#: ../../extending/extending.rst:914 +#: ../../extending/extending.rst:939 msgid "" "An alternative strategy is called :dfn:`automatic garbage collection`. " "(Sometimes, reference counting is also referred to as a garbage collection " @@ -1526,7 +1592,7 @@ msgid "" "with reference counts." msgstr "" -#: ../../extending/extending.rst:926 +#: ../../extending/extending.rst:951 msgid "" "While Python uses the traditional reference counting implementation, it also " "offers a cycle detector that works to detect reference cycles. This allows " @@ -1540,7 +1606,7 @@ msgid "" "though there are no further references to the cycle itself." msgstr "" -#: ../../extending/extending.rst:937 +#: ../../extending/extending.rst:962 msgid "" "The cycle detector is able to detect garbage cycles and can reclaim them. " "The :mod:`gc` module exposes a way to run the detector (the :func:`~gc." @@ -1548,11 +1614,11 @@ msgid "" "disable the detector at runtime." msgstr "" -#: ../../extending/extending.rst:946 +#: ../../extending/extending.rst:971 msgid "Reference Counting in Python" msgstr "" -#: ../../extending/extending.rst:948 +#: ../../extending/extending.rst:973 msgid "" "There are two macros, ``Py_INCREF(x)`` and ``Py_DECREF(x)``, which handle " "the incrementing and decrementing of the reference count. :c:func:" @@ -1563,7 +1629,7 @@ msgid "" "object." msgstr "" -#: ../../extending/extending.rst:955 +#: ../../extending/extending.rst:980 msgid "" "The big question now remains: when to use ``Py_INCREF(x)`` and " "``Py_DECREF(x)``? Let's first introduce some terms. Nobody \"owns\" an " @@ -1576,7 +1642,7 @@ msgid "" "reference creates a memory leak." msgstr "" -#: ../../extending/extending.rst:964 +#: ../../extending/extending.rst:989 msgid "" "It is also possible to :dfn:`borrow` [#]_ a reference to an object. The " "borrower of a reference should not call :c:func:`Py_DECREF`. The borrower " @@ -1585,7 +1651,7 @@ msgid "" "risks using freed memory and should be avoided completely [#]_." msgstr "" -#: ../../extending/extending.rst:970 +#: ../../extending/extending.rst:995 msgid "" "The advantage of borrowing over owning a reference is that you don't need to " "take care of disposing of the reference on all possible paths through the " @@ -1596,7 +1662,7 @@ msgid "" "borrowed has in fact disposed of it." msgstr "" -#: ../../extending/extending.rst:978 +#: ../../extending/extending.rst:1003 msgid "" "A borrowed reference can be changed into an owned reference by calling :c:" "func:`Py_INCREF`. This does not affect the status of the owner from which " @@ -1605,18 +1671,18 @@ msgid "" "properly, as well as the previous owner)." msgstr "" -#: ../../extending/extending.rst:988 +#: ../../extending/extending.rst:1013 msgid "Ownership Rules" msgstr "" -#: ../../extending/extending.rst:990 +#: ../../extending/extending.rst:1015 msgid "" "Whenever an object reference is passed into or out of a function, it is part " "of the function's interface specification whether ownership is transferred " "with the reference or not." msgstr "" -#: ../../extending/extending.rst:994 +#: ../../extending/extending.rst:1019 msgid "" "Most functions that return a reference to an object pass on ownership with " "the reference. In particular, all functions whose function it is to create " @@ -1627,7 +1693,7 @@ msgid "" "reference to a cached item." msgstr "" -#: ../../extending/extending.rst:1002 +#: ../../extending/extending.rst:1027 msgid "" "Many functions that extract objects from other objects also transfer " "ownership with the reference, for instance :c:func:" @@ -1638,14 +1704,14 @@ msgid "" "list or dictionary." msgstr "" -#: ../../extending/extending.rst:1009 +#: ../../extending/extending.rst:1034 msgid "" "The function :c:func:`PyImport_AddModule` also returns a borrowed reference, " "even though it may actually create the object it returns: this is possible " "because an owned reference to the object is stored in ``sys.modules``." msgstr "" -#: ../../extending/extending.rst:1013 +#: ../../extending/extending.rst:1038 msgid "" "When you pass an object reference into another function, in general, the " "function borrows the reference from you --- if it needs to store it, it will " @@ -1656,7 +1722,7 @@ msgid "" "don't take over ownership --- they are \"normal.\")" msgstr "" -#: ../../extending/extending.rst:1021 +#: ../../extending/extending.rst:1046 msgid "" "When a C function is called from Python, it borrows references to its " "arguments from the caller. The caller owns a reference to the object, so " @@ -1665,18 +1731,18 @@ msgid "" "turned into an owned reference by calling :c:func:`Py_INCREF`." msgstr "" -#: ../../extending/extending.rst:1027 +#: ../../extending/extending.rst:1052 msgid "" "The object reference returned from a C function that is called from Python " "must be an owned reference --- ownership is transferred from the function to " "its caller." msgstr "" -#: ../../extending/extending.rst:1035 +#: ../../extending/extending.rst:1060 msgid "Thin Ice" msgstr "" -#: ../../extending/extending.rst:1037 +#: ../../extending/extending.rst:1062 msgid "" "There are a few situations where seemingly harmless use of a borrowed " "reference can lead to problems. These all have to do with implicit " @@ -1684,14 +1750,14 @@ msgid "" "dispose of it." msgstr "" -#: ../../extending/extending.rst:1041 +#: ../../extending/extending.rst:1066 msgid "" "The first and most important case to know about is using :c:func:`Py_DECREF` " "on an unrelated object while borrowing a reference to a list item. For " "instance::" msgstr "" -#: ../../extending/extending.rst:1044 +#: ../../extending/extending.rst:1069 msgid "" "void\n" "bug(PyObject *list)\n" @@ -1711,14 +1777,14 @@ msgstr "" " PyObject_Print(item, stdout, 0); /* BUG! */\n" "}" -#: ../../extending/extending.rst:1053 +#: ../../extending/extending.rst:1078 msgid "" "This function first borrows a reference to ``list[0]``, then replaces " "``list[1]`` with the value ``0``, and finally prints the borrowed reference. " "Looks harmless, right? But it's not!" msgstr "" -#: ../../extending/extending.rst:1057 +#: ../../extending/extending.rst:1082 msgid "" "Let's follow the control flow into :c:func:`PyList_SetItem`. The list owns " "references to all its items, so when item 1 is replaced, it has to dispose " @@ -1728,7 +1794,7 @@ msgid "" "count of 1, disposing of it will call its :meth:`!__del__` method." msgstr "" -#: ../../extending/extending.rst:1064 +#: ../../extending/extending.rst:1089 msgid "" "Since it is written in Python, the :meth:`!__del__` method can execute " "arbitrary Python code. Could it perhaps do something to invalidate the " @@ -1739,13 +1805,13 @@ msgid "" "associated with it, thereby invalidating ``item``." msgstr "" -#: ../../extending/extending.rst:1072 +#: ../../extending/extending.rst:1097 msgid "" "The solution, once you know the source of the problem, is easy: temporarily " "increment the reference count. The correct version of the function reads::" msgstr "" -#: ../../extending/extending.rst:1075 +#: ../../extending/extending.rst:1100 msgid "" "void\n" "no_bug(PyObject *list)\n" @@ -1769,14 +1835,14 @@ msgstr "" " Py_DECREF(item);\n" "}" -#: ../../extending/extending.rst:1086 +#: ../../extending/extending.rst:1111 msgid "" "This is a true story. An older version of Python contained variants of this " "bug and someone spent a considerable amount of time in a C debugger to " "figure out why his :meth:`!__del__` methods would fail..." msgstr "" -#: ../../extending/extending.rst:1090 +#: ../../extending/extending.rst:1115 msgid "" "The second case of problems with a borrowed reference is a variant involving " "threads. Normally, multiple threads in the Python interpreter can't get in " @@ -1789,7 +1855,7 @@ msgid "" "Obviously, the following function has the same problem as the previous one::" msgstr "" -#: ../../extending/extending.rst:1100 +#: ../../extending/extending.rst:1125 msgid "" "void\n" "bug(PyObject *list)\n" @@ -1802,11 +1868,11 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:1114 +#: ../../extending/extending.rst:1139 msgid "NULL Pointers" msgstr "NULL 指標" -#: ../../extending/extending.rst:1116 +#: ../../extending/extending.rst:1141 msgid "" "In general, functions that take object references as arguments do not expect " "you to pass them ``NULL`` pointers, and will dump core (or cause later core " @@ -1818,21 +1884,21 @@ msgid "" "more slowly." msgstr "" -#: ../../extending/extending.rst:1124 +#: ../../extending/extending.rst:1149 msgid "" "It is better to test for ``NULL`` only at the \"source:\" when a pointer " "that may be ``NULL`` is received, for example, from :c:func:`malloc` or from " "a function that may raise an exception." msgstr "" -#: ../../extending/extending.rst:1128 +#: ../../extending/extending.rst:1153 msgid "" "The macros :c:func:`Py_INCREF` and :c:func:`Py_DECREF` do not check for " "``NULL`` pointers --- however, their variants :c:func:`Py_XINCREF` and :c:" "func:`Py_XDECREF` do." msgstr "" -#: ../../extending/extending.rst:1132 +#: ../../extending/extending.rst:1157 msgid "" "The macros for checking for a particular object type (``Pytype_Check()``) " "don't check for ``NULL`` pointers --- again, there is much code that calls " @@ -1841,24 +1907,24 @@ msgid "" "variants with ``NULL`` checking." msgstr "" -#: ../../extending/extending.rst:1138 +#: ../../extending/extending.rst:1163 msgid "" "The C function calling mechanism guarantees that the argument list passed to " "C functions (``args`` in the examples) is never ``NULL`` --- in fact it " "guarantees that it is always a tuple [#]_." msgstr "" -#: ../../extending/extending.rst:1142 +#: ../../extending/extending.rst:1167 msgid "" "It is a severe error to ever let a ``NULL`` pointer \"escape\" to the Python " "user." msgstr "" -#: ../../extending/extending.rst:1153 +#: ../../extending/extending.rst:1178 msgid "Writing Extensions in C++" msgstr "" -#: ../../extending/extending.rst:1155 +#: ../../extending/extending.rst:1180 msgid "" "It is possible to write extension modules in C++. Some restrictions apply. " "If the main program (the Python interpreter) is compiled and linked by the C " @@ -1871,11 +1937,11 @@ msgid "" "(all recent C++ compilers define this symbol)." msgstr "" -#: ../../extending/extending.rst:1169 +#: ../../extending/extending.rst:1194 msgid "Providing a C API for an Extension Module" msgstr "" -#: ../../extending/extending.rst:1174 +#: ../../extending/extending.rst:1199 msgid "" "Many extension modules just provide new functions and types to be used from " "Python, but sometimes the code in an extension module can be useful for " @@ -1886,7 +1952,7 @@ msgid "" "functions for direct manipulation from other extension modules." msgstr "" -#: ../../extending/extending.rst:1182 +#: ../../extending/extending.rst:1207 msgid "" "At first sight this seems easy: just write the functions (without declaring " "them ``static``, of course), provide an appropriate header file, and " @@ -1902,7 +1968,7 @@ msgid "" "call might not have been loaded yet!" msgstr "" -#: ../../extending/extending.rst:1194 +#: ../../extending/extending.rst:1219 msgid "" "Portability therefore requires not to make any assumptions about symbol " "visibility. This means that all symbols in extension modules should be " @@ -1912,7 +1978,7 @@ msgid "" "accessible from other extension modules must be exported in a different way." msgstr "" -#: ../../extending/extending.rst:1201 +#: ../../extending/extending.rst:1226 msgid "" "Python provides a special mechanism to pass C-level information (pointers) " "from one extension module to another one: Capsules. A Capsule is a Python " @@ -1924,7 +1990,7 @@ msgid "" "the Capsule." msgstr "" -#: ../../extending/extending.rst:1209 +#: ../../extending/extending.rst:1234 msgid "" "There are many ways in which Capsules can be used to export the C API of an " "extension module. Each function could get its own Capsule, or all C API " @@ -1934,7 +2000,7 @@ msgid "" "client modules." msgstr "" -#: ../../extending/extending.rst:1215 +#: ../../extending/extending.rst:1240 msgid "" "Whichever method you choose, it's important to name your Capsules properly. " "The function :c:func:`PyCapsule_New` takes a name parameter (:c:expr:`const " @@ -1944,17 +2010,17 @@ msgid "" "from another." msgstr "" -#: ../../extending/extending.rst:1222 +#: ../../extending/extending.rst:1247 msgid "" "In particular, Capsules used to expose C APIs should be given a name " "following this convention::" msgstr "" -#: ../../extending/extending.rst:1225 +#: ../../extending/extending.rst:1250 msgid "modulename.attributename" msgstr "modulename.attributename" -#: ../../extending/extending.rst:1227 +#: ../../extending/extending.rst:1252 msgid "" "The convenience function :c:func:`PyCapsule_Import` makes it easy to load a " "C API provided via a Capsule, but only if the Capsule's name matches this " @@ -1962,7 +2028,7 @@ msgid "" "the Capsule they load contains the correct C API." msgstr "" -#: ../../extending/extending.rst:1232 +#: ../../extending/extending.rst:1257 msgid "" "The following example demonstrates an approach that puts most of the burden " "on the writer of the exporting module, which is appropriate for commonly " @@ -1973,7 +2039,7 @@ msgid "" "modules only have to call this macro before accessing the C API." msgstr "" -#: ../../extending/extending.rst:1240 +#: ../../extending/extending.rst:1265 msgid "" "The exporting module is a modification of the :mod:`!spam` module from " "section :ref:`extending-simpleexample`. The function :func:`!spam.system` " @@ -1984,13 +2050,13 @@ msgid "" "modules." msgstr "" -#: ../../extending/extending.rst:1247 +#: ../../extending/extending.rst:1272 msgid "" "The function :c:func:`!PySpam_System` is a plain C function, declared " "``static`` like everything else::" msgstr "" -#: ../../extending/extending.rst:1250 +#: ../../extending/extending.rst:1275 msgid "" "static int\n" "PySpam_System(const char *command)\n" @@ -2004,11 +2070,11 @@ msgstr "" " return system(command);\n" "}" -#: ../../extending/extending.rst:1256 +#: ../../extending/extending.rst:1281 msgid "The function :c:func:`!spam_system` is modified in a trivial way::" msgstr "" -#: ../../extending/extending.rst:1258 +#: ../../extending/extending.rst:1283 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -2034,19 +2100,19 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:1270 +#: ../../extending/extending.rst:1295 msgid "In the beginning of the module, right after the line ::" msgstr "" -#: ../../extending/extending.rst:1272 +#: ../../extending/extending.rst:1297 msgid "#include " msgstr "#include " -#: ../../extending/extending.rst:1274 +#: ../../extending/extending.rst:1299 msgid "two more lines must be added::" msgstr "" -#: ../../extending/extending.rst:1276 +#: ../../extending/extending.rst:1301 msgid "" "#define SPAM_MODULE\n" "#include \"spammodule.h\"" @@ -2054,7 +2120,7 @@ msgstr "" "#define SPAM_MODULE\n" "#include \"spammodule.h\"" -#: ../../extending/extending.rst:1279 +#: ../../extending/extending.rst:1304 msgid "" "The ``#define`` is used to tell the header file that it is being included in " "the exporting module, not a client module. Finally, the module's :c:data:" @@ -2062,7 +2128,7 @@ msgid "" "pointer array::" msgstr "" -#: ../../extending/extending.rst:1283 +#: ../../extending/extending.rst:1308 msgid "" "static int\n" "spam_module_exec(PyObject *m)\n" @@ -2085,19 +2151,19 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:1302 +#: ../../extending/extending.rst:1327 msgid "" "Note that ``PySpam_API`` is declared ``static``; otherwise the pointer array " "would disappear when :c:func:`!PyInit_spam` terminates!" msgstr "" -#: ../../extending/extending.rst:1305 +#: ../../extending/extending.rst:1330 msgid "" "The bulk of the work is in the header file :file:`spammodule.h`, which looks " "like this::" msgstr "" -#: ../../extending/extending.rst:1308 +#: ../../extending/extending.rst:1333 msgid "" "#ifndef Py_SPAMMODULE_H\n" "#define Py_SPAMMODULE_H\n" @@ -2149,14 +2215,14 @@ msgid "" "#endif /* !defined(Py_SPAMMODULE_H) */" msgstr "" -#: ../../extending/extending.rst:1356 +#: ../../extending/extending.rst:1381 msgid "" "All that a client module must do in order to have access to the function :c:" "func:`!PySpam_System` is to call the function (or rather macro) :c:func:`!" "import_spam` in its :c:data:`mod_exec ` function::" msgstr "" -#: ../../extending/extending.rst:1360 +#: ../../extending/extending.rst:1385 msgid "" "static int\n" "client_module_exec(PyObject *m)\n" @@ -2169,14 +2235,14 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:1370 +#: ../../extending/extending.rst:1395 msgid "" "The main disadvantage of this approach is that the file :file:`spammodule.h` " "is rather complicated. However, the basic structure is the same for each " "function that is exported, so it has to be learned only once." msgstr "" -#: ../../extending/extending.rst:1374 +#: ../../extending/extending.rst:1399 msgid "" "Finally it should be mentioned that Capsules offer additional functionality, " "which is especially useful for memory allocation and deallocation of the " @@ -2186,51 +2252,67 @@ msgid "" "in the Python source code distribution)." msgstr "" -#: ../../extending/extending.rst:1382 +#: ../../extending/extending.rst:1407 msgid "Footnotes" msgstr "註腳" -#: ../../extending/extending.rst:1383 +#: ../../extending/extending.rst:1408 msgid "" "An interface for this function already exists in the standard module :mod:" "`os` --- it was chosen as a simple and straightforward example." msgstr "" -#: ../../extending/extending.rst:1386 +#: ../../extending/extending.rst:1411 msgid "" "The metaphor of \"borrowing\" a reference is not completely correct: the " "owner still has a copy of the reference." msgstr "" -#: ../../extending/extending.rst:1389 +#: ../../extending/extending.rst:1414 msgid "" "Checking that the reference count is at least 1 **does not work** --- the " "reference count itself could be in freed memory and may thus be reused for " "another object!" msgstr "" -#: ../../extending/extending.rst:1393 +#: ../../extending/extending.rst:1418 msgid "" "These guarantees don't hold when you use the \"old\" style calling " "convention --- this is still found in much existing code." msgstr "" -#: ../../extending/extending.rst:568 +#: ../../extending/extending.rst:593 msgid "PyObject_CallObject (C function)" msgstr "PyObject_CallObject(C 函式)" -#: ../../extending/extending.rst:659 +#: ../../extending/extending.rst:684 msgid "PyArg_ParseTuple (C function)" msgstr "PyArg_ParseTuple(C 函式)" -#: ../../extending/extending.rst:751 +#: ../../extending/extending.rst:776 msgid "PyArg_ParseTupleAndKeywords (C function)" msgstr "PyArg_ParseTupleAndKeywords(C 函式)" -#: ../../extending/extending.rst:772 +#: ../../extending/extending.rst:797 msgid "Philbrick, Geoff" msgstr "Philbrick, Geoff" +#~ msgid "" +#~ "All user-visible symbols defined by :file:`Python.h` have a prefix of " +#~ "``Py`` or ``PY``, except those defined in standard header files. For " +#~ "convenience, and since they are used extensively by the Python " +#~ "interpreter, ``\"Python.h\"`` includes a few standard header files: " +#~ "````, ````, ````, and ````. If the " +#~ "latter header file does not exist on your system, it declares the " +#~ "functions :c:func:`malloc`, :c:func:`free` and :c:func:`realloc` directly." +#~ msgstr "" +#~ "除了那些在標準標頭檔中定義的符號以外,所有由 :file:`Python.h` 定義的使用者" +#~ "可見符號 (user-visible symbols) 的前綴都是 ``Py`` 或 ``PY``。為了方便,也" +#~ "因為 Python 直譯器的大量使用,``\"Python.h\"`` 也引入了一些標準的標頭檔:" +#~ "````、````、```` 和 ````。如果 " +#~ "```` 在你的系統上不存在,它會直接宣告 :c:func:`malloc`、:c:func:" +#~ "`free` 和 :c:func:`realloc` 函式。" + #~ msgid "" #~ "and initialize it in your module's initialization function (:c:func:`!" #~ "PyInit_spam`) with an exception object::" diff --git a/glossary.po b/glossary.po index 18ffbb20e3..9002348c19 100644 --- a/glossary.po +++ b/glossary.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-13 11:32+0000\n" +"POT-Creation-Date: 2025-08-06 00:17+0000\n" "PO-Revision-Date: 2023-07-02 22:47+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -924,10 +924,22 @@ msgstr "" "風格。" #: ../../glossary.rst:404 +#, fuzzy +msgid "dunder" +msgstr "finder(尋檢器)" + +#: ../../glossary.rst:406 +msgid "" +"An informal short-hand for \"double underscore\", used when talking about a :" +"term:`special method`. For example, ``__init__`` is often pronounced " +"\"dunder init\"." +msgstr "" + +#: ../../glossary.rst:409 msgid "EAFP" msgstr "EAFP" -#: ../../glossary.rst:406 +#: ../../glossary.rst:411 msgid "" "Easier to ask for forgiveness than permission. This common Python coding " "style assumes the existence of valid keys or attributes and catches " @@ -942,11 +954,11 @@ msgstr "" "keyword:`except` 陳述式。該技術與許多其他語言(例如 C)常見的 :term:`LBYL` 風" "格形成了對比。" -#: ../../glossary.rst:412 +#: ../../glossary.rst:417 msgid "expression" msgstr "expression(運算式)" -#: ../../glossary.rst:414 +#: ../../glossary.rst:419 msgid "" "A piece of syntax which can be evaluated to some value. In other words, an " "expression is an accumulation of expression elements like literals, names, " @@ -962,11 +974,11 @@ msgstr "" "(陳述式)不能被用作運算式,例如 :keyword:`while`。賦值 (assignment) 也是陳述" "式,而不是運算式。" -#: ../../glossary.rst:421 +#: ../../glossary.rst:426 msgid "extension module" msgstr "extension module(擴充模組)" -#: ../../glossary.rst:423 +#: ../../glossary.rst:428 msgid "" "A module written in C or C++, using Python's C API to interact with the core " "and with user code." @@ -974,11 +986,11 @@ msgstr "" "一個以 C 或 C++ 編寫的模組,它使用 Python 的 C API 來與核心及使用者程式碼進行" "互動。" -#: ../../glossary.rst:425 +#: ../../glossary.rst:430 msgid "f-string" msgstr "f-string(f 字串)" -#: ../../glossary.rst:427 +#: ../../glossary.rst:432 msgid "" "String literals prefixed with ``'f'`` or ``'F'`` are commonly called \"f-" "strings\" which is short for :ref:`formatted string literals `. " @@ -987,11 +999,11 @@ msgstr "" "以 ``'f'`` 或 ``'F'`` 為前綴的字串文本通常被稱為「f 字串」,它是\\ :ref:`格式" "化的字串文本 `\\ 的縮寫。另請參閱 :pep:`498`。" -#: ../../glossary.rst:430 +#: ../../glossary.rst:435 msgid "file object" msgstr "file object(檔案物件)" -#: ../../glossary.rst:432 +#: ../../glossary.rst:437 msgid "" "An object exposing a file-oriented API (with methods such as :meth:`!read` " "or :meth:`!write`) to an underlying resource. Depending on the way it was " @@ -1006,7 +1018,7 @@ msgstr "" "衝區、socket(插座)、管線 (pipe) 等)的存取。檔案物件也被稱為\\ :dfn:`類檔案" "物件 (file-like object)` 或\\ :dfn:`串流 (stream)`。" -#: ../../glossary.rst:440 +#: ../../glossary.rst:445 msgid "" "There are actually three categories of file objects: raw :term:`binary files " "`, buffered :term:`binary files ` and :term:`text " @@ -1018,19 +1030,19 @@ msgstr "" "term:`二進位檔案 `\\ 和\\ :term:`文字檔案 `。它們的介" "面在 :mod:`io` 模組中被定義。建立檔案物件的標準方法是使用 :func:`open` 函式。" -#: ../../glossary.rst:445 +#: ../../glossary.rst:450 msgid "file-like object" msgstr "file-like object(類檔案物件)" -#: ../../glossary.rst:447 +#: ../../glossary.rst:452 msgid "A synonym for :term:`file object`." msgstr ":term:`file object`\\ (檔案物件)的同義字。" -#: ../../glossary.rst:448 +#: ../../glossary.rst:453 msgid "filesystem encoding and error handler" msgstr "filesystem encoding and error handler(檔案系統編碼和錯誤處理函式)" -#: ../../glossary.rst:450 +#: ../../glossary.rst:455 msgid "" "Encoding and error handler used by Python to decode bytes from the operating " "system and encode Unicode to the operating system." @@ -1038,7 +1050,7 @@ msgstr "" "Python 所使用的一種編碼和錯誤處理函式,用來解碼來自作業系統的位元組,以及將 " "Unicode 編碼到作業系統。" -#: ../../glossary.rst:453 +#: ../../glossary.rst:458 msgid "" "The filesystem encoding must guarantee to successfully decode all bytes " "below 128. If the file system encoding fails to provide this guarantee, API " @@ -1047,7 +1059,7 @@ msgstr "" "檔案系統編碼必須保證能成功解碼所有小於 128 的位元組。如果檔案系統編碼無法提供" "此保證,則 API 函式會引發 :exc:`UnicodeError`。" -#: ../../glossary.rst:457 +#: ../../glossary.rst:462 msgid "" "The :func:`sys.getfilesystemencoding` and :func:`sys." "getfilesystemencodeerrors` functions can be used to get the filesystem " @@ -1056,7 +1068,7 @@ msgstr "" ":func:`sys.getfilesystemencoding` 和 :func:`sys.getfilesystemencodeerrors` 函" "式可用於取得檔案系統編碼和錯誤處理函式。" -#: ../../glossary.rst:461 +#: ../../glossary.rst:466 msgid "" "The :term:`filesystem encoding and error handler` are configured at Python " "startup by the :c:func:`PyConfig_Read` function: see :c:member:`~PyConfig." @@ -1068,22 +1080,22 @@ msgstr "" "member:`~PyConfig.filesystem_encoding`,以及 :c:type:`PyConfig` 的成員 :c:" "member:`~PyConfig.filesystem_errors`。" -#: ../../glossary.rst:466 +#: ../../glossary.rst:471 msgid "See also the :term:`locale encoding`." msgstr "另請參閱 :term:`locale encoding`\\ (區域編碼)。" -#: ../../glossary.rst:467 +#: ../../glossary.rst:472 msgid "finder" msgstr "finder(尋檢器)" -#: ../../glossary.rst:469 +#: ../../glossary.rst:474 msgid "" "An object that tries to find the :term:`loader` for a module that is being " "imported." msgstr "" "一個物件,它會嘗試為正在被 import 的模組尋找 :term:`loader`\\ (載入器)。" -#: ../../glossary.rst:472 +#: ../../glossary.rst:477 msgid "" "There are two types of finder: :term:`meta path finders ` " "for use with :data:`sys.meta_path`, and :term:`path entry finders ` 會使用 :data:`sys.meta_path`,而\\ :term:`路徑項目尋檢器 (path " "entry finder) ` 會使用 :data:`sys.path_hooks`。" -#: ../../glossary.rst:476 +#: ../../glossary.rst:481 msgid "" "See :ref:`finders-and-loaders` and :mod:`importlib` for much more detail." msgstr "請參閱 :ref:`finders-and-loaders` 和 :mod:`importlib` 以了解更多細節。" -#: ../../glossary.rst:477 +#: ../../glossary.rst:482 msgid "floor division" msgstr "floor division(向下取整除法)" -#: ../../glossary.rst:479 +#: ../../glossary.rst:484 msgid "" "Mathematical division that rounds down to nearest integer. The floor " "division operator is ``//``. For example, the expression ``11 // 4`` " @@ -1115,11 +1127,11 @@ msgstr "" "``2.75`` 不同。請注意,``(-11) // 4`` 的結果是 ``-3``,因為是 ``-2.75`` 被\\ " "*向下*\\ 無條件捨去。請參閱 :pep:`238`。" -#: ../../glossary.rst:484 +#: ../../glossary.rst:489 msgid "free threading" msgstr "free threading(自由執行緒)" -#: ../../glossary.rst:486 +#: ../../glossary.rst:491 msgid "" "A threading model where multiple threads can run Python bytecode " "simultaneously within the same interpreter. This is in contrast to the :" @@ -1130,11 +1142,11 @@ msgstr "" "\\ :term:`全域直譯器鎖 `\\ 形成對比,後者一次只允許" "一個執行緒執行 Python 位元組碼。請參閱 :pep:`703`。" -#: ../../glossary.rst:490 +#: ../../glossary.rst:495 msgid "free variable" msgstr "free variable(自由變數)" -#: ../../glossary.rst:492 +#: ../../glossary.rst:497 msgid "" "Formally, as defined in the :ref:`language execution model `, a " "free variable is any variable used in a namespace which is not a local " @@ -1144,11 +1156,11 @@ msgid "" "variable`." msgstr "" -#: ../../glossary.rst:497 +#: ../../glossary.rst:502 msgid "function" msgstr "function(函式)" -#: ../../glossary.rst:499 +#: ../../glossary.rst:504 msgid "" "A series of statements which returns some value to a caller. It can also be " "passed zero or more :term:`arguments ` which may be used in the " @@ -1160,15 +1172,15 @@ msgstr "" "`parameter`\\ (參數)、:term:`method`\\ (方法),以及\\ :ref:`function`\\ " "章節。" -#: ../../glossary.rst:503 +#: ../../glossary.rst:508 msgid "function annotation" msgstr "function annotation(函式註釋)" -#: ../../glossary.rst:505 +#: ../../glossary.rst:510 msgid "An :term:`annotation` of a function parameter or return value." msgstr "函式參數或回傳值的一個 :term:`annotation`\\ (註釋)。" -#: ../../glossary.rst:507 +#: ../../glossary.rst:512 msgid "" "Function annotations are usually used for :term:`type hints `: " "for example, this function is expected to take two :class:`int` arguments " @@ -1177,7 +1189,7 @@ msgstr "" "函式註釋通常被使用於\\ :term:`型別提示 `:例如,這個函式預期會得到" "兩個 :class:`int` 引數,並會有一個 :class:`int` 回傳值: ::" -#: ../../glossary.rst:512 +#: ../../glossary.rst:517 msgid "" "def sum_two_numbers(a: int, b: int) -> int:\n" " return a + b" @@ -1185,11 +1197,11 @@ msgstr "" "def sum_two_numbers(a: int, b: int) -> int:\n" " return a + b" -#: ../../glossary.rst:515 +#: ../../glossary.rst:520 msgid "Function annotation syntax is explained in section :ref:`function`." msgstr "函式註釋的語法在\\ :ref:`function`\\ 章節有詳細解釋。" -#: ../../glossary.rst:517 +#: ../../glossary.rst:522 msgid "" "See :term:`variable annotation` and :pep:`484`, which describe this " "functionality. Also see :ref:`annotations-howto` for best practices on " @@ -1198,11 +1210,11 @@ msgstr "" "請參閱 :term:`variable annotation` 和 :pep:`484`,皆有此功能的描述。關於註釋" "的最佳實踐方法,另請參閱 :ref:`annotations-howto`。" -#: ../../glossary.rst:521 +#: ../../glossary.rst:526 msgid "__future__" msgstr "__future__" -#: ../../glossary.rst:523 +#: ../../glossary.rst:528 msgid "" "A :ref:`future statement `, ``from __future__ import ``, " "directs the compiler to compile the current module using syntax or semantics " @@ -1218,7 +1230,7 @@ msgstr "" "import 此模組並對其變數求值,你可以看見一個新的功能是何時首次被新增到此語言" "中,以及它何時將會(或已經)成為預設的功能: ::" -#: ../../glossary.rst:531 +#: ../../glossary.rst:536 msgid "" ">>> import __future__\n" ">>> __future__.division\n" @@ -1228,11 +1240,11 @@ msgstr "" ">>> __future__.division\n" "_Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)" -#: ../../glossary.rst:534 +#: ../../glossary.rst:539 msgid "garbage collection" msgstr "garbage collection(垃圾回收)" -#: ../../glossary.rst:536 +#: ../../glossary.rst:541 msgid "" "The process of freeing memory when it is not used anymore. Python performs " "garbage collection via reference counting and a cyclic garbage collector " @@ -1244,11 +1256,11 @@ msgstr "" "垃圾回收器 (cyclic garbage collector) 來完成。垃圾回收器可以使用 :mod:`gc` 模" "組對其進行控制。" -#: ../../glossary.rst:541 ../../glossary.rst:542 +#: ../../glossary.rst:546 ../../glossary.rst:547 msgid "generator" msgstr "generator(產生器)" -#: ../../glossary.rst:544 +#: ../../glossary.rst:549 msgid "" "A function which returns a :term:`generator iterator`. It looks like a " "normal function except that it contains :keyword:`yield` expressions for " @@ -1259,7 +1271,7 @@ msgstr "" "個正常的函式,但不同的是它包含了 :keyword:`yield` 運算式,能產生一系列的值," "這些值可用於 for 迴圈,或是以 :func:`next` 函式,每次檢索其中的一個值。" -#: ../../glossary.rst:549 +#: ../../glossary.rst:554 msgid "" "Usually refers to a generator function, but may refer to a *generator " "iterator* in some contexts. In cases where the intended meaning isn't " @@ -1268,15 +1280,15 @@ msgstr "" "這個術語通常用來表示一個產生器函式,但在某些情境中,也可能是表示\\ *產生器疊" "代器*。萬一想表達的意思不夠清楚,那就使用完整的術語,以避免歧義。" -#: ../../glossary.rst:552 +#: ../../glossary.rst:557 msgid "generator iterator" msgstr "generator iterator(產生器疊代器)" -#: ../../glossary.rst:554 +#: ../../glossary.rst:559 msgid "An object created by a :term:`generator` function." msgstr "一個由 :term:`generator`\\ (產生器)函式所建立的物件。" -#: ../../glossary.rst:556 +#: ../../glossary.rst:561 msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " "execution state (including local variables and pending try-statements). " @@ -1287,11 +1299,11 @@ msgstr "" "try 陳述式)。當\\ *產生器疊代器*\\ 回復時,它會從停止的地方繼續執行(與那些" "每次呼叫時都要重新開始的函式有所不同)。" -#: ../../glossary.rst:562 ../../glossary.rst:563 +#: ../../glossary.rst:567 ../../glossary.rst:568 msgid "generator expression" msgstr "generator expression(產生器運算式)" -#: ../../glossary.rst:565 +#: ../../glossary.rst:570 msgid "" "An :term:`expression` that returns an :term:`iterator`. It looks like a " "normal expression followed by a :keyword:`!for` clause defining a loop " @@ -1303,7 +1315,7 @@ msgstr "" "變數、範圍以及一個選擇性的 :keyword:`!if` 子句。該組合運算式會為外層函式產生" "多個值: ::" -#: ../../glossary.rst:570 +#: ../../glossary.rst:575 msgid "" ">>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81\n" "285" @@ -1311,11 +1323,11 @@ msgstr "" ">>> sum(i*i for i in range(10)) # 平方之和 0, 1, 4, ... 81\n" "285" -#: ../../glossary.rst:572 +#: ../../glossary.rst:577 msgid "generic function" msgstr "generic function(泛型函式)" -#: ../../glossary.rst:574 +#: ../../glossary.rst:579 msgid "" "A function composed of multiple functions implementing the same operation " "for different types. Which implementation should be used during a call is " @@ -1324,7 +1336,7 @@ msgstr "" "一個由多個函式組成的函式,該函式會對不同的型別實作相同的運算。呼叫期間應該使" "用哪種實作,是由調度演算法 (dispatch algorithm) 來決定。" -#: ../../glossary.rst:578 +#: ../../glossary.rst:583 msgid "" "See also the :term:`single dispatch` glossary entry, the :func:`functools." "singledispatch` decorator, and :pep:`443`." @@ -1332,11 +1344,11 @@ msgstr "" "另請參閱 :term:`single dispatch`\\ (單一調度)術語表條目、:func:`functools." "singledispatch` 裝飾器和 :pep:`443`。" -#: ../../glossary.rst:580 +#: ../../glossary.rst:585 msgid "generic type" msgstr "generic type(泛型型別)" -#: ../../glossary.rst:582 +#: ../../glossary.rst:587 msgid "" "A :term:`type` that can be parameterized; typically a :ref:`container " "class` such as :class:`list` or :class:`dict`. Used for :" @@ -1346,7 +1358,7 @@ msgstr "" "`容器型別 `,像是 :class:`list` 和 :class:`dict`。它被用於" "\\ :term:`型別提示 `\\ 和\\ :term:`註釋 `。" -#: ../../glossary.rst:587 +#: ../../glossary.rst:592 msgid "" "For more details, see :ref:`generic alias types`, :pep:" "`483`, :pep:`484`, :pep:`585`, and the :mod:`typing` module." @@ -1354,19 +1366,19 @@ msgstr "" "詳情請參閱\\ :ref:`泛型別名型別 `、:pep:`483`、:pep:" "`484`、:pep:`585` 和 :mod:`typing` 模組。" -#: ../../glossary.rst:589 +#: ../../glossary.rst:594 msgid "GIL" msgstr "GIL" -#: ../../glossary.rst:591 +#: ../../glossary.rst:596 msgid "See :term:`global interpreter lock`." msgstr "請參閱 :term:`global interpreter lock`\\ (全域直譯器鎖)。" -#: ../../glossary.rst:592 +#: ../../glossary.rst:597 msgid "global interpreter lock" msgstr "global interpreter lock(全域直譯器鎖)" -#: ../../glossary.rst:594 +#: ../../glossary.rst:599 msgid "" "The mechanism used by the :term:`CPython` interpreter to assure that only " "one thread executes Python :term:`bytecode` at a time. This simplifies the " @@ -1383,7 +1395,7 @@ msgstr "" "(multi-threaded),但代價是會犧牲掉多處理器的機器能夠提供的一大部分平行性 " "(parallelism)。" -#: ../../glossary.rst:603 +#: ../../glossary.rst:608 msgid "" "However, some extension modules, either standard or third-party, are " "designed so as to release the GIL when doing computationally intensive tasks " @@ -1394,7 +1406,7 @@ msgstr "" "計算密集 (computationally intensive) 的任務時,可以解除 GIL。另外,在執行 I/" "O 時,GIL 總是會被解除。" -#: ../../glossary.rst:608 +#: ../../glossary.rst:613 msgid "" "As of Python 3.13, the GIL can be disabled using the :option:`--disable-gil` " "build configuration. After building Python with this option, code must be " @@ -1409,11 +1421,11 @@ msgstr "" "多執行緒應用程式的效能,並使多核心 CPU 的高效使用變得更加容易。有關更多詳細資" "訊,請參閱 :pep:`703`。" -#: ../../glossary.rst:614 +#: ../../glossary.rst:619 msgid "hash-based pyc" msgstr "hash-based pyc(雜湊架構的 pyc)" -#: ../../glossary.rst:616 +#: ../../glossary.rst:621 msgid "" "A bytecode cache file that uses the hash rather than the last-modified time " "of the corresponding source file to determine its validity. See :ref:`pyc-" @@ -1422,11 +1434,11 @@ msgstr "" "一個位元組碼 (bytecode) 暫存檔,它使用雜湊值而不是對應原始檔案的最後修改時" "間,來確定其有效性。請參閱\\ :ref:`pyc-invalidation`。" -#: ../../glossary.rst:619 +#: ../../glossary.rst:624 msgid "hashable" msgstr "hashable(可雜湊的)" -#: ../../glossary.rst:621 +#: ../../glossary.rst:626 msgid "" "An object is *hashable* if it has a hash value which never changes during " "its lifetime (it needs a :meth:`~object.__hash__` method), and can be " @@ -1438,7 +1450,7 @@ msgstr "" "`~object.__eq__` method),那麼它就是一個\\ *可雜湊*\\ 物件。比較結果為相等的" "多個可雜湊物件,它們必須擁有相同的雜湊值。" -#: ../../glossary.rst:627 +#: ../../glossary.rst:632 msgid "" "Hashability makes an object usable as a dictionary key and a set member, " "because these data structures use the hash value internally." @@ -1446,7 +1458,7 @@ msgstr "" "可雜湊性 (hashability) 使一個物件可用作 dictionary(字典)的鍵和 set(集合)" "的成員,因為這些資料結構都在其內部使用了雜湊值。" -#: ../../glossary.rst:630 +#: ../../glossary.rst:635 msgid "" "Most of Python's immutable built-in objects are hashable; mutable containers " "(such as lists or dictionaries) are not; immutable containers (such as " @@ -1461,11 +1473,11 @@ msgstr "" "則這些物件會被預設為可雜湊的。它們在互相比較時都是不相等的(除非它們與自己比" "較),而它們的雜湊值則是衍生自它們的 :func:`id`。" -#: ../../glossary.rst:637 +#: ../../glossary.rst:642 msgid "IDLE" msgstr "IDLE" -#: ../../glossary.rst:639 +#: ../../glossary.rst:644 msgid "" "An Integrated Development and Learning Environment for Python. :ref:`idle` " "is a basic editor and interpreter environment which ships with the standard " @@ -1475,17 +1487,17 @@ msgstr "" "境)。:ref:`idle` 是一個基本的編輯器和直譯器環境,它和 Python 的標準發行版本" "一起被提供。" -#: ../../glossary.rst:642 +#: ../../glossary.rst:647 msgid "immortal" msgstr "immortal(不滅)" -#: ../../glossary.rst:644 +#: ../../glossary.rst:649 msgid "" "*Immortal objects* are a CPython implementation detail introduced in :pep:" "`683`." msgstr "*不滅物件 (Immortal objects)* 是 :pep:`683` 引入的 CPython 實作細節。" -#: ../../glossary.rst:647 +#: ../../glossary.rst:652 msgid "" "If an object is immortal, its :term:`reference count` is never modified, and " "therefore it is never deallocated while the interpreter is running. For " @@ -1495,11 +1507,11 @@ msgstr "" "修改,因此在直譯器運行時它永遠不會被釋放。例如,:const:`True` 和 :const:" "`None` 在 CPython 中是不滅的。" -#: ../../glossary.rst:650 +#: ../../glossary.rst:655 msgid "immutable" msgstr "immutable(不可變物件)" -#: ../../glossary.rst:652 +#: ../../glossary.rst:657 msgid "" "An object with a fixed value. Immutable objects include numbers, strings " "and tuples. Such an object cannot be altered. A new object has to be " @@ -1511,11 +1523,11 @@ msgstr "" "能被改變的。如果一個不同的值必須被儲存,則必須建立一個新的物件。它們在需要恆" "定雜湊值的地方,扮演重要的角色,例如 dictionary(字典)中的一個鍵。" -#: ../../glossary.rst:657 +#: ../../glossary.rst:662 msgid "import path" msgstr "import path(引入路徑)" -#: ../../glossary.rst:659 +#: ../../glossary.rst:664 msgid "" "A list of locations (or :term:`path entries `) that are searched " "by the :term:`path based finder` for modules to import. During import, this " @@ -1527,11 +1539,11 @@ msgstr "" "的位置。在 import 期間,此位置列表通常是來自 :data:`sys.path`,但對於子套件 " "(subpackage) 而言,它也可能是來自父套件的 ``__path__`` 屬性。" -#: ../../glossary.rst:664 +#: ../../glossary.rst:669 msgid "importing" msgstr "importing(引入)" -#: ../../glossary.rst:666 +#: ../../glossary.rst:671 msgid "" "The process by which Python code in one module is made available to Python " "code in another module." @@ -1539,11 +1551,11 @@ msgstr "" "一個過程。一個模組中的 Python 程式碼可以透過此過程,被另一個模組中的 Python " "程式碼使用。" -#: ../../glossary.rst:668 +#: ../../glossary.rst:673 msgid "importer" msgstr "importer(引入器)" -#: ../../glossary.rst:670 +#: ../../glossary.rst:675 msgid "" "An object that both finds and loads a module; both a :term:`finder` and :" "term:`loader` object." @@ -1551,11 +1563,11 @@ msgstr "" "一個能夠尋找及載入模組的物件;它既是 :term:`finder`\\ (尋檢器)也是 :term:" "`loader`\\ (載入器)物件。" -#: ../../glossary.rst:672 +#: ../../glossary.rst:677 msgid "interactive" msgstr "interactive(互動的)" -#: ../../glossary.rst:674 +#: ../../glossary.rst:679 msgid "" "Python has an interactive interpreter which means you can enter statements " "and expressions at the interpreter prompt, immediately execute them and see " @@ -1569,11 +1581,11 @@ msgstr "" "從你的電腦的主選單選擇它)。這是測試新想法或檢查模組和包的非常強大的方法(請" "記住help(x))。更多互動式模式相關資訊請見 :ref:`tut-interac`。" -#: ../../glossary.rst:681 +#: ../../glossary.rst:686 msgid "interpreted" msgstr "interpreted(直譯的)" -#: ../../glossary.rst:683 +#: ../../glossary.rst:688 msgid "" "Python is an interpreted language, as opposed to a compiled one, though the " "distinction can be blurry because of the presence of the bytecode compiler. " @@ -1587,11 +1599,11 @@ msgstr "" "一個執行檔,然後再執行它。直譯語言通常比編譯語言有更短的開發/除錯週期,不過" "它們的程式通常也運行得較慢。另請參閱 :term:`interactive`\\ (互動的)。" -#: ../../glossary.rst:690 +#: ../../glossary.rst:695 msgid "interpreter shutdown" msgstr "interpreter shutdown(直譯器關閉)" -#: ../../glossary.rst:692 +#: ../../glossary.rst:697 msgid "" "When asked to shut down, the Python interpreter enters a special phase where " "it gradually releases all allocated resources, such as modules and various " @@ -1609,18 +1621,18 @@ msgstr "" "段被執行的程式碼會遇到各種例外,因為它所依賴的資源可能不再有作用了(常見的例" "子是函式庫模組或是警告機制)。" -#: ../../glossary.rst:701 +#: ../../glossary.rst:706 msgid "" "The main reason for interpreter shutdown is that the ``__main__`` module or " "the script being run has finished executing." msgstr "" "直譯器關閉的主要原因,是 ``__main__`` 模組或正被運行的腳本已經執行完成。" -#: ../../glossary.rst:703 +#: ../../glossary.rst:708 msgid "iterable" msgstr "iterable(可疊代物件)" -#: ../../glossary.rst:705 +#: ../../glossary.rst:710 msgid "" "An object capable of returning its members one at a time. Examples of " "iterables include all sequence types (such as :class:`list`, :class:`str`, " @@ -1635,7 +1647,7 @@ msgstr "" "只要那些 class 有實作 :term:`sequence`\\ (序列)語意的 :meth:`~object." "__iter__` 或是 :meth:`~object.__getitem__` method,該物件就是可疊代物件。" -#: ../../glossary.rst:713 +#: ../../glossary.rst:718 msgid "" "Iterables can be used in a :keyword:`for` loop and in many other places " "where a sequence is needed (:func:`zip`, :func:`map`, ...). When an " @@ -1655,11 +1667,11 @@ msgstr "" "數,用於在迴圈期間保有該疊代器。另請參閱 :term:`iterator`\\ (疊代器)、:" "term:`sequence`\\ (序列)和 :term:`generator`\\ (產生器)。" -#: ../../glossary.rst:723 +#: ../../glossary.rst:728 msgid "iterator" msgstr "iterator(疊代器)" -#: ../../glossary.rst:725 +#: ../../glossary.rst:730 msgid "" "An object representing a stream of data. Repeated calls to the iterator's :" "meth:`~iterator.__next__` method (or passing it to the built-in function :" @@ -1688,11 +1700,11 @@ msgstr "" "此事(多遍疊代)時,只會回傳在前一遍疊代中被用過的、同一個已被用盡的疊代器物" "件,使其看起來就像一個空的容器。" -#: ../../glossary.rst:740 +#: ../../glossary.rst:745 msgid "More information can be found in :ref:`typeiter`." msgstr "在\\ :ref:`typeiter`\\ 文中可以找到更多資訊。" -#: ../../glossary.rst:744 +#: ../../glossary.rst:749 msgid "" "CPython does not consistently apply the requirement that an iterator define :" "meth:`~iterator.__iter__`. And also please note that the free-threading " @@ -1702,11 +1714,11 @@ msgstr "" "__iter__`\\ 」這個規定。另請注意,free-threading(自由執行緒)CPython 不保證" "疊代器操作的執行緒安全。" -#: ../../glossary.rst:749 +#: ../../glossary.rst:754 msgid "key function" msgstr "key function(鍵函式)" -#: ../../glossary.rst:751 +#: ../../glossary.rst:756 msgid "" "A key function or collation function is a callable that returns a value used " "for sorting or ordering. For example, :func:`locale.strxfrm` is used to " @@ -1716,7 +1728,7 @@ msgstr "" "一個用於排序 (sorting) 或定序 (ordering) 的值。例如,:func:`locale.strxfrm` " "被用來產生一個了解區域特定排序慣例的排序鍵。" -#: ../../glossary.rst:756 +#: ../../glossary.rst:761 msgid "" "A number of tools in Python accept key functions to control how elements are " "ordered or grouped. They include :func:`min`, :func:`max`, :func:`sorted`, :" @@ -1728,7 +1740,7 @@ msgstr "" "merge`、:func:`heapq.nsmallest`、:func:`heapq.nlargest` 和 :func:`itertools." "groupby`。" -#: ../../glossary.rst:762 +#: ../../glossary.rst:767 msgid "" "There are several ways to create a key function. For example. the :meth:" "`str.lower` method can serve as a key function for case insensitive sorts. " @@ -1745,19 +1757,19 @@ msgstr "" "式 (constructor)。關於如何建立和使用鍵函式的範例,請參閱\\ :ref:`如何排序 " "`。" -#: ../../glossary.rst:769 +#: ../../glossary.rst:774 msgid "keyword argument" msgstr "keyword argument(關鍵字引數)" -#: ../../glossary.rst:771 ../../glossary.rst:1086 +#: ../../glossary.rst:776 ../../glossary.rst:1091 msgid "See :term:`argument`." msgstr "請參閱 :term:`argument`\\ (引數)。" -#: ../../glossary.rst:772 +#: ../../glossary.rst:777 msgid "lambda" msgstr "lambda" -#: ../../glossary.rst:774 +#: ../../glossary.rst:779 msgid "" "An anonymous inline function consisting of a single :term:`expression` which " "is evaluated when the function is called. The syntax to create a lambda " @@ -1767,11 +1779,11 @@ msgstr "" "function),於該函式被呼叫時求值。建立 lambda 函式的語法是 ``lambda " "[parameters]: expression``" -#: ../../glossary.rst:777 +#: ../../glossary.rst:782 msgid "LBYL" msgstr "LBYL" -#: ../../glossary.rst:779 +#: ../../glossary.rst:784 msgid "" "Look before you leap. This coding style explicitly tests for pre-conditions " "before making calls or lookups. This style contrasts with the :term:`EAFP` " @@ -1782,7 +1794,7 @@ msgstr "" "地測試先決條件。這種風格與 :term:`EAFP` 方式形成對比,且它的特色是會有許多 :" "keyword:`if` 陳述式的存在。" -#: ../../glossary.rst:784 +#: ../../glossary.rst:789 msgid "" "In a multi-threaded environment, the LBYL approach can risk introducing a " "race condition between \"the looking\" and \"the leaping\". For example, " @@ -1796,19 +1808,19 @@ msgstr "" "了 *key*,則該程式碼就會失效。這個問題可以用鎖 (lock) 或使用 EAFP 編碼方式來" "解決。" -#: ../../glossary.rst:789 +#: ../../glossary.rst:794 msgid "lexical analyzer" msgstr "lexical analyzer(詞法分析器)" -#: ../../glossary.rst:792 +#: ../../glossary.rst:797 msgid "Formal name for the *tokenizer*; see :term:`token`." msgstr "tokenizer 的正式名稱;請參閱 :term:`token`。" -#: ../../glossary.rst:793 +#: ../../glossary.rst:798 msgid "list" msgstr "list(串列)" -#: ../../glossary.rst:795 +#: ../../glossary.rst:800 msgid "" "A built-in Python :term:`sequence`. Despite its name it is more akin to an " "array in other languages than to a linked list since access to elements is " @@ -1818,11 +1830,11 @@ msgstr "" "似其他語言中的一個陣列 (array) 而較不像一個鏈結串列 (linked list),因為存取元" "素的時間複雜度是 *O*\\ (1)。" -#: ../../glossary.rst:798 +#: ../../glossary.rst:803 msgid "list comprehension" msgstr "list comprehension(串列綜合運算)" -#: ../../glossary.rst:800 +#: ../../glossary.rst:805 msgid "" "A compact way to process all or part of the elements in a sequence and " "return a list with the results. ``result = ['{:#04x}'.format(x) for x in " @@ -1836,11 +1848,11 @@ msgstr "" "keyword:`if` 子句是選擇性的。如果省略它,則 ``range(256)`` 中的所有元素都會被" "處理。" -#: ../../glossary.rst:806 +#: ../../glossary.rst:811 msgid "loader" msgstr "loader(載入器)" -#: ../../glossary.rst:808 +#: ../../glossary.rst:813 msgid "" "An object that loads a module. It must define the :meth:`!exec_module` and :" "meth:`!create_module` methods to implement the :class:`~importlib.abc." @@ -1851,23 +1863,23 @@ msgstr "" "create_module` 方法以實作 :class:`~importlib.abc.Loader` 介面。載入器通常是" "被 :term:`finder`\\ (尋檢器)回傳。更多細節請參閱:" -#: ../../glossary.rst:814 +#: ../../glossary.rst:819 msgid ":ref:`finders-and-loaders`" msgstr ":ref:`finders-and-loaders`" -#: ../../glossary.rst:815 +#: ../../glossary.rst:820 msgid ":class:`importlib.abc.Loader`" msgstr ":class:`importlib.abc.Loader`" -#: ../../glossary.rst:816 +#: ../../glossary.rst:821 msgid ":pep:`302`" msgstr ":pep:`302`" -#: ../../glossary.rst:817 +#: ../../glossary.rst:822 msgid "locale encoding" msgstr "locale encoding(區域編碼)" -#: ../../glossary.rst:819 +#: ../../glossary.rst:824 msgid "" "On Unix, it is the encoding of the LC_CTYPE locale. It can be set with :func:" "`locale.setlocale(locale.LC_CTYPE, new_locale) `." @@ -1875,36 +1887,36 @@ msgstr "" "在 Unix 上,它是 LC_CTYPE 區域設定的編碼。它可以用 :func:`locale." "setlocale(locale.LC_CTYPE, new_locale) ` 來設定。" -#: ../../glossary.rst:822 +#: ../../glossary.rst:827 msgid "On Windows, it is the ANSI code page (ex: ``\"cp1252\"``)." msgstr "在 Windows 上,它是 ANSI 碼頁(code page,例如 ``\"cp1252\"``\\ )。" -#: ../../glossary.rst:824 +#: ../../glossary.rst:829 msgid "" "On Android and VxWorks, Python uses ``\"utf-8\"`` as the locale encoding." msgstr "在 Android 和 VxWorks 上,Python 使用 ``\"utf-8\"`` 作為區域編碼。" -#: ../../glossary.rst:826 +#: ../../glossary.rst:831 msgid ":func:`locale.getencoding` can be used to get the locale encoding." msgstr ":func:`locale.getencoding` 可以用來取得區域編碼。" -#: ../../glossary.rst:828 +#: ../../glossary.rst:833 msgid "See also the :term:`filesystem encoding and error handler`." msgstr "也請參考 :term:`filesystem encoding and error handler`。" -#: ../../glossary.rst:829 +#: ../../glossary.rst:834 msgid "magic method" msgstr "magic method(魔術方法)" -#: ../../glossary.rst:833 +#: ../../glossary.rst:838 msgid "An informal synonym for :term:`special method`." msgstr ":term:`special method`\\ (特殊方法)的一個非正式同義詞。" -#: ../../glossary.rst:834 +#: ../../glossary.rst:839 msgid "mapping" msgstr "mapping(對映)" -#: ../../glossary.rst:836 +#: ../../glossary.rst:841 msgid "" "A container object that supports arbitrary key lookups and implements the " "methods specified in the :class:`collections.abc.Mapping` or :class:" @@ -1919,11 +1931,11 @@ msgstr "" "包括 :class:`dict`、:class:`collections.defaultdict`、:class:`collections." "OrderedDict` 和 :class:`collections.Counter`。" -#: ../../glossary.rst:842 +#: ../../glossary.rst:847 msgid "meta path finder" msgstr "meta path finder(元路徑尋檢器)" -#: ../../glossary.rst:844 +#: ../../glossary.rst:849 msgid "" "A :term:`finder` returned by a search of :data:`sys.meta_path`. Meta path " "finders are related to, but different from :term:`path entry finders ` " "相關但是不同。" -#: ../../glossary.rst:848 +#: ../../glossary.rst:853 msgid "" "See :class:`importlib.abc.MetaPathFinder` for the methods that meta path " "finders implement." msgstr "" "關於元路徑尋檢器實作的 method,請參閱 :class:`importlib.abc.MetaPathFinder`。" -#: ../../glossary.rst:850 +#: ../../glossary.rst:855 msgid "metaclass" msgstr "metaclass(元類別)" -#: ../../glossary.rst:852 +#: ../../glossary.rst:857 msgid "" "The class of a class. Class definitions create a class name, a class " "dictionary, and a list of base classes. The metaclass is responsible for " @@ -1964,15 +1976,15 @@ msgstr "" "性存取、增加執行緒安全性、追蹤物件建立、實作單例模式 (singleton),以及許多其" "他的任務。" -#: ../../glossary.rst:862 +#: ../../glossary.rst:867 msgid "More information can be found in :ref:`metaclasses`." msgstr "更多資訊可以在\\ :ref:`metaclasses`\\ 章節中找到。" -#: ../../glossary.rst:831 ../../glossary.rst:863 ../../glossary.rst:1236 +#: ../../glossary.rst:836 ../../glossary.rst:868 ../../glossary.rst:1241 msgid "method" msgstr "method(方法)" -#: ../../glossary.rst:865 +#: ../../glossary.rst:870 msgid "" "A function which is defined inside a class body. If called as an attribute " "of an instance of that class, the method will get the instance object as its " @@ -1984,11 +1996,11 @@ msgstr "" "通常被稱為 ``self``)。請參閱 :term:`function`\\ (函式)和 :term:`nested " "scope`\\ (巢狀作用域)。" -#: ../../glossary.rst:869 +#: ../../glossary.rst:874 msgid "method resolution order" msgstr "method resolution order(方法解析順序)" -#: ../../glossary.rst:871 +#: ../../glossary.rst:876 msgid "" "Method Resolution Order is the order in which base classes are searched for " "a member during lookup. See :ref:`python_2.3_mro` for details of the " @@ -1997,11 +2009,11 @@ msgstr "" "方法解析順序是在查找某個成員的過程中,base class(基底類別)被搜尋的順序。關" "於 Python 自 2.3 版直譯器所使用的演算法細節,請參閱 :ref:`python_2.3_mro`。" -#: ../../glossary.rst:874 +#: ../../glossary.rst:879 msgid "module" msgstr "module(模組)" -#: ../../glossary.rst:876 +#: ../../glossary.rst:881 msgid "" "An object that serves as an organizational unit of Python code. Modules " "have a namespace containing arbitrary Python objects. Modules are loaded " @@ -2011,15 +2023,15 @@ msgstr "" "空間,它包含任意的 Python 物件。模組是藉由 :term:`importing` 的過程,被載入" "至 Python。" -#: ../../glossary.rst:880 +#: ../../glossary.rst:885 msgid "See also :term:`package`." msgstr "另請參閱 :term:`package`\\ (套件)。" -#: ../../glossary.rst:881 +#: ../../glossary.rst:886 msgid "module spec" msgstr "module spec(模組規格)" -#: ../../glossary.rst:883 +#: ../../glossary.rst:888 msgid "" "A namespace containing the import-related information used to load a module. " "An instance of :class:`importlib.machinery.ModuleSpec`." @@ -2027,23 +2039,23 @@ msgstr "" "一個命名空間,它包含用於載入模組的 import 相關資訊。它是 :class:`importlib." "machinery.ModuleSpec` 的一個實例。" -#: ../../glossary.rst:886 +#: ../../glossary.rst:891 msgid "See also :ref:`module-specs`." msgstr "另請參閱 :ref:`module-specs`。" -#: ../../glossary.rst:887 +#: ../../glossary.rst:892 msgid "MRO" msgstr "MRO" -#: ../../glossary.rst:889 +#: ../../glossary.rst:894 msgid "See :term:`method resolution order`." msgstr "請參閱 :term:`method resolution order`\\ (方法解析順序)。" -#: ../../glossary.rst:890 +#: ../../glossary.rst:895 msgid "mutable" msgstr "mutable(可變物件)" -#: ../../glossary.rst:892 +#: ../../glossary.rst:897 msgid "" "Mutable objects can change their value but keep their :func:`id`. See also :" "term:`immutable`." @@ -2051,11 +2063,11 @@ msgstr "" "可變物件可以改變它們的值,但維持它們的 :func:`id`。另請參閱 :term:" "`immutable`\\ (不可變物件)。" -#: ../../glossary.rst:894 +#: ../../glossary.rst:899 msgid "named tuple" msgstr "named tuple(附名元組)" -#: ../../glossary.rst:896 +#: ../../glossary.rst:901 msgid "" "The term \"named tuple\" applies to any type or class that inherits from " "tuple and whose indexable elements are also accessible using named " @@ -2065,7 +2077,7 @@ msgstr "" "索引 (indexable) 元素也可以用附名屬性來存取。這些型別或 class 也可以具有其他" "的特性。" -#: ../../glossary.rst:900 +#: ../../glossary.rst:905 msgid "" "Several built-in types are named tuples, including the values returned by :" "func:`time.localtime` and :func:`os.stat`. Another example is :data:`sys." @@ -2074,7 +2086,7 @@ msgstr "" "有些內建型別是 named tuple,包括由 :func:`time.localtime` 和 :func:`os.stat` " "回傳的值。另一個例子是 :data:`sys.float_info`: ::" -#: ../../glossary.rst:904 +#: ../../glossary.rst:909 msgid "" ">>> sys.float_info[1] # indexed access\n" "1024\n" @@ -2090,7 +2102,7 @@ msgstr "" ">>> isinstance(sys.float_info, tuple) # 屬於 tuple 型別\n" "True" -#: ../../glossary.rst:911 +#: ../../glossary.rst:916 msgid "" "Some named tuples are built-in types (such as the above examples). " "Alternatively, a named tuple can be created from a regular class definition " @@ -2107,11 +2119,11 @@ msgstr "" "namedtuple` 來建立。後者技術也增加了一些額外的 method,這些 method 可能是在手" "寫或內建的 named tuple 中,無法找到的。" -#: ../../glossary.rst:919 +#: ../../glossary.rst:924 msgid "namespace" msgstr "namespace(命名空間)" -#: ../../glossary.rst:921 +#: ../../glossary.rst:926 msgid "" "The place where a variable is stored. Namespaces are implemented as " "dictionaries. There are the local, global and built-in namespaces as well " @@ -2131,11 +2143,11 @@ msgstr "" "func:`itertools.islice` 明確地表示,這些函式分別是由 :mod:`random` 和 :mod:" "`itertools` 模組在實作。" -#: ../../glossary.rst:931 +#: ../../glossary.rst:936 msgid "namespace package" msgstr "namespace package(命名空間套件)" -#: ../../glossary.rst:933 +#: ../../glossary.rst:938 msgid "" "A :term:`package` which serves only as a container for subpackages. " "Namespace packages may have no physical representation, and specifically are " @@ -2145,7 +2157,7 @@ msgstr "" "名空間套件可能沒有實體的表示法,而且具體來說它們不像是一個 :term:`regular " "package`\\ (正規套件),因為它們並沒有 ``__init__.py`` 這個檔案。" -#: ../../glossary.rst:938 +#: ../../glossary.rst:943 msgid "" "Namespace packages allow several individually installable packages to have a " "common parent package. Otherwise, it is recommended to use a :term:`regular " @@ -2154,20 +2166,20 @@ msgstr "" "命名空間套件允許數個可獨立安裝的套件擁有一個共同的父套件。除此之外,建議使" "用 :term:`regular package`。" -#: ../../glossary.rst:941 +#: ../../glossary.rst:946 msgid "" "For more information, see :pep:`420` and :ref:`reference-namespace-package`." msgstr "更多資訊,請參閱 :pep:`420` 和 :ref:`reference-namespace-package`。" -#: ../../glossary.rst:943 +#: ../../glossary.rst:948 msgid "See also :term:`module`." msgstr "另請參閱 :term:`module`\\ (模組)。" -#: ../../glossary.rst:944 +#: ../../glossary.rst:949 msgid "nested scope" msgstr "nested scope(巢狀作用域)" -#: ../../glossary.rst:946 +#: ../../glossary.rst:951 msgid "" "The ability to refer to a variable in an enclosing definition. For " "instance, a function defined inside another function can refer to variables " @@ -2182,11 +2194,11 @@ msgstr "" "寫入。同樣地,全域變數是在全域命名空間中讀取及寫入。:keyword:`nonlocal` 容許" "對外層作用域進行寫入。" -#: ../../glossary.rst:953 +#: ../../glossary.rst:958 msgid "new-style class" msgstr "new-style class(新式類別)" -#: ../../glossary.rst:955 +#: ../../glossary.rst:960 msgid "" "Old name for the flavor of classes now used for all class objects. In " "earlier Python versions, only new-style classes could use Python's newer, " @@ -2198,11 +2210,11 @@ msgstr "" "__slots__`、描述器 (descriptor)、屬性 (property)、:meth:`~object." "__getattribute__`、class method(類別方法)和 static method(靜態方法)。" -#: ../../glossary.rst:960 +#: ../../glossary.rst:965 msgid "object" msgstr "object(物件)" -#: ../../glossary.rst:962 +#: ../../glossary.rst:967 msgid "" "Any data with state (attributes or value) and defined behavior (methods). " "Also the ultimate base class of any :term:`new-style class`." @@ -2210,11 +2222,11 @@ msgstr "" "具有狀態(屬性或值)及被定義的行為(method)的任何資料。它也是任何 :term:" "`new-style class`\\ (新式類別)的最終 base class(基底類別)。" -#: ../../glossary.rst:965 +#: ../../glossary.rst:970 msgid "optimized scope" msgstr "optimized scope(最佳化作用域)" -#: ../../glossary.rst:967 +#: ../../glossary.rst:972 msgid "" "A scope where target local variable names are reliably known to the compiler " "when the code is compiled, allowing optimization of read and write access to " @@ -2225,11 +2237,11 @@ msgid "" "to optimized scopes." msgstr "" -#: ../../glossary.rst:974 +#: ../../glossary.rst:979 msgid "package" msgstr "package(套件)" -#: ../../glossary.rst:976 +#: ../../glossary.rst:981 msgid "" "A Python :term:`module` which can contain submodules or recursively, " "subpackages. Technically, a package is a Python module with a ``__path__`` " @@ -2239,17 +2251,17 @@ msgstr "" "迴的子套件 (subpackage)。技術上而言,套件就是具有 ``__path__`` 屬性的一個 " "Python 模組。" -#: ../../glossary.rst:980 +#: ../../glossary.rst:985 msgid "See also :term:`regular package` and :term:`namespace package`." msgstr "" "另請參閱 :term:`regular package`\\ (正規套件)和 :term:`namespace " "package`\\ (命名空間套件)。" -#: ../../glossary.rst:981 +#: ../../glossary.rst:986 msgid "parameter" msgstr "parameter(參數)" -#: ../../glossary.rst:983 +#: ../../glossary.rst:988 msgid "" "A named entity in a :term:`function` (or method) definition that specifies " "an :term:`argument` (or in some cases, arguments) that the function can " @@ -2259,7 +2271,7 @@ msgstr "" "它指明該函式能夠接受的一個 :term:`argument`\\ (引數),或在某些情況下指示多" "個引數。共有有五種不同的參數類型:" -#: ../../glossary.rst:987 +#: ../../glossary.rst:992 msgid "" ":dfn:`positional-or-keyword`: specifies an argument that can be passed " "either :term:`positionally ` or as a :term:`keyword argument " @@ -2270,11 +2282,11 @@ msgstr "" "置 `\\ 或是作為\\ :term:`關鍵字引數 `\\ 被傳遞的引數。這" "是參數的預設類型,例如以下的 *foo* 和 *bar*: ::" -#: ../../glossary.rst:992 +#: ../../glossary.rst:997 msgid "def func(foo, bar=None): ..." msgstr "def func(foo, bar=None): ..." -#: ../../glossary.rst:996 +#: ../../glossary.rst:1001 msgid "" ":dfn:`positional-only`: specifies an argument that can be supplied only by " "position. Positional-only parameters can be defined by including a ``/`` " @@ -2285,11 +2297,11 @@ msgstr "" "式定義的參數列表中包含一個 ``/`` 字元,就可以在該字元前面定義僅限位置參數,例" "如以下的 *posonly1* 和 *posonly2*: ::" -#: ../../glossary.rst:1001 +#: ../../glossary.rst:1006 msgid "def func(posonly1, posonly2, /, positional_or_keyword): ..." msgstr "def func(posonly1, posonly2, /, positional_or_keyword): ..." -#: ../../glossary.rst:1005 +#: ../../glossary.rst:1010 msgid "" ":dfn:`keyword-only`: specifies an argument that can be supplied only by " "keyword. Keyword-only parameters can be defined by including a single var-" @@ -2302,11 +2314,11 @@ msgstr "" "單純的 ``*`` 字元,就可以在其後方定義僅限關鍵字參數,例如以下的 *kw_only1* " "和 *kw_only2*: ::" -#: ../../glossary.rst:1011 +#: ../../glossary.rst:1016 msgid "def func(arg, *, kw_only1, kw_only2): ..." msgstr "def func(arg, *, kw_only1, kw_only2): ..." -#: ../../glossary.rst:1013 +#: ../../glossary.rst:1018 msgid "" ":dfn:`var-positional`: specifies that an arbitrary sequence of positional " "arguments can be provided (in addition to any positional arguments already " @@ -2318,11 +2330,11 @@ msgstr "" "數(在已被其他參數接受的任何位置引數之外)。這類參數是透過在其參數名稱字首加" "上 ``*`` 來定義的,例如以下的 *args*: ::" -#: ../../glossary.rst:1019 +#: ../../glossary.rst:1024 msgid "def func(*args, **kwargs): ..." msgstr "def func(*args, **kwargs): ..." -#: ../../glossary.rst:1021 +#: ../../glossary.rst:1026 msgid "" ":dfn:`var-keyword`: specifies that arbitrarily many keyword arguments can be " "provided (in addition to any keyword arguments already accepted by other " @@ -2333,14 +2345,14 @@ msgstr "" "已被其他參數接受的任何關鍵字引數之外)。這類參數是透過在其參數名稱字首加上 " "``**`` 來定義的,例如上面範例中的 *kwargs*。" -#: ../../glossary.rst:1027 +#: ../../glossary.rst:1032 msgid "" "Parameters can specify both optional and required arguments, as well as " "default values for some optional arguments." msgstr "" "參數可以指明引數是選擇性的或必需的,也可以為一些選擇性的引數指定預設值。" -#: ../../glossary.rst:1030 +#: ../../glossary.rst:1035 msgid "" "See also the :term:`argument` glossary entry, the FAQ question on :ref:`the " "difference between arguments and parameters `, " @@ -2351,11 +2363,11 @@ msgstr "" "參數之間的差異 `、:class:`inspect.Parameter` " "class、:ref:`function`\\ 章節,以及 :pep:`362`。" -#: ../../glossary.rst:1034 +#: ../../glossary.rst:1039 msgid "path entry" msgstr "path entry(路徑項目)" -#: ../../glossary.rst:1036 +#: ../../glossary.rst:1041 msgid "" "A single location on the :term:`import path` which the :term:`path based " "finder` consults to find modules for importing." @@ -2363,11 +2375,11 @@ msgstr "" "在 :term:`import path`\\ (引入路徑)中的一個位置,而 :term:`path based " "finder` (基於路徑的尋檢器)會參考該位置來尋找要 import 的模組。" -#: ../../glossary.rst:1038 +#: ../../glossary.rst:1043 msgid "path entry finder" msgstr "path entry finder(路徑項目尋檢器)" -#: ../../glossary.rst:1040 +#: ../../glossary.rst:1045 msgid "" "A :term:`finder` returned by a callable on :data:`sys.path_hooks` (i.e. a :" "term:`path entry hook`) which knows how to locate modules given a :term:" @@ -2377,7 +2389,7 @@ msgstr "" "`path entry hook`\\ )所回傳的一種 :term:`finder`,它知道如何以一個 :term:" "`path entry`\\ 定位模組。" -#: ../../glossary.rst:1044 +#: ../../glossary.rst:1049 msgid "" "See :class:`importlib.abc.PathEntryFinder` for the methods that path entry " "finders implement." @@ -2385,11 +2397,11 @@ msgstr "" "關於路徑項目尋檢器實作的 method,請參閱 :class:`importlib.abc." "PathEntryFinder`。" -#: ../../glossary.rst:1046 +#: ../../glossary.rst:1051 msgid "path entry hook" msgstr "path entry hook(路徑項目鉤)" -#: ../../glossary.rst:1048 +#: ../../glossary.rst:1053 msgid "" "A callable on the :data:`sys.path_hooks` list which returns a :term:`path " "entry finder` if it knows how to find modules on a specific :term:`path " @@ -2399,11 +2411,11 @@ msgstr "" "個特定的 :term:`path entry` 中尋找模組,則會回傳一個 :term:`path entry " "finder`\\ (路徑項目尋檢器)。" -#: ../../glossary.rst:1051 +#: ../../glossary.rst:1056 msgid "path based finder" msgstr "path based finder(基於路徑的尋檢器)" -#: ../../glossary.rst:1053 +#: ../../glossary.rst:1058 msgid "" "One of the default :term:`meta path finders ` which " "searches an :term:`import path` for modules." @@ -2411,11 +2423,11 @@ msgstr "" "預設的\\ :term:`元路徑尋檢器 (meta path finder) ` 之一,它" "會在一個 :term:`import path` 中搜尋模組。" -#: ../../glossary.rst:1055 +#: ../../glossary.rst:1060 msgid "path-like object" msgstr "path-like object(類路徑物件)" -#: ../../glossary.rst:1057 +#: ../../glossary.rst:1062 msgid "" "An object representing a file system path. A path-like object is either a :" "class:`str` or :class:`bytes` object representing a path, or an object " @@ -2433,11 +2445,11 @@ msgstr "" "`os.fsencode` 則分別可用於確保 :class:`str` 及 :class:`bytes` 的結果。由 :" "pep:`519` 引入。" -#: ../../glossary.rst:1065 +#: ../../glossary.rst:1070 msgid "PEP" msgstr "PEP" -#: ../../glossary.rst:1067 +#: ../../glossary.rst:1072 msgid "" "Python Enhancement Proposal. A PEP is a design document providing " "information to the Python community, or describing a new feature for Python " @@ -2448,7 +2460,7 @@ msgstr "" "為 Python 社群提供資訊,或是描述 Python 的一個新功能或該功能的程序和環境。" "PEP 應該要提供簡潔的技術規範以及被提案功能的運作原理。" -#: ../../glossary.rst:1073 +#: ../../glossary.rst:1078 msgid "" "PEPs are intended to be the primary mechanisms for proposing major new " "features, for collecting community input on an issue, and for documenting " @@ -2460,15 +2472,15 @@ msgstr "" "已納入 Python 的設計決策的記錄,這些過程的主要機制。PEP 的作者要負責在社群內" "建立共識並記錄反對意見。" -#: ../../glossary.rst:1079 +#: ../../glossary.rst:1084 msgid "See :pep:`1`." msgstr "請參閱 :pep:`1`。" -#: ../../glossary.rst:1080 +#: ../../glossary.rst:1085 msgid "portion" msgstr "portion(部分)" -#: ../../glossary.rst:1082 +#: ../../glossary.rst:1087 msgid "" "A set of files in a single directory (possibly stored in a zip file) that " "contribute to a namespace package, as defined in :pep:`420`." @@ -2476,15 +2488,15 @@ msgstr "" "在單一目錄中的一組檔案(也可能儲存在一個 zip 檔中),這些檔案能對一個命名空間" "套件 (namespace package) 有所貢獻,如同 :pep:`420` 中的定義。" -#: ../../glossary.rst:1084 +#: ../../glossary.rst:1089 msgid "positional argument" msgstr "positional argument(位置引數)" -#: ../../glossary.rst:1087 +#: ../../glossary.rst:1092 msgid "provisional API" msgstr "provisional API(暫行 API)" -#: ../../glossary.rst:1089 +#: ../../glossary.rst:1094 msgid "" "A provisional API is one which has been deliberately excluded from the " "standard library's backwards compatibility guarantees. While major changes " @@ -2500,7 +2512,7 @@ msgstr "" "該介面)。這種變更並不會無端地產生——只有 API 被納入之前未察覺的嚴重基本缺陷被" "揭露時,它們才會發生。" -#: ../../glossary.rst:1098 +#: ../../glossary.rst:1103 msgid "" "Even for provisional APIs, backwards incompatible changes are seen as a " "\"solution of last resort\" - every attempt will still be made to find a " @@ -2509,7 +2521,7 @@ msgstr "" "即使對於暫行 API,向後不相容的變更也會被視為「最後的解決方案」——對於任何被發" "現的問題,仍然會盡可能找出一個向後相容的解決方案。" -#: ../../glossary.rst:1102 +#: ../../glossary.rst:1107 msgid "" "This process allows the standard library to continue to evolve over time, " "without locking in problematic design errors for extended periods of time. " @@ -2518,19 +2530,19 @@ msgstr "" "這個過程使得標準函式庫能隨著時間不斷進化,而避免耗費過長的時間去鎖定有問題的" "設計錯誤。請參閱 :pep:`411` 了解更多細節。" -#: ../../glossary.rst:1105 +#: ../../glossary.rst:1110 msgid "provisional package" msgstr "provisional package(暫行套件)" -#: ../../glossary.rst:1107 +#: ../../glossary.rst:1112 msgid "See :term:`provisional API`." msgstr "請參閱 :term:`provisional API`\\ (暫行 API)。" -#: ../../glossary.rst:1108 +#: ../../glossary.rst:1113 msgid "Python 3000" msgstr "Python 3000" -#: ../../glossary.rst:1110 +#: ../../glossary.rst:1115 msgid "" "Nickname for the Python 3.x release line (coined long ago when the release " "of version 3 was something in the distant future.) This is also abbreviated " @@ -2539,11 +2551,11 @@ msgstr "" "Python 3.x 系列版本的暱稱(很久以前創造的,當時第 3 版的發布是在遙遠的未" "來。)也可以縮寫為「Py3k」。" -#: ../../glossary.rst:1113 +#: ../../glossary.rst:1118 msgid "Pythonic" msgstr "Pythonic(Python 風格的)" -#: ../../glossary.rst:1115 +#: ../../glossary.rst:1120 msgid "" "An idea or piece of code which closely follows the most common idioms of the " "Python language, rather than implementing code using concepts common to " @@ -2557,7 +2569,7 @@ msgstr "" "keyword:`for` 陳述式,對一個可疊代物件的所有元素進行迴圈。許多其他語言並沒有" "這種類型的架構,所以不熟悉 Python 的人有時會使用一個數值計數器來代替: ::" -#: ../../glossary.rst:1122 +#: ../../glossary.rst:1127 msgid "" "for i in range(len(food)):\n" " print(food[i])" @@ -2565,11 +2577,11 @@ msgstr "" "for i in range(len(food)):\n" " print(food[i])" -#: ../../glossary.rst:1125 +#: ../../glossary.rst:1130 msgid "As opposed to the cleaner, Pythonic method::" msgstr "相較之下,以下方法更簡潔、更具有 Python 風格: ::" -#: ../../glossary.rst:1127 +#: ../../glossary.rst:1132 msgid "" "for piece in food:\n" " print(piece)" @@ -2577,11 +2589,11 @@ msgstr "" "for piece in food:\n" " print(piece)" -#: ../../glossary.rst:1129 +#: ../../glossary.rst:1134 msgid "qualified name" msgstr "qualified name(限定名稱)" -#: ../../glossary.rst:1131 +#: ../../glossary.rst:1136 msgid "" "A dotted name showing the \"path\" from a module's global scope to a class, " "function or method defined in that module, as defined in :pep:`3155`. For " @@ -2592,7 +2604,7 @@ msgstr "" "或 method 的「路徑」,如 :pep:`3155` 中的定義。對於頂層的函式和 class 而言," "限定名稱與其物件名稱相同: ::" -#: ../../glossary.rst:1136 +#: ../../glossary.rst:1141 msgid "" ">>> class C:\n" "... class D:\n" @@ -2618,7 +2630,7 @@ msgstr "" ">>> C.D.meth.__qualname__\n" "'C.D.meth'" -#: ../../glossary.rst:1148 +#: ../../glossary.rst:1153 msgid "" "When used to refer to modules, the *fully qualified name* means the entire " "dotted path to the module, including any parent packages, e.g. ``email.mime." @@ -2627,7 +2639,7 @@ msgstr "" "當用於引用模組時,*完全限定名稱 (fully qualified name)* 是表示該模組的完整點" "分隔路徑,包括任何的父套件,例如 ``email.mime.text``: ::" -#: ../../glossary.rst:1152 +#: ../../glossary.rst:1157 msgid "" ">>> import email.mime.text\n" ">>> email.mime.text.__name__\n" @@ -2637,11 +2649,11 @@ msgstr "" ">>> email.mime.text.__name__\n" "'email.mime.text'" -#: ../../glossary.rst:1155 +#: ../../glossary.rst:1160 msgid "reference count" msgstr "reference count(參照計數)" -#: ../../glossary.rst:1157 +#: ../../glossary.rst:1162 msgid "" "The number of references to an object. When the reference count of an " "object drops to zero, it is deallocated. Some objects are :term:`immortal` " @@ -2657,7 +2669,7 @@ msgstr "" "看不到,但它卻是 :term:`CPython` 實作的一個關鍵元素。程式設計師可以呼叫 :" "func:`~sys.getrefcount` 函式來回傳一個特定物件的參照計數。" -#: ../../glossary.rst:1166 +#: ../../glossary.rst:1171 msgid "" "In :term:`CPython`, reference counts are not considered to be stable or well-" "defined values; the number of references to an object, and how that number " @@ -2666,11 +2678,11 @@ msgstr "" "在 :term:`CPython` 中,參照計數不被視為穩定或明確定義的值;對物件的參照數量," "以及該數量如何受到 Python 程式碼的影響,在不同版本之間可能會有所不同。" -#: ../../glossary.rst:1170 +#: ../../glossary.rst:1175 msgid "regular package" msgstr "regular package(正規套件)" -#: ../../glossary.rst:1172 +#: ../../glossary.rst:1177 msgid "" "A traditional :term:`package`, such as a directory containing an ``__init__." "py`` file." @@ -2678,15 +2690,15 @@ msgstr "" "一個傳統的 :term:`package`\\ (套件),例如一個包含 ``__init__.py`` 檔案的目" "錄。" -#: ../../glossary.rst:1175 +#: ../../glossary.rst:1180 msgid "See also :term:`namespace package`." msgstr "另請參閱 :term:`namespace package`\\ (命名空間套件)。" -#: ../../glossary.rst:1176 +#: ../../glossary.rst:1181 msgid "REPL" msgstr "REPL" -#: ../../glossary.rst:1178 +#: ../../glossary.rst:1183 msgid "" "An acronym for the \"read–eval–print loop\", another name for the :term:" "`interactive` interpreter shell." @@ -2694,11 +2706,11 @@ msgstr "" "「read-eval-print 迴圈 (read–eval–print loop)」的縮寫,是\\ :term:`互動式 " "`\\ 直譯器 shell 的另一個名稱。" -#: ../../glossary.rst:1180 +#: ../../glossary.rst:1185 msgid "__slots__" msgstr "__slots__" -#: ../../glossary.rst:1182 +#: ../../glossary.rst:1187 msgid "" "A declaration inside a class that saves memory by pre-declaring space for " "instance attributes and eliminating instance dictionaries. Though popular, " @@ -2711,11 +2723,11 @@ msgstr "" "最好保留給那種在一個記憶體關鍵 (memory-critical) 的應用程式中存在大量實例的罕" "見情況。" -#: ../../glossary.rst:1187 +#: ../../glossary.rst:1192 msgid "sequence" msgstr "sequence(序列)" -#: ../../glossary.rst:1189 +#: ../../glossary.rst:1194 msgid "" "An :term:`iterable` which supports efficient element access using integer " "indices via the :meth:`~object.__getitem__` special method and defines a :" @@ -2734,7 +2746,7 @@ msgstr "" "為對映 (mapping) 而不是序列,因為其查找方式是使用任意的 :term:`hashable` 鍵," "而不是整數。" -#: ../../glossary.rst:1198 +#: ../../glossary.rst:1203 msgid "" "The :class:`collections.abc.Sequence` abstract base class defines a much " "richer interface that goes beyond just :meth:`~object.__getitem__` and :meth:" @@ -2751,11 +2763,11 @@ msgstr "" "用 :func:`~abc.ABCMeta.register` 被明確地註冊。更多關於序列方法的文件,請見" "\\ :ref:`常見序列操作 `。" -#: ../../glossary.rst:1207 +#: ../../glossary.rst:1212 msgid "set comprehension" msgstr "set comprehension(集合綜合運算)" -#: ../../glossary.rst:1209 +#: ../../glossary.rst:1214 msgid "" "A compact way to process all or part of the elements in an iterable and " "return a set with the results. ``results = {c for c in 'abracadabra' if c " @@ -2766,11 +2778,11 @@ msgstr "" "set 回傳。``results = {c for c in 'abracadabra' if c not in 'abc'}`` 會產生一" "個字串 set:``{'r', 'd'}``。請參閱\\ :ref:`comprehensions`。" -#: ../../glossary.rst:1213 +#: ../../glossary.rst:1218 msgid "single dispatch" msgstr "single dispatch(單一調度)" -#: ../../glossary.rst:1215 +#: ../../glossary.rst:1220 msgid "" "A form of :term:`generic function` dispatch where the implementation is " "chosen based on the type of a single argument." @@ -2778,11 +2790,11 @@ msgstr "" ":term:`generic function`\\ (泛型函式)調度的一種形式,在此,實作的選擇是基於" "單一引數的型別。" -#: ../../glossary.rst:1217 +#: ../../glossary.rst:1222 msgid "slice" msgstr "slice(切片)" -#: ../../glossary.rst:1219 +#: ../../glossary.rst:1224 msgid "" "An object usually containing a portion of a :term:`sequence`. A slice is " "created using the subscript notation, ``[]`` with colons between numbers " @@ -2794,11 +2806,11 @@ msgstr "" "之間使用冒號,例如 ``variable_name[1:3:5]``。在括號(下標)符號的內部,會使" "用 :class:`slice` 物件。" -#: ../../glossary.rst:1223 +#: ../../glossary.rst:1228 msgid "soft deprecated" msgstr "soft deprecated(軟性棄用)" -#: ../../glossary.rst:1225 +#: ../../glossary.rst:1230 msgid "" "A soft deprecated API should not be used in new code, but it is safe for " "already existing code to use it. The API remains documented and tested, but " @@ -2807,13 +2819,13 @@ msgstr "" "被軟性棄用的 API 代表不應再用於新程式碼中,但在現有程式碼中繼續使用它仍會是安" "全的。API 仍會以文件記錄並會被測試,但不會被繼續改進。" -#: ../../glossary.rst:1229 +#: ../../glossary.rst:1234 msgid "" "Soft deprecation, unlike normal deprecation, does not plan on removing the " "API and will not emit warnings." msgstr "與正常棄用不同,軟性棄用沒有刪除 API 的規劃,也不會發出警告。" -#: ../../glossary.rst:1232 +#: ../../glossary.rst:1237 msgid "" "See `PEP 387: Soft Deprecation `_." @@ -2821,11 +2833,11 @@ msgstr "" "請參閱 `PEP 387:軟性棄用 `_。" -#: ../../glossary.rst:1234 +#: ../../glossary.rst:1239 msgid "special method" msgstr "special method(特殊方法)" -#: ../../glossary.rst:1238 +#: ../../glossary.rst:1243 msgid "" "A method that is called implicitly by Python to execute a certain operation " "on a type, such as addition. Such methods have names starting and ending " @@ -2836,11 +2848,11 @@ msgstr "" "種 method 的名稱會在開頭和結尾有兩個下底線。Special method 在\\ :ref:" "`specialnames`\\ 中有詳細說明。" -#: ../../glossary.rst:1242 +#: ../../glossary.rst:1247 msgid "standard library" msgstr "標準函式庫" -#: ../../glossary.rst:1244 +#: ../../glossary.rst:1249 msgid "" "The collection of :term:`packages `, :term:`modules ` and :" "term:`extension modules ` distributed as a part of the " @@ -2853,7 +2865,7 @@ msgstr "" "行。該集合的成員可能會因平台、可用的系統函式庫或其他條件而有所不同。相關文件" "可以在 :ref:`library-index` 中找到。" -#: ../../glossary.rst:1250 +#: ../../glossary.rst:1255 msgid "" "See also :data:`sys.stdlib_module_names` for a list of all possible standard " "library module names." @@ -2861,11 +2873,11 @@ msgstr "" "請參閱 :data:`sys.stdlib_module_names` 以取得所有可能的標準函式庫模組名稱的列" "表。" -#: ../../glossary.rst:1252 +#: ../../glossary.rst:1257 msgid "statement" msgstr "statement(陳述式)" -#: ../../glossary.rst:1254 +#: ../../glossary.rst:1259 msgid "" "A statement is part of a suite (a \"block\" of code). A statement is either " "an :term:`expression` or one of several constructs with a keyword, such as :" @@ -2875,11 +2887,11 @@ msgstr "" "term:`expression`\\ (運算式),或是含有關鍵字(例如 :keyword:`if`、:keyword:" "`while` 或 :keyword:`for`\\ )的多種結構之一。" -#: ../../glossary.rst:1257 +#: ../../glossary.rst:1262 msgid "static type checker" msgstr "static type checker(靜態型別檢查器)" -#: ../../glossary.rst:1259 +#: ../../glossary.rst:1264 msgid "" "An external tool that reads Python code and analyzes it, looking for issues " "such as incorrect types. See also :term:`type hints ` and the :" @@ -2889,19 +2901,19 @@ msgstr "" "另請參閱\\ :term:`型別提示 (type hints) ` 以及 :mod:`typing` 模" "組。" -#: ../../glossary.rst:1262 +#: ../../glossary.rst:1267 msgid "stdlib" msgstr "stdlib(標準函式庫)" -#: ../../glossary.rst:1264 +#: ../../glossary.rst:1269 msgid "An abbreviation of :term:`standard library`." msgstr ":term:`standard library` 的縮寫。" -#: ../../glossary.rst:1265 +#: ../../glossary.rst:1270 msgid "strong reference" msgstr "strong reference(強參照)" -#: ../../glossary.rst:1267 +#: ../../glossary.rst:1272 msgid "" "In Python's C API, a strong reference is a reference to an object which is " "owned by the code holding the reference. The strong reference is taken by " @@ -2912,7 +2924,7 @@ msgstr "" "有。建立參照時透過呼叫 :c:func:`Py_INCREF` 來獲得強參照、刪除參照時透過 :c:" "func:`Py_DECREF` 釋放強參照。" -#: ../../glossary.rst:1273 +#: ../../glossary.rst:1278 msgid "" "The :c:func:`Py_NewRef` function can be used to create a strong reference to " "an object. Usually, the :c:func:`Py_DECREF` function must be called on the " @@ -2922,15 +2934,15 @@ msgstr "" ":c:func:`Py_NewRef` 函式可用於建立一個對物件的強參照。通常,在退出強參照的作" "用域之前,必須在該強參照上呼叫 :c:func:`Py_DECREF` 函式,以避免洩漏一個參照。" -#: ../../glossary.rst:1278 +#: ../../glossary.rst:1283 msgid "See also :term:`borrowed reference`." msgstr "另請參閱 :term:`borrowed reference`\\ (借用參照)。" -#: ../../glossary.rst:1279 +#: ../../glossary.rst:1284 msgid "text encoding" msgstr "text encoding(文字編碼)" -#: ../../glossary.rst:1281 +#: ../../glossary.rst:1286 msgid "" "A string in Python is a sequence of Unicode code points (in range " "``U+0000``--``U+10FFFF``). To store or transfer a string, it needs to be " @@ -2939,7 +2951,7 @@ msgstr "" "Python 中的字串是一個 Unicode 碼點 (code point) 的序列(範圍在 ``U+0000`` -- " "``U+10FFFF`` 之間)。若要儲存或傳送一個字串,它必須被序列化為一個位元組序列。" -#: ../../glossary.rst:1285 +#: ../../glossary.rst:1290 msgid "" "Serializing a string into a sequence of bytes is known as \"encoding\", and " "recreating the string from the sequence of bytes is known as \"decoding\"." @@ -2947,7 +2959,7 @@ msgstr "" "將一個字串序列化為位元組序列,稱為「編碼」,而從位元組序列重新建立該字串則稱" "為「解碼 (decoding)」。" -#: ../../glossary.rst:1288 +#: ../../glossary.rst:1293 msgid "" "There are a variety of different text serialization :ref:`codecs `, which are collectively referred to as \"text encodings\"." @@ -2955,11 +2967,11 @@ msgstr "" "有多種不同的文字序列化編解碼器 (:ref:`codecs `),它們被統" "稱為「文字編碼」。" -#: ../../glossary.rst:1291 +#: ../../glossary.rst:1296 msgid "text file" msgstr "text file(文字檔案)" -#: ../../glossary.rst:1293 +#: ../../glossary.rst:1298 msgid "" "A :term:`file object` able to read and write :class:`str` objects. Often, a " "text file actually accesses a byte-oriented datastream and handles the :term:" @@ -2973,7 +2985,7 @@ msgstr "" "有:以文字模式(``'r'`` 或 ``'w'``)開啟的檔案、:data:`sys.stdin`、:data:" "`sys.stdout` 以及 :class:`io.StringIO` 的實例。" -#: ../../glossary.rst:1300 +#: ../../glossary.rst:1305 msgid "" "See also :term:`binary file` for a file object able to read and write :term:" "`bytes-like objects `." @@ -2981,11 +2993,11 @@ msgstr "" "另請參閱 :term:`binary file`\\ (二進位檔案),它是一個能夠讀取和寫入\\ :" "term:`類位元組串物件 (bytes-like object) ` 的檔案物件。" -#: ../../glossary.rst:1302 +#: ../../glossary.rst:1307 msgid "token" msgstr "token" -#: ../../glossary.rst:1305 +#: ../../glossary.rst:1310 msgid "" "A small unit of source code, generated by the :ref:`lexical analyzer " "` (also called the *tokenizer*). Names, numbers, strings, " @@ -2994,19 +3006,19 @@ msgstr "" "原始碼的小單位,由 :ref:`詞法分析器 ` (也稱為 *tokenizer*)產生。名" "稱、數字、字串、運算子、換行符號等都以 token 表示。" -#: ../../glossary.rst:1310 +#: ../../glossary.rst:1315 msgid "" "The :mod:`tokenize` module exposes Python's lexical analyzer. The :mod:" "`token` module contains information on the various types of tokens." msgstr "" -":mod:`tokenize` 模組公開了 Python 的詞法分析器。:mod:`token` 模組包含各種 token " -"類型的資訊。" +":mod:`tokenize` 模組公開了 Python 的詞法分析器。:mod:`token` 模組包含各種 " +"token 類型的資訊。" -#: ../../glossary.rst:1313 +#: ../../glossary.rst:1318 msgid "triple-quoted string" msgstr "triple-quoted string(三引號內字串)" -#: ../../glossary.rst:1315 +#: ../../glossary.rst:1320 msgid "" "A string which is bound by three instances of either a quotation mark (\") " "or an apostrophe ('). While they don't provide any functionality not " @@ -3021,11 +3033,11 @@ msgstr "" "中包含未跳脫 (unescaped) 的單引號和雙引號,而且它們不需使用連續字元 " "(continuation character) 就可以跨越多行,這使得它們在編寫說明字串時特別有用。" -#: ../../glossary.rst:1322 +#: ../../glossary.rst:1327 msgid "type" msgstr "type(型別)" -#: ../../glossary.rst:1324 +#: ../../glossary.rst:1329 msgid "" "The type of a Python object determines what kind of object it is; every " "object has a type. An object's type is accessible as its :attr:`~object." @@ -3035,22 +3047,22 @@ msgstr "" "件的型別可以用它的 :attr:`~object.__class__` 屬性來存取,或以 ``type(obj)`` " "來檢索。" -#: ../../glossary.rst:1328 +#: ../../glossary.rst:1333 msgid "type alias" msgstr "type alias(型別別名)" -#: ../../glossary.rst:1330 +#: ../../glossary.rst:1335 msgid "A synonym for a type, created by assigning the type to an identifier." msgstr "一個型別的同義詞,透過將型別指定給一個識別符 (identifier) 來建立。" -#: ../../glossary.rst:1332 +#: ../../glossary.rst:1337 msgid "" "Type aliases are useful for simplifying :term:`type hints `. For " "example::" msgstr "" "型別別名對於簡化\\ :term:`型別提示 (type hint) ` 很有用。例如: ::" -#: ../../glossary.rst:1335 +#: ../../glossary.rst:1340 msgid "" "def remove_gray_shades(\n" " colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" @@ -3060,11 +3072,11 @@ msgstr "" " colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" " pass" -#: ../../glossary.rst:1339 +#: ../../glossary.rst:1344 msgid "could be made more readable like this::" msgstr "可以寫成這樣,更具有可讀性: ::" -#: ../../glossary.rst:1341 +#: ../../glossary.rst:1346 msgid "" "Color = tuple[int, int, int]\n" "\n" @@ -3076,15 +3088,15 @@ msgstr "" "def remove_gray_shades(colors: list[Color]) -> list[Color]:\n" " pass" -#: ../../glossary.rst:1346 ../../glossary.rst:1360 +#: ../../glossary.rst:1351 ../../glossary.rst:1365 msgid "See :mod:`typing` and :pep:`484`, which describe this functionality." msgstr "請參閱 :mod:`typing` 和 :pep:`484`,有此功能的描述。" -#: ../../glossary.rst:1347 +#: ../../glossary.rst:1352 msgid "type hint" msgstr "type hint(型別提示)" -#: ../../glossary.rst:1349 +#: ../../glossary.rst:1354 msgid "" "An :term:`annotation` that specifies the expected type for a variable, a " "class attribute, or a function parameter or return value." @@ -3092,7 +3104,7 @@ msgstr "" "一種 :term:`annotation`\\ (註釋),它指定一個變數、一個 class 屬性或一個函式" "的參數或回傳值的預期型別。" -#: ../../glossary.rst:1352 +#: ../../glossary.rst:1357 msgid "" "Type hints are optional and are not enforced by Python but they are useful " "to :term:`static type checkers `. They can also aid " @@ -3102,7 +3114,7 @@ msgstr "" "(static type checkers) `\\ 很有用,並能協助 IDE 完成程式" "碼的補全 (completion) 和重構 (refactoring)。" -#: ../../glossary.rst:1356 +#: ../../glossary.rst:1361 msgid "" "Type hints of global variables, class attributes, and functions, but not " "local variables, can be accessed using :func:`typing.get_type_hints`." @@ -3110,11 +3122,11 @@ msgstr "" "全域變數、class 屬性和函式(不含區域變數)的型別提示,都可以使用 :func:" "`typing.get_type_hints` 來存取。" -#: ../../glossary.rst:1361 +#: ../../glossary.rst:1366 msgid "universal newlines" msgstr "universal newlines(通用換行字元)" -#: ../../glossary.rst:1363 +#: ../../glossary.rst:1368 msgid "" "A manner of interpreting text streams in which all of the following are " "recognized as ending a line: the Unix end-of-line convention ``'\\n'``, the " @@ -3127,20 +3139,20 @@ msgstr "" "``'\\r'``。請參閱 :pep:`278` 和 :pep:`3116`,以及用於 :func:`bytes." "splitlines` 的附加用途。" -#: ../../glossary.rst:1368 +#: ../../glossary.rst:1373 msgid "variable annotation" msgstr "variable annotation(變數註釋)" -#: ../../glossary.rst:1370 +#: ../../glossary.rst:1375 msgid "An :term:`annotation` of a variable or a class attribute." msgstr "一個變數或 class 屬性的 :term:`annotation`\\ (註釋)。" -#: ../../glossary.rst:1372 +#: ../../glossary.rst:1377 msgid "" "When annotating a variable or a class attribute, assignment is optional::" msgstr "註釋變數或 class 屬性時,賦值是選擇性的: ::" -#: ../../glossary.rst:1374 +#: ../../glossary.rst:1379 msgid "" "class C:\n" " field: 'annotation'" @@ -3148,7 +3160,7 @@ msgstr "" "class C:\n" " field: 'annotation'" -#: ../../glossary.rst:1377 +#: ../../glossary.rst:1382 msgid "" "Variable annotations are usually used for :term:`type hints `: " "for example this variable is expected to take :class:`int` values::" @@ -3156,15 +3168,15 @@ msgstr "" "變數註釋通常用於\\ :term:`型別提示 (type hint) `:例如,這個變數預" "期會取得 :class:`int`\\ (整數)值: ::" -#: ../../glossary.rst:1381 +#: ../../glossary.rst:1386 msgid "count: int = 0" msgstr "count: int = 0" -#: ../../glossary.rst:1383 +#: ../../glossary.rst:1388 msgid "Variable annotation syntax is explained in section :ref:`annassign`." msgstr "變數註釋的語法在\\ :ref:`annassign`\\ 章節有詳細的解釋。" -#: ../../glossary.rst:1385 +#: ../../glossary.rst:1390 msgid "" "See :term:`function annotation`, :pep:`484` and :pep:`526`, which describe " "this functionality. Also see :ref:`annotations-howto` for best practices on " @@ -3173,11 +3185,11 @@ msgstr "" "請參閱 :term:`function annotation`\\ (函式註釋)、:pep:`484` 和 :pep:`526`," "皆有此功能的描述。關於註釋的最佳實踐方法,另請參閱 :ref:`annotations-howto`。" -#: ../../glossary.rst:1389 +#: ../../glossary.rst:1394 msgid "virtual environment" msgstr "virtual environment(虛擬環境)" -#: ../../glossary.rst:1391 +#: ../../glossary.rst:1396 msgid "" "A cooperatively isolated runtime environment that allows Python users and " "applications to install and upgrade Python distribution packages without " @@ -3188,15 +3200,15 @@ msgstr "" "程式得以安裝和升級 Python 發佈套件,而不會對同一個系統上運行的其他 Python 應" "用程式的行為產生干擾。" -#: ../../glossary.rst:1396 +#: ../../glossary.rst:1401 msgid "See also :mod:`venv`." msgstr "另請參閱 :mod:`venv`。" -#: ../../glossary.rst:1397 +#: ../../glossary.rst:1402 msgid "virtual machine" msgstr "virtual machine(虛擬機器)" -#: ../../glossary.rst:1399 +#: ../../glossary.rst:1404 msgid "" "A computer defined entirely in software. Python's virtual machine executes " "the :term:`bytecode` emitted by the bytecode compiler." @@ -3204,11 +3216,23 @@ msgstr "" "一部完全由軟體所定義的電腦 (computer)。Python 的虛擬機器會執行由 :term:" "`bytecode`\\ (位元組碼)編譯器所發出的位元組碼。" -#: ../../glossary.rst:1401 +#: ../../glossary.rst:1406 +#, fuzzy +msgid "walrus operator" +msgstr "asynchronous iterator(非同步疊代器)" + +#: ../../glossary.rst:1408 +msgid "" +"A light-hearted way to refer to the :ref:`assignment expression ` operator ``:=`` because it looks a bit like a walrus if you " +"turn your head." +msgstr "" + +#: ../../glossary.rst:1411 msgid "Zen of Python" msgstr "Zen of Python(Python 之禪)" -#: ../../glossary.rst:1403 +#: ../../glossary.rst:1413 msgid "" "Listing of Python design principles and philosophies that are helpful in " "understanding and using the language. The listing can be found by typing " @@ -3225,11 +3249,11 @@ msgstr "C-contiguous(C 連續的)" msgid "Fortran contiguous" msgstr "Fortran contiguous(Fortran 連續的)" -#: ../../glossary.rst:831 +#: ../../glossary.rst:836 msgid "magic" msgstr "magic" -#: ../../glossary.rst:1236 +#: ../../glossary.rst:1241 msgid "special" msgstr "special" diff --git a/library/codecs.po b/library/codecs.po index fdd1bfcb7c..0316e8e612 100644 --- a/library/codecs.po +++ b/library/codecs.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-28 00:20+0000\n" +"POT-Creation-Date: 2025-08-06 00:17+0000\n" "PO-Revision-Date: 2018-05-23 14:40+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1536,7 +1536,7 @@ msgid "IBM775" msgstr "IBM775" #: ../../library/codecs.rst:1129 ../../library/codecs.rst:1196 -#: ../../library/codecs.rst:1246 ../../library/codecs.rst:1263 +#: ../../library/codecs.rst:1263 msgid "Baltic languages" msgstr "" @@ -2018,6 +2018,10 @@ msgstr "iso8859_4" msgid "iso-8859-4, latin4, L4" msgstr "iso-8859-4, latin4, L4" +#: ../../library/codecs.rst:1246 +msgid "Northern Europe" +msgstr "" + #: ../../library/codecs.rst:1248 msgid "iso8859_5" msgstr "iso8859_5" diff --git a/library/fractions.po b/library/fractions.po index 92a898b867..c3f5ecb277 100644 --- a/library/fractions.po +++ b/library/fractions.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-08-06 00:17+0000\n" "PO-Revision-Date: 2016-01-31 07:18+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,23 +33,23 @@ msgstr "" #: ../../library/fractions.rst:17 msgid "" -"A Fraction instance can be constructed from a pair of integers, from another " -"rational number, or from a string." +"A Fraction instance can be constructed from a pair of rational numbers, from " +"a single number, or from a string." msgstr "" #: ../../library/fractions.rst:26 msgid "" "The first version requires that *numerator* and *denominator* are instances " "of :class:`numbers.Rational` and returns a new :class:`Fraction` instance " -"with value ``numerator/denominator``. If *denominator* is ``0``, it raises " -"a :exc:`ZeroDivisionError`. The second version requires that " -"*other_fraction* is an instance of :class:`numbers.Rational` and returns " -"a :class:`Fraction` instance with the same value. The next two versions " -"accept either a :class:`float` or a :class:`decimal.Decimal` instance, and " -"return a :class:`Fraction` instance with exactly the same value. Note that " -"due to the usual issues with binary floating point (see :ref:`tut-fp-" -"issues`), the argument to ``Fraction(1.1)`` is not exactly equal to 11/10, " -"and so ``Fraction(1.1)`` does *not* return ``Fraction(11, 10)`` as one might " +"with a value equal to ``numerator/denominator``. If *denominator* is zero, " +"it raises a :exc:`ZeroDivisionError`. The second version requires that " +"*other_fraction* is an instance of :class:`numbers.Rational` and returns a :" +"class:`Fraction` instance with the same value. The next two versions accept " +"either a :class:`float` or a :class:`decimal.Decimal` instance, and return " +"a :class:`Fraction` instance with exactly the same value. Note that due to " +"the usual issues with binary floating point (see :ref:`tut-fp-issues`), the " +"argument to ``Fraction(1.1)`` is not exactly equal to 11/10, and so " +"``Fraction(1.1)`` does *not* return ``Fraction(11, 10)`` as one might " "expect. (But see the documentation for the :meth:`limit_denominator` method " "below.) The last version of the constructor expects a string or unicode " "instance. The usual form for this instance is::" @@ -64,10 +64,10 @@ msgid "" "where the optional ``sign`` may be either '+' or '-' and ``numerator`` and " "``denominator`` (if present) are strings of decimal digits (underscores may " "be used to delimit digits as with integral literals in code). In addition, " -"any string that represents a finite value and is accepted by " -"the :class:`float` constructor is also accepted by the :class:`Fraction` " -"constructor. In either form the input string may also have leading and/or " -"trailing whitespace. Here are some examples::" +"any string that represents a finite value and is accepted by the :class:" +"`float` constructor is also accepted by the :class:`Fraction` constructor. " +"In either form the input string may also have leading and/or trailing " +"whitespace. Here are some examples::" msgstr "" #: ../../library/fractions.rst:52 @@ -124,18 +124,20 @@ msgstr "" #: ../../library/fractions.rst:78 msgid "" -"The :class:`Fraction` class inherits from the abstract base " -"class :class:`numbers.Rational`, and implements all of the methods and " -"operations from that class. :class:`Fraction` instances " -"are :term:`hashable`, and should be treated as immutable. In " -"addition, :class:`Fraction` has the following properties and methods:" +"The :class:`Fraction` class inherits from the abstract base class :class:" +"`numbers.Rational`, and implements all of the methods and operations from " +"that class. :class:`Fraction` instances are :term:`hashable`, and should be " +"treated as immutable. In addition, :class:`Fraction` has the following " +"properties and methods:" msgstr "" #: ../../library/fractions.rst:84 msgid "" -"The :class:`Fraction` constructor now accepts :class:`float` " -"and :class:`decimal.Decimal` instances." -msgstr ":class:`Fraction` 建構函式現在可接受 :class:`float` 和 :class:`decimal.Decimal` 實例。" +"The :class:`Fraction` constructor now accepts :class:`float` and :class:" +"`decimal.Decimal` instances." +msgstr "" +":class:`Fraction` 建構函式現在可接受 :class:`float` 和 :class:`decimal." +"Decimal` 實例。" #: ../../library/fractions.rst:88 msgid "" @@ -152,8 +154,8 @@ msgstr "" #: ../../library/fractions.rst:97 msgid "" -":class:`Fraction` implements ``__int__`` now to satisfy " -"``typing.SupportsInt`` instance checks." +":class:`Fraction` implements ``__int__`` now to satisfy ``typing." +"SupportsInt`` instance checks." msgstr "" #: ../../library/fractions.rst:101 @@ -179,84 +181,84 @@ msgid "Numerator of the Fraction in lowest term." msgstr "" #: ../../library/fractions.rst:119 -msgid "Denominator of the Fraction in lowest term." +msgid "Denominator of the Fraction in lowest terms. Guaranteed to be positive." msgstr "" -#: ../../library/fractions.rst:124 +#: ../../library/fractions.rst:125 msgid "" "Return a tuple of two integers, whose ratio is equal to the original " "Fraction. The ratio is in lowest terms and has a positive denominator." msgstr "" -#: ../../library/fractions.rst:132 +#: ../../library/fractions.rst:133 msgid "Return ``True`` if the Fraction is an integer." msgstr "" -#: ../../library/fractions.rst:138 +#: ../../library/fractions.rst:139 msgid "" -"Alternative constructor which only accepts instances of :class:`float` " -"or :class:`numbers.Integral`. Beware that ``Fraction.from_float(0.3)`` is " -"not the same value as ``Fraction(3, 10)``." +"Alternative constructor which only accepts instances of :class:`float` or :" +"class:`numbers.Integral`. Beware that ``Fraction.from_float(0.3)`` is not " +"the same value as ``Fraction(3, 10)``." msgstr "" -#: ../../library/fractions.rst:144 +#: ../../library/fractions.rst:145 msgid "" "From Python 3.2 onwards, you can also construct a :class:`Fraction` instance " "directly from a :class:`float`." msgstr "" -#: ../../library/fractions.rst:150 +#: ../../library/fractions.rst:151 msgid "" -"Alternative constructor which only accepts instances " -"of :class:`decimal.Decimal` or :class:`numbers.Integral`." +"Alternative constructor which only accepts instances of :class:`decimal." +"Decimal` or :class:`numbers.Integral`." msgstr "" -#: ../../library/fractions.rst:155 +#: ../../library/fractions.rst:156 msgid "" "From Python 3.2 onwards, you can also construct a :class:`Fraction` instance " "directly from a :class:`decimal.Decimal` instance." msgstr "" -#: ../../library/fractions.rst:162 +#: ../../library/fractions.rst:163 msgid "" "Finds and returns the closest :class:`Fraction` to ``self`` that has " "denominator at most max_denominator. This method is useful for finding " "rational approximations to a given floating-point number:" msgstr "" -#: ../../library/fractions.rst:170 +#: ../../library/fractions.rst:171 msgid "or for recovering a rational number that's represented as a float:" msgstr "" -#: ../../library/fractions.rst:183 +#: ../../library/fractions.rst:184 msgid "" "Returns the greatest :class:`int` ``<= self``. This method can also be " "accessed through the :func:`math.floor` function:" msgstr "" -#: ../../library/fractions.rst:193 +#: ../../library/fractions.rst:194 msgid "" "Returns the least :class:`int` ``>= self``. This method can also be " "accessed through the :func:`math.ceil` function." msgstr "" -#: ../../library/fractions.rst:200 +#: ../../library/fractions.rst:201 msgid "" "The first version returns the nearest :class:`int` to ``self``, rounding " "half to even. The second version rounds ``self`` to the nearest multiple of " "``Fraction(1, 10**ndigits)`` (logically, if ``ndigits`` is negative), again " -"rounding half toward even. This method can also be accessed through " -"the :func:`round` function." +"rounding half toward even. This method can also be accessed through the :" +"func:`round` function." msgstr "" -#: ../../library/fractions.rst:208 +#: ../../library/fractions.rst:209 msgid "" -"Provides support for formatting of :class:`Fraction` instances via " -"the :meth:`str.format` method, the :func:`format` built-in function, " -"or :ref:`Formatted string literals `." +"Provides support for formatting of :class:`Fraction` instances via the :meth:" +"`str.format` method, the :func:`format` built-in function, or :ref:" +"`Formatted string literals `." msgstr "" -#: ../../library/fractions.rst:212 +#: ../../library/fractions.rst:213 msgid "" "If the ``format_spec`` format specification string does not end with one of " "the presentation types ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``, ``'G'`` " @@ -268,7 +270,7 @@ msgid "" "exact integer. The zero-fill flag ``'0'`` is not supported." msgstr "" -#: ../../library/fractions.rst:222 +#: ../../library/fractions.rst:223 msgid "" "If the ``format_spec`` format specification string ends with one of the " "presentation types ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``, ``'G'`` or " @@ -276,11 +278,11 @@ msgid "" "type in the :ref:`formatspec` section." msgstr "" -#: ../../library/fractions.rst:227 +#: ../../library/fractions.rst:228 msgid "Here are some examples::" msgstr "" -#: ../../library/fractions.rst:229 +#: ../../library/fractions.rst:230 msgid "" ">>> from fractions import Fraction\n" ">>> format(Fraction(103993, 33102), '_')\n" @@ -320,10 +322,10 @@ msgstr "" ">>> \"{:.2%} price increase\".format(Fraction(new_price, old_price) - 1)\n" "'34.67% price increase'" -#: ../../library/fractions.rst:251 +#: ../../library/fractions.rst:252 msgid "Module :mod:`numbers`" msgstr ":mod:`numbers` 模組" -#: ../../library/fractions.rst:252 +#: ../../library/fractions.rst:253 msgid "The abstract base classes making up the numeric tower." msgstr "" diff --git a/library/numbers.po b/library/numbers.po index db32c6ca63..d33387bbdc 100644 --- a/library/numbers.po +++ b/library/numbers.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-22 08:51+0000\n" +"POT-Creation-Date: 2025-08-06 00:17+0000\n" "PO-Revision-Date: 2022-11-16 04:57+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -120,9 +120,15 @@ msgstr "" ":attr:`~Rational.numerator` 和 :attr:`~Rational.denominator` 的值必須是 :" "class:`Integral` 的實例且 :attr:`~Rational.denominator` 要是正數。" -#: ../../library/numbers.rst:72 ../../library/numbers.rst:76 -msgid "Abstract." -msgstr "為抽象的。" +#: ../../library/numbers.rst:72 +#, fuzzy +msgid "Abstract. The numerator of this rational number." +msgstr "為抽象的。取得該數值的實數部分。" + +#: ../../library/numbers.rst:76 +#, fuzzy +msgid "Abstract. The denominator of this rational number." +msgstr "為抽象的。取得該數值的實數部分。" #: ../../library/numbers.rst:81 msgid "" @@ -420,3 +426,6 @@ msgstr "" "__add__, __radd__ = _operator_fallbacks(_add, operator.add)\n" "\n" "# ..." + +#~ msgid "Abstract." +#~ msgstr "為抽象的。" From 1f672a1e0269d0e41ca638475d1da87003238da5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 7 Aug 2025 00:19:24 +0000 Subject: [PATCH 07/23] sync with cpython 7762de25 --- library/warnings.po | 30 ++-- reference/compound_stmts.po | 286 ++++++++++++++++++------------------ 2 files changed, 159 insertions(+), 157 deletions(-) diff --git a/library/warnings.po b/library/warnings.po index dac5cbe821..136d899866 100644 --- a/library/warnings.po +++ b/library/warnings.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-03 00:14+0000\n" +"POT-Creation-Date: 2025-08-07 00:18+0000\n" "PO-Revision-Date: 2025-07-14 13:00+0800\n" "Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -406,8 +406,8 @@ msgid "" "If a warning is reported and doesn't match any registered filter then the " "\"default\" action is applied (hence its name)." msgstr "" -"如果一個警告被回報且不匹配任何已註冊的過濾器,則會套用 \"default\" 動作(因此得" -"名)。" +"如果一個警告被回報且不匹配任何已註冊的過濾器,則會套用 \"default\" 動作(因此" +"得名)。" #: ../../library/warnings.rst:185 msgid "Repeated Warning Suppression Criteria" @@ -937,9 +937,10 @@ msgstr "" " lower.one_way(**kw)" #: ../../library/warnings.rst:453 +#, fuzzy msgid "" "This makes the warning refer to both the ``example.lower.one_way()`` and " -"``package.higher.another_way()`` call sites only from calling code living " +"``example.higher.another_way()`` call sites only from calling code living " "outside of ``example`` package." msgstr "" "這使得警告只會從存在於 ``example`` 套件之外的呼叫程式碼中,指向 ``example." @@ -983,8 +984,9 @@ msgid "" "displaying source for modules found in zipfiles or other non-filesystem " "import sources)." msgstr "" -"*module_globals*\\ (如果提供)應該是發出警告的程式碼所使用的全域命名空間。(此" -"引數用於支援顯示在 zip 檔案或其他非檔案系統引入來源中找到的模組的原始碼)。" +"*module_globals*\\ (如果提供)應該是發出警告的程式碼所使用的全域命名空間。" +"(此引數用於支援顯示在 zip 檔案或其他非檔案系統引入來源中找到的模組的原始" +"碼)。" #: ../../library/warnings.rst:486 msgid "Add the *source* parameter." @@ -1124,9 +1126,10 @@ msgid "" msgstr "" "由 *category* 指定的警告將在使用已棄用物件時於 runtime 發出。對於函式,這發生" "在呼叫時;對於類別,發生在實例化和建立子類別時。如果 *category* 是 ``None``," -"則在 runtime 不會發出警告。*stacklevel* 決定了警告發出的位置。如果它是 ``1``\\ " -"(預設值),警告會在已棄用物件的直接呼叫者處發出;如果更高,它會在堆疊的更上" -"層發出。靜態型別檢查器的行為不受 *category* 和 *stacklevel* 引數的影響。" +"則在 runtime 不會發出警告。*stacklevel* 決定了警告發出的位置。如果它是 " +"``1``\\ (預設值),警告會在已棄用物件的直接呼叫者處發出;如果更高,它會在堆" +"疊的更上層發出。靜態型別檢查器的行為不受 *category* 和 *stacklevel* 引數的影" +"響。" #: ../../library/warnings.rst:577 msgid "" @@ -1159,10 +1162,11 @@ msgid "" "has attributes with the same names as the arguments to :func:`showwarning`." msgstr "" "一個情境管理器,它會複製並在退出時恢復警告過濾器和 :func:`showwarning` 函式。" -"如果 *record* 引數為 :const:`False`\\ (預設值),情境管理器在進入時回傳 :class:" -"`None`。如果 *record* 為 :const:`True`,則會回傳一個串列,該串列會由自訂的 :" -"func:`showwarning` 函式(該函式也會抑制對 ``sys.stdout`` 的輸出)所看到的物件" -"逐步填充。串列中的每個物件都具有與 :func:`showwarning` 的引數同名的屬性。" +"如果 *record* 引數為 :const:`False`\\ (預設值),情境管理器在進入時回傳 :" +"class:`None`。如果 *record* 為 :const:`True`,則會回傳一個串列,該串列會由自" +"訂的 :func:`showwarning` 函式(該函式也會抑制對 ``sys.stdout`` 的輸出)所看到" +"的物件逐步填充。串列中的每個物件都具有與 :func:`showwarning` 的引數同名的屬" +"性。" #: ../../library/warnings.rst:602 msgid "" diff --git a/reference/compound_stmts.po b/reference/compound_stmts.po index 9930b44306..a60aae4a99 100644 --- a/reference/compound_stmts.po +++ b/reference/compound_stmts.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-01-22 00:13+0000\n" +"POT-Creation-Date: 2025-08-07 00:18+0000\n" "PO-Revision-Date: 2018-05-23 16:17+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,10 +33,10 @@ msgstr "" msgid "" "The :keyword:`if`, :keyword:`while` and :keyword:`for` statements implement " "traditional control flow constructs. :keyword:`try` specifies exception " -"handlers and/or cleanup code for a group of statements, while " -"the :keyword:`with` statement allows the execution of initialization and " -"finalization code around a block of code. Function and class definitions " -"are also syntactically compound statements." +"handlers and/or cleanup code for a group of statements, while the :keyword:" +"`with` statement allows the execution of initialization and finalization " +"code around a block of code. Function and class definitions are also " +"syntactically compound statements." msgstr "" #: ../../reference/compound_stmts.rst:26 @@ -78,8 +78,8 @@ msgid "" "Note that statements always end in a ``NEWLINE`` possibly followed by a " "``DEDENT``. Also note that optional continuation clauses always begin with " "a keyword that cannot start a statement, thus there are no ambiguities (the " -"'dangling :keyword:`else`' problem is solved in Python by requiring " -"nested :keyword:`if` statements to be indented)." +"'dangling :keyword:`else`' problem is solved in Python by requiring nested :" +"keyword:`if` statements to be indented)." msgstr "" #: ../../reference/compound_stmts.rst:75 @@ -127,9 +127,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:133 msgid "" "A :keyword:`break` statement executed in the first suite terminates the loop " -"without executing the :keyword:`!else` clause's suite. " -"A :keyword:`continue` statement executed in the first suite skips the rest " -"of the suite and goes back to testing the expression." +"without executing the :keyword:`!else` clause's suite. A :keyword:" +"`continue` statement executed in the first suite skips the rest of the suite " +"and goes back to testing the expression." msgstr "" #: ../../reference/compound_stmts.rst:142 @@ -144,23 +144,22 @@ msgstr "" #: ../../reference/compound_stmts.rst:160 msgid "" -"The ``starred_list`` expression is evaluated once; it should yield " -"an :term:`iterable` object. An :term:`iterator` is created for that " -"iterable. The first item provided by the iterator is then assigned to the " -"target list using the standard rules for assignments " -"(see :ref:`assignment`), and the suite is executed. This repeats for each " -"item provided by the iterator. When the iterator is exhausted, the suite in " -"the :keyword:`!else` clause, if present, is executed, and the loop " -"terminates." +"The ``starred_list`` expression is evaluated once; it should yield an :term:" +"`iterable` object. An :term:`iterator` is created for that iterable. The " +"first item provided by the iterator is then assigned to the target list " +"using the standard rules for assignments (see :ref:`assignment`), and the " +"suite is executed. This repeats for each item provided by the iterator. " +"When the iterator is exhausted, the suite in the :keyword:`!else` clause, if " +"present, is executed, and the loop terminates." msgstr "" #: ../../reference/compound_stmts.rst:173 msgid "" "A :keyword:`break` statement executed in the first suite terminates the loop " -"without executing the :keyword:`!else` clause's suite. " -"A :keyword:`continue` statement executed in the first suite skips the rest " -"of the suite and continues with the next item, or with the :keyword:`!else` " -"clause if there is no next item." +"without executing the :keyword:`!else` clause's suite. A :keyword:" +"`continue` statement executed in the first suite skips the rest of the suite " +"and continues with the next item, or with the :keyword:`!else` clause if " +"there is no next item." msgstr "" #: ../../reference/compound_stmts.rst:179 @@ -204,9 +203,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:231 msgid "" -"Additional information on exceptions can be found in " -"section :ref:`exceptions`, and information on using the :keyword:`raise` " -"statement to generate exceptions may be found in section :ref:`raise`." +"Additional information on exceptions can be found in section :ref:" +"`exceptions`, and information on using the :keyword:`raise` statement to " +"generate exceptions may be found in section :ref:`raise`." msgstr "" #: ../../reference/compound_stmts.rst:239 @@ -252,13 +251,13 @@ msgstr "" #: ../../reference/compound_stmts.rst:267 msgid "" "When a matching :keyword:`!except` clause is found, the exception is " -"assigned to the target specified after the :keyword:`!as` keyword in " -"that :keyword:`!except` clause, if present, and the :keyword:`!except` " -"clause's suite is executed. All :keyword:`!except` clauses must have an " -"executable block. When the end of this block is reached, execution continues " -"normally after the entire :keyword:`try` statement. (This means that if two " -"nested handlers exist for the same exception, and the exception occurs in " -"the :keyword:`!try` clause of the inner handler, the outer handler will not " +"assigned to the target specified after the :keyword:`!as` keyword in that :" +"keyword:`!except` clause, if present, and the :keyword:`!except` clause's " +"suite is executed. All :keyword:`!except` clauses must have an executable " +"block. When the end of this block is reached, execution continues normally " +"after the entire :keyword:`try` statement. (This means that if two nested " +"handlers exist for the same exception, and the exception occurs in the :" +"keyword:`!try` clause of the inner handler, the outer handler will not " "handle the exception.)" msgstr "" @@ -356,15 +355,15 @@ msgstr ":keyword:`!except*` 子句" #: ../../reference/compound_stmts.rst:335 msgid "" -"The :keyword:`!except*` clause(s) are used for " -"handling :exc:`ExceptionGroup`\\s. The exception type for matching is " -"interpreted as in the case of :keyword:`except`, but in the case of " -"exception groups we can have partial matches when the type matches some of " -"the exceptions in the group. This means that multiple :keyword:`!except*` " -"clauses can execute, each handling part of the exception group. Each clause " -"executes at most once and handles an exception group of all matching " -"exceptions. Each exception in the group is handled by at most " -"one :keyword:`!except*` clause, the first that matches it. ::" +"The :keyword:`!except*` clause(s) are used for handling :exc:" +"`ExceptionGroup`\\s. The exception type for matching is interpreted as in " +"the case of :keyword:`except`, but in the case of exception groups we can " +"have partial matches when the type matches some of the exceptions in the " +"group. This means that multiple :keyword:`!except*` clauses can execute, " +"each handling part of the exception group. Each clause executes at most once " +"and handles an exception group of all matching exceptions. Each exception " +"in the group is handled by at most one :keyword:`!except*` clause, the first " +"that matches it. ::" msgstr "" #: ../../reference/compound_stmts.rst:345 @@ -428,8 +427,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:384 msgid "" "It is not possible to mix :keyword:`except` and :keyword:`!except*` in the " -"same :keyword:`try`. :keyword:`break`, :keyword:`continue` " -"and :keyword:`return` cannot appear in an :keyword:`!except*` clause." +"same :keyword:`try`. The :keyword:`break`, :keyword:`continue`, and :keyword:" +"`return` statements cannot appear in an :keyword:`!except*` clause." msgstr "" #: ../../reference/compound_stmts.rst:399 @@ -439,10 +438,10 @@ msgstr ":keyword:`!else` 子句" #: ../../reference/compound_stmts.rst:401 msgid "" "The optional :keyword:`!else` clause is executed if the control flow leaves " -"the :keyword:`try` suite, no exception was raised, and " -"no :keyword:`return`, :keyword:`continue`, or :keyword:`break` statement was " -"executed. Exceptions in the :keyword:`!else` clause are not handled by the " -"preceding :keyword:`except` clauses." +"the :keyword:`try` suite, no exception was raised, and no :keyword:" +"`return`, :keyword:`continue`, or :keyword:`break` statement was executed. " +"Exceptions in the :keyword:`!else` clause are not handled by the preceding :" +"keyword:`except` clauses." msgstr "" #: ../../reference/compound_stmts.rst:413 @@ -451,16 +450,16 @@ msgstr ":keyword:`!finally` 子句" #: ../../reference/compound_stmts.rst:415 msgid "" -"If :keyword:`!finally` is present, it specifies a 'cleanup' handler. " -"The :keyword:`try` clause is executed, including any :keyword:`except` " -"and :keyword:`else` clauses. If an exception occurs in any of the clauses " -"and is not handled, the exception is temporarily saved. The :keyword:`!" -"finally` clause is executed. If there is a saved exception it is re-raised " -"at the end of the :keyword:`!finally` clause. If the :keyword:`!finally` " -"clause raises another exception, the saved exception is set as the context " -"of the new exception. If the :keyword:`!finally` clause executes " -"a :keyword:`return`, :keyword:`break` or :keyword:`continue` statement, the " -"saved exception is discarded::" +"If :keyword:`!finally` is present, it specifies a 'cleanup' handler. The :" +"keyword:`try` clause is executed, including any :keyword:`except` and :" +"keyword:`else` clauses. If an exception occurs in any of the clauses and is " +"not handled, the exception is temporarily saved. The :keyword:`!finally` " +"clause is executed. If there is a saved exception it is re-raised at the " +"end of the :keyword:`!finally` clause. If the :keyword:`!finally` clause " +"raises another exception, the saved exception is set as the context of the " +"new exception. If the :keyword:`!finally` clause executes a :keyword:" +"`return`, :keyword:`break` or :keyword:`continue` statement, the saved " +"exception is discarded::" msgstr "" #: ../../reference/compound_stmts.rst:425 @@ -527,8 +526,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:460 msgid "" -"Prior to Python 3.8, a :keyword:`continue` statement was illegal in " -"the :keyword:`!finally` clause due to a problem with the implementation." +"Prior to Python 3.8, a :keyword:`continue` statement was illegal in the :" +"keyword:`!finally` clause due to a problem with the implementation." msgstr "" #: ../../reference/compound_stmts.rst:469 @@ -539,8 +538,8 @@ msgstr ":keyword:`!with` 陳述式" msgid "" "The :keyword:`with` statement is used to wrap the execution of a block with " "methods defined by a context manager (see section :ref:`context-managers`). " -"This allows common :keyword:`try`...\\ :keyword:`except`..." -"\\ :keyword:`finally` usage patterns to be encapsulated for convenient reuse." +"This allows common :keyword:`try`...\\ :keyword:`except`...\\ :keyword:" +"`finally` usage patterns to be encapsulated for convenient reuse." msgstr "" #: ../../reference/compound_stmts.rst:488 @@ -551,8 +550,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:490 msgid "" -"The context expression (the expression given in the :token:`~python-" -"grammar:with_item`) is evaluated to obtain a context manager." +"The context expression (the expression given in the :token:`~python-grammar:" +"with_item`) is evaluated to obtain a context manager." msgstr "" #: ../../reference/compound_stmts.rst:493 @@ -576,11 +575,11 @@ msgstr "" #: ../../reference/compound_stmts.rst:504 msgid "" -"The :keyword:`with` statement guarantees that if " -"the :meth:`~object.__enter__` method returns without an error, " -"then :meth:`~object.__exit__` will always be called. Thus, if an error " -"occurs during the assignment to the target list, it will be treated the same " -"as an error occurring within the suite would be. See step 7 below." +"The :keyword:`with` statement guarantees that if the :meth:`~object." +"__enter__` method returns without an error, then :meth:`~object.__exit__` " +"will always be called. Thus, if an error occurs during the assignment to the " +"target list, it will be treated the same as an error occurring within the " +"suite would be. See step 7 below." msgstr "" #: ../../reference/compound_stmts.rst:510 @@ -591,16 +590,16 @@ msgstr "" msgid "" "The context manager's :meth:`~object.__exit__` method is invoked. If an " "exception caused the suite to be exited, its type, value, and traceback are " -"passed as arguments to :meth:`~object.__exit__`. Otherwise, " -"three :const:`None` arguments are supplied." +"passed as arguments to :meth:`~object.__exit__`. Otherwise, three :const:" +"`None` arguments are supplied." msgstr "" #: ../../reference/compound_stmts.rst:517 msgid "" -"If the suite was exited due to an exception, and the return value from " -"the :meth:`~object.__exit__` method was false, the exception is reraised. " -"If the return value was true, the exception is suppressed, and execution " -"continues with the statement following the :keyword:`with` statement." +"If the suite was exited due to an exception, and the return value from the :" +"meth:`~object.__exit__` method was false, the exception is reraised. If the " +"return value was true, the exception is suppressed, and execution continues " +"with the statement following the :keyword:`with` statement." msgstr "" #: ../../reference/compound_stmts.rst:522 @@ -668,8 +667,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:550 msgid "" -"With more than one item, the context managers are processed as if " -"multiple :keyword:`with` statements were nested::" +"With more than one item, the context managers are processed as if multiple :" +"keyword:`with` statements were nested::" msgstr "" #: ../../reference/compound_stmts.rst:553 @@ -1048,8 +1047,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:846 msgid "" -"The rule ``strings`` and the token ``NUMBER`` are defined in " -"the :doc:`standard Python grammar <./grammar>`. Triple-quoted strings are " +"The rule ``strings`` and the token ``NUMBER`` are defined in the :doc:" +"`standard Python grammar <./grammar>`. Triple-quoted strings are " "supported. Raw strings and byte strings are supported. :ref:`f-strings` " "are not supported." msgstr "" @@ -1079,8 +1078,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:869 msgid "" "A single underscore ``_`` is not a capture pattern (this is what ``!'_'`` " -"expresses). It is instead treated as a :token:`~python-" -"grammar:wildcard_pattern`." +"expresses). It is instead treated as a :token:`~python-grammar:" +"wildcard_pattern`." msgstr "" #: ../../reference/compound_stmts.rst:873 @@ -1141,8 +1140,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:918 msgid "" -"In simple terms ``NAME1.NAME2`` will succeed only if `` == " -"NAME1.NAME2``" +"In simple terms ``NAME1.NAME2`` will succeed only if `` == NAME1." +"NAME2``" msgstr "" #: ../../reference/compound_stmts.rst:922 @@ -1354,8 +1353,8 @@ msgstr "" msgid "" "Key-value pairs are matched using the two-argument form of the mapping " "subject's ``get()`` method. Matched key-value pairs must already be present " -"in the mapping, and not created on-the-fly via :meth:`__missing__` " -"or :meth:`~object.__getitem__`." +"in the mapping, and not created on-the-fly via :meth:`__missing__` or :meth:" +"`~object.__getitem__`." msgstr "" #: ../../reference/compound_stmts.rst:1064 @@ -1402,14 +1401,14 @@ msgstr "" #: ../../reference/compound_stmts.rst:1094 msgid "" -"If ``name_or_attr`` is not an instance of the builtin :class:`type` , " -"raise :exc:`TypeError`." +"If ``name_or_attr`` is not an instance of the builtin :class:`type` , raise :" +"exc:`TypeError`." msgstr "" #: ../../reference/compound_stmts.rst:1097 msgid "" -"If the subject value is not an instance of ``name_or_attr`` (tested " -"via :func:`isinstance`), the class pattern fails." +"If the subject value is not an instance of ``name_or_attr`` (tested via :" +"func:`isinstance`), the class pattern fails." msgstr "" #: ../../reference/compound_stmts.rst:1100 @@ -1475,14 +1474,14 @@ msgstr "" #: ../../reference/compound_stmts.rst:1133 msgid "" -"If the returned value is not a tuple, the conversion fails " -"and :exc:`TypeError` is raised." +"If the returned value is not a tuple, the conversion fails and :exc:" +"`TypeError` is raised." msgstr "" #: ../../reference/compound_stmts.rst:1136 msgid "" -"If there are more positional patterns than " -"``len(cls.__match_args__)``, :exc:`TypeError` is raised." +"If there are more positional patterns than ``len(cls.__match_args__)``, :exc:" +"`TypeError` is raised." msgstr "" #: ../../reference/compound_stmts.rst:1139 @@ -1603,8 +1602,8 @@ msgstr "函式定義" #: ../../reference/compound_stmts.rst:1208 msgid "" -"A function definition defines a user-defined function object (see " -"section :ref:`types`):" +"A function definition defines a user-defined function object (see section :" +"ref:`types`):" msgstr "" #: ../../reference/compound_stmts.rst:1230 @@ -1664,9 +1663,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:1260 msgid "" -"Functions may be decorated with any valid :token:`~python-" -"grammar:assignment_expression`. Previously, the grammar was much more " -"restrictive; see :pep:`614` for details." +"Functions may be decorated with any valid :token:`~python-grammar:" +"assignment_expression`. Previously, the grammar was much more restrictive; " +"see :pep:`614` for details." msgstr "" #: ../../reference/compound_stmts.rst:1265 @@ -1719,18 +1718,18 @@ msgstr "" #: ../../reference/compound_stmts.rst:1309 msgid "" -"Function call semantics are described in more detail in " -"section :ref:`calls`. A function call always assigns values to all " -"parameters mentioned in the parameter list, either from positional " -"arguments, from keyword arguments, or from default values. If the form " -"\"``*identifier``\" is present, it is initialized to a tuple receiving any " -"excess positional parameters, defaulting to the empty tuple. If the form " -"\"``**identifier``\" is present, it is initialized to a new ordered mapping " -"receiving any excess keyword arguments, defaulting to a new empty mapping of " -"the same type. Parameters after \"``*``\" or \"``*identifier``\" are " -"keyword-only parameters and may only be passed by keyword arguments. " -"Parameters before \"``/``\" are positional-only parameters and may only be " -"passed by positional arguments." +"Function call semantics are described in more detail in section :ref:" +"`calls`. A function call always assigns values to all parameters mentioned " +"in the parameter list, either from positional arguments, from keyword " +"arguments, or from default values. If the form \"``*identifier``\" is " +"present, it is initialized to a tuple receiving any excess positional " +"parameters, defaulting to the empty tuple. If the form \"``**identifier``\" " +"is present, it is initialized to a new ordered mapping receiving any excess " +"keyword arguments, defaulting to a new empty mapping of the same type. " +"Parameters after \"``*``\" or \"``*identifier``\" are keyword-only " +"parameters and may only be passed by keyword arguments. Parameters before " +"\"``/``\" are positional-only parameters and may only be passed by " +"positional arguments." msgstr "" #: ../../reference/compound_stmts.rst:1321 @@ -1749,8 +1748,8 @@ msgid "" "of the form \"``-> expression``\" after the parameter list. These " "annotations can be any valid Python expression. The presence of annotations " "does not change the semantics of a function. The annotation values are " -"available as values of a dictionary keyed by the parameters' names in " -"the :attr:`__annotations__` attribute of the function object. If the " +"available as values of a dictionary keyed by the parameters' names in the :" +"attr:`__annotations__` attribute of the function object. If the " "``annotations`` import from :mod:`__future__` is used, annotations are " "preserved as strings at runtime which enables postponed evaluation. " "Otherwise, they are evaluated when the function definition is executed. In " @@ -1771,8 +1770,8 @@ msgid "" "described in section :ref:`lambda`. Note that the lambda expression is " "merely a shorthand for a simplified function definition; a function defined " "in a \":keyword:`def`\" statement can be passed around or assigned to " -"another name just like a function defined by a lambda expression. The " -"\":keyword:`!def`\" form is actually more powerful since it allows the " +"another name just like a function defined by a lambda expression. The \":" +"keyword:`!def`\" form is actually more powerful since it allows the " "execution of multiple statements and annotations." msgstr "" @@ -1870,14 +1869,14 @@ msgstr "" #: ../../reference/compound_stmts.rst:1423 msgid "" -"The class's suite is then executed in a new execution frame " -"(see :ref:`naming`), using a newly created local namespace and the original " -"global namespace. (Usually, the suite contains mostly function " -"definitions.) When the class's suite finishes execution, its execution " -"frame is discarded but its local namespace is saved. [#]_ A class object is " -"then created using the inheritance list for the base classes and the saved " -"local namespace for the attribute dictionary. The class name is bound to " -"this class object in the original local namespace." +"The class's suite is then executed in a new execution frame (see :ref:" +"`naming`), using a newly created local namespace and the original global " +"namespace. (Usually, the suite contains mostly function definitions.) When " +"the class's suite finishes execution, its execution frame is discarded but " +"its local namespace is saved. [#]_ A class object is then created using the " +"inheritance list for the base classes and the saved local namespace for the " +"attribute dictionary. The class name is bound to this class object in the " +"original local namespace." msgstr "" #: ../../reference/compound_stmts.rst:1432 @@ -1924,9 +1923,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:1456 msgid "" -"Classes may be decorated with any valid :token:`~python-" -"grammar:assignment_expression`. Previously, the grammar was much more " -"restrictive; see :pep:`614` for details." +"Classes may be decorated with any valid :token:`~python-grammar:" +"assignment_expression`. Previously, the grammar was much more restrictive; " +"see :pep:`614` for details." msgstr "" #: ../../reference/compound_stmts.rst:1461 @@ -1934,8 +1933,8 @@ msgid "" "A list of :ref:`type parameters ` may be given in square " "brackets immediately after the class's name. This indicates to static type " "checkers that the class is generic. At runtime, the type parameters can be " -"retrieved from the class's :attr:`~type.__type_params__` attribute. " -"See :ref:`generic-classes` for more." +"retrieved from the class's :attr:`~type.__type_params__` attribute. See :ref:" +"`generic-classes` for more." msgstr "" #: ../../reference/compound_stmts.rst:1470 @@ -2179,9 +2178,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:1645 msgid "" -":ref:`Functions ` (including :ref:`coroutines `), :ref:`classes ` and :ref:`type aliases ` may contain a " -"type parameter list::" +":ref:`Functions ` (including :ref:`coroutines `), :ref:" +"`classes ` and :ref:`type aliases ` may contain a type " +"parameter list::" msgstr "" #: ../../reference/compound_stmts.rst:1649 @@ -2238,9 +2237,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:1678 msgid "" -"Generic functions, classes, and type aliases have " -"a :attr:`~definition.__type_params__` attribute listing their type " -"parameters." +"Generic functions, classes, and type aliases have a :attr:`~definition." +"__type_params__` attribute listing their type parameters." msgstr "" #: ../../reference/compound_stmts.rst:1681 @@ -2383,8 +2381,8 @@ msgid "" "Here ``annotation-def`` indicates an :ref:`annotation scope `, which is not actually bound to any name at runtime. (One other " "liberty is taken in the translation: the syntax does not go through " -"attribute access on the :mod:`typing` module, but creates an instance " -"of :data:`typing.TypeVar` directly.)" +"attribute access on the :mod:`typing` module, but creates an instance of :" +"data:`typing.TypeVar` directly.)" msgstr "" #: ../../reference/compound_stmts.rst:1760 @@ -2412,8 +2410,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:1771 msgid "" -"Except for the :ref:`lazy evaluation ` of " -"the :class:`~typing.TypeVar` bound, this is equivalent to::" +"Except for the :ref:`lazy evaluation ` of the :class:" +"`~typing.TypeVar` bound, this is equivalent to::" msgstr "" #: ../../reference/compound_stmts.rst:1774 @@ -2476,9 +2474,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:1815 msgid "" -"Here again ``annotation-def`` (not a real keyword) indicates " -"an :ref:`annotation scope `, and the name " -"``TYPE_PARAMS_OF_Bag`` is not actually bound at runtime." +"Here again ``annotation-def`` (not a real keyword) indicates an :ref:" +"`annotation scope `, and the name ``TYPE_PARAMS_OF_Bag`` " +"is not actually bound at runtime." msgstr "" #: ../../reference/compound_stmts.rst:1819 @@ -2565,9 +2563,9 @@ msgstr "註解" #: ../../reference/compound_stmts.rst:1865 msgid "" -"The exception is propagated to the invocation stack unless there is " -"a :keyword:`finally` clause which happens to raise another exception. That " -"new exception causes the old one to be lost." +"The exception is propagated to the invocation stack unless there is a :" +"keyword:`finally` clause which happens to raise another exception. That new " +"exception causes the old one to be lost." msgstr "" #: ../../reference/compound_stmts.rst:1869 @@ -2639,8 +2637,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:1895 msgid "" -"The standard library classes :class:`dict` " -"and :class:`types.MappingProxyType` are mappings." +"The standard library classes :class:`dict` and :class:`types." +"MappingProxyType` are mappings." msgstr "" #: ../../reference/compound_stmts.rst:1898 From 65a524048915c38bff746e725257f89306dc34b0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 8 Aug 2025 00:19:13 +0000 Subject: [PATCH 08/23] sync with cpython 4ad36035 --- library/difflib.po | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/library/difflib.po b/library/difflib.po index c0d1130505..f47345cb45 100644 --- a/library/difflib.po +++ b/library/difflib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-08-08 00:17+0000\n" "PO-Revision-Date: 2016-11-19 00:29+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -404,15 +404,14 @@ msgstr "" #: ../../library/difflib.rst:354 msgid "" -"`Pattern Matching: The Gestalt Approach `_" +"`Pattern Matching: The Gestalt Approach `_" msgstr "" #: ../../library/difflib.rst:355 msgid "" "Discussion of a similar algorithm by John W. Ratcliff and D. E. Metzener. " -"This was published in `Dr. Dobb's Journal `_ in " -"July, 1988." +"This was published in Dr. Dobb's Journal in July, 1988." msgstr "" #: ../../library/difflib.rst:362 @@ -781,7 +780,7 @@ msgstr "" #: ../../library/difflib.rst:649 msgid "The :class:`Differ` class has this constructor:" -msgstr ":class:`Differ` 類別有這個建構函式:" +msgstr ":class:`Differ` 類別有這個建構函式:" #: ../../library/difflib.rst:655 msgid "" From 30cbc8d475fb79637a1cdc0786d5e26cb756d3f0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 9 Aug 2025 00:18:16 +0000 Subject: [PATCH 09/23] sync with cpython aa4525fc --- extending/extending.po | 8 +- library/functions.po | 5 +- library/typing.po | 576 +++++++++++++++++++-------------------- library/unittest.mock.po | 9 +- 4 files changed, 295 insertions(+), 303 deletions(-) diff --git a/extending/extending.po b/extending/extending.po index 9818750cbd..b8532c668c 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-06 00:17+0000\n" +"POT-Creation-Date: 2025-08-09 00:16+0000\n" "PO-Revision-Date: 2025-02-17 14:34+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -505,9 +505,9 @@ msgstr "" #: ../../extending/extending.rst:242 msgid "" -"Since :c:data:`!SpamError` is a global variable, it will be overwitten every " -"time the module is reinitialized, when the :c:data:`Py_mod_exec` function is " -"called." +"Since :c:data:`!SpamError` is a global variable, it will be overwritten " +"every time the module is reinitialized, when the :c:data:`Py_mod_exec` " +"function is called." msgstr "" #: ../../extending/extending.rst:245 diff --git a/library/functions.po b/library/functions.po index fb90fa4b56..fee1a48f99 100644 --- a/library/functions.po +++ b/library/functions.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-09 00:16+0000\n" "PO-Revision-Date: 2024-05-06 17:06+0800\n" "Last-Translator: KNChiu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -2738,8 +2738,9 @@ msgstr "" "的 ``pow(exp, exp)`` 等價於次方運算子:``base**exp``。" #: ../../library/functions.rst:1568 +#, fuzzy msgid "" -"The arguments must have numeric types. With mixed operand types, the " +"When arguments are builtin numeric types with mixed operand types, the " "coercion rules for binary arithmetic operators apply. For :class:`int` " "operands, the result has the same type as the operands (after coercion) " "unless the second argument is negative; in that case, all arguments are " diff --git a/library/typing.po b/library/typing.po index 2306bfda2b..d2b8a3b8c1 100644 --- a/library/typing.po +++ b/library/typing.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-06 02:41+0000\n" +"POT-Creation-Date: 2025-08-09 00:16+0000\n" "PO-Revision-Date: 2024-07-11 11:12+0800\n" "Last-Translator: Li-Hung Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -55,8 +55,8 @@ msgstr "" msgid "" "The function ``surface_area_of_cube`` takes an argument expected to be an " "instance of :class:`float`, as indicated by the :term:`type hint` " -"``edge_length: float``. The function is expected to return an instance " -"of :class:`str`, as indicated by the ``-> str`` hint." +"``edge_length: float``. The function is expected to return an instance of :" +"class:`str`, as indicated by the ``-> str`` hint." msgstr "" "函式 ``surface_area_of_cube`` 需要一個引數且預期是一個 :class:`float` 的實" "例,如 ``edge_length: float`` 所指出的\\ :term:`型別提示 `。這個函" @@ -73,17 +73,18 @@ msgstr "" #: ../../library/typing.rst:42 msgid "" -"New features are frequently added to the ``typing`` module. " -"The :pypi:`typing_extensions` package provides backports of these new " -"features to older versions of Python." +"New features are frequently added to the ``typing`` module. The :pypi:" +"`typing_extensions` package provides backports of these new features to " +"older versions of Python." msgstr "" "新功能會頻繁的新增至 ``typing`` 模組中。:pypi:`typing_extensions` 套件為這些" "新功能提供了 backport(向後移植的)版本,提供給舊版本的 Python 使用。" #: ../../library/typing.rst:48 +#, fuzzy msgid "" -"`\"Typing cheat sheet\" `_" +"`Typing cheat sheet `_" msgstr "" "`\"型別小抄 (Typing cheat sheet)\" `_" @@ -93,9 +94,10 @@ msgid "A quick overview of type hints (hosted at the mypy docs)" msgstr "型別提示的快速預覽(發布於 mypy 的文件中)" #: ../../library/typing.rst:51 +#, fuzzy msgid "" -"\"Type System Reference\" section of `the mypy docs `_" +"Type System Reference section of `the mypy docs `_" msgstr "" "`mypy 文件 `_\\ 的 \"型別系" "統參考資料 (Type System Reference)\" 章節" @@ -110,7 +112,8 @@ msgstr "" "多數 Python 型別檢查器中廣為使用。(某些部分依然是特定給 mypy 使用。)" #: ../../library/typing.rst:56 -msgid "`\"Static Typing with Python\" `_" +#, fuzzy +msgid "`Static Typing with Python `_" msgstr "" "`\"Python 的靜態型別 (Static Typing)\" `_" @@ -128,10 +131,11 @@ msgid "Specification for the Python Type System" msgstr "Python 型別系統的技術規範" #: ../../library/typing.rst:66 +#, fuzzy msgid "" "The canonical, up-to-date specification of the Python type system can be " -"found at `\"Specification for the Python type system\" `_." +"found at `Specification for the Python type system `_." msgstr "" "關於 Python 型別系統標準的 (canonical)、最新的技術規範可以在\\ `「Python 型別" "系統的技術規範」 `_\\ 找" @@ -147,9 +151,9 @@ msgid "" "an instance of :class:`TypeAliasType`. In this example, ``Vector`` and " "``list[float]`` will be treated equivalently by static type checkers::" msgstr "" -"一個型別別名被定義來使用 :keyword:`type` 陳述式,其建立" -"了 :class:`TypeAliasType` 的實例。在這個範例中,``Vector`` 及 " -"``list[float]`` 會被當作和靜態型別檢查器一樣同等對待: ::" +"一個型別別名被定義來使用 :keyword:`type` 陳述式,其建立了 :class:" +"`TypeAliasType` 的實例。在這個範例中,``Vector`` 及 ``list[float]`` 會被當作" +"和靜態型別檢查器一樣同等對待: ::" #: ../../library/typing.rst:79 msgid "" @@ -376,16 +380,15 @@ msgstr "註釋 callable 物件" #: ../../library/typing.rst:210 msgid "" -"Functions -- or other :term:`callable` objects -- can be annotated " -"using :class:`collections.abc.Callable` or " -"deprecated :data:`typing.Callable`. ``Callable[[int], str]`` signifies a " -"function that takes a single parameter of type :class:`int` and returns " -"a :class:`str`." +"Functions -- or other :term:`callable` objects -- can be annotated using :" +"class:`collections.abc.Callable` or deprecated :data:`typing.Callable`. " +"``Callable[[int], str]`` signifies a function that takes a single parameter " +"of type :class:`int` and returns a :class:`str`." msgstr "" -"函式,或者是其他 :term:`callable` 物件,可以使" -"用 :class:`collections.abc.Callable` 或以棄用的 :data:`typing.Callable` 進行" -"註釋。 ``Callable[[int], str]`` 象徵為一個函式,可以接受一個型別" -"為 :class:`int` 的引數,並回傳一個 :class:`str`。" +"函式,或者是其他 :term:`callable` 物件,可以使用 :class:`collections.abc." +"Callable` 或以棄用的 :data:`typing.Callable` 進行註釋。 ``Callable[[int], " +"str]`` 象徵為一個函式,可以接受一個型別為 :class:`int` 的引數,並回傳一個 :" +"class:`str`。" #: ../../library/typing.rst:215 ../../library/typing.rst:3161 #: ../../library/typing.rst:3341 @@ -443,8 +446,8 @@ msgid "" "``Callable`` cannot express complex signatures such as functions that take a " "variadic number of arguments, :ref:`overloaded functions `, or " "functions that have keyword-only parameters. However, these signatures can " -"be expressed by defining a :class:`Protocol` class with " -"a :meth:`~object.__call__` method:" +"be expressed by defining a :class:`Protocol` class with a :meth:`~object." +"__call__` method:" msgstr "" "``Callable`` 不如有可變數量引數的函式、:func:`overloaded functions " "`、或是僅限關鍵字參數的函式,可以表示複雜簽名。然而,這些簽名可以透" @@ -494,11 +497,11 @@ msgstr "" #: ../../library/typing.rst:285 ../../library/typing.rst:3831 msgid "" -"``Callable`` now supports :class:`ParamSpec` and :data:`Concatenate`. " -"See :pep:`612` for more details." +"``Callable`` now supports :class:`ParamSpec` and :data:`Concatenate`. See :" +"pep:`612` for more details." msgstr "" -"``Callable`` 現已支援 :class:`ParamSpec` 以及 :data:`Concatenate`。請參" -"閱 :pep:`612` 閱讀詳細內容。" +"``Callable`` 現已支援 :class:`ParamSpec` 以及 :data:`Concatenate`。請參閱 :" +"pep:`612` 閱讀詳細內容。" #: ../../library/typing.rst:290 msgid "" @@ -603,10 +606,9 @@ msgstr "" #: ../../library/typing.rst:356 msgid "" ":class:`list` only accepts one type argument, so a type checker would emit " -"an error on the ``y`` assignment above. " -"Similarly, :class:`~collections.abc.Mapping` only accepts two type " -"arguments: the first indicates the type of the keys, and the second " -"indicates the type of the values." +"an error on the ``y`` assignment above. Similarly, :class:`~collections.abc." +"Mapping` only accepts two type arguments: the first indicates the type of " +"the keys, and the second indicates the type of the values." msgstr "" ":class:`list` 只接受一個型別引數,所以型別檢查器可能在上述 ``y`` 賦值 " "(assignment) 觸發錯誤。類似的範例,:class:`~collections.abc.Mapping` 只接受兩" @@ -617,8 +619,8 @@ msgstr "" msgid "" "Unlike most other Python containers, however, it is common in idiomatic " "Python code for tuples to have elements which are not all of the same type. " -"For this reason, tuples are special-cased in Python's typing " -"system. :class:`tuple` accepts *any number* of type arguments::" +"For this reason, tuples are special-cased in Python's typing system. :class:" +"`tuple` accepts *any number* of type arguments::" msgstr "" "然而,與其他多數的 Python 容器不同,在慣用的 (idiomatic) Python 程式碼中,元" "組可以擁有不完全相同型別的元素是相當常見的。為此,元組在 Python 的加註型別系" @@ -678,10 +680,9 @@ msgstr "類別物件的型別" #: ../../library/typing.rst:403 msgid "" "A variable annotated with ``C`` may accept a value of type ``C``. In " -"contrast, a variable annotated with ``type[C]`` (or " -"deprecated :class:`typing.Type[C] `) may accept values that are " -"classes themselves -- specifically, it will accept the *class object* of " -"``C``. For example::" +"contrast, a variable annotated with ``type[C]`` (or deprecated :class:" +"`typing.Type[C] `) may accept values that are classes themselves -- " +"specifically, it will accept the *class object* of ``C``. For example::" msgstr "" "一個變數被註釋為 ``C`` 可以接受一個型別為 ``C`` 的值。相對的,一個變數備註解" "為 ``type[C]`` \\ (或已棄用的 :class:`typing.Type[C] `)\\ 可以接受本" @@ -720,9 +721,8 @@ msgstr "" #: ../../library/typing.rst:429 msgid "" -"The only legal parameters for :class:`type` are " -"classes, :data:`Any`, :ref:`type variables `, and unions of any of " -"these types. For example::" +"The only legal parameters for :class:`type` are classes, :data:`Any`, :ref:" +"`type variables `, and unions of any of these types. For example::" msgstr "" ":class:`type` 僅有的合法參數是類別、:data:`Any`、:ref:`型別變數 " "`\\ 以及這些型別任意組合成的聯集。舉例來說: ::" @@ -740,8 +740,8 @@ msgstr "" #: ../../library/typing.rst:441 msgid "" -"``type[Any]`` is equivalent to :class:`type`, which is the root of " -"Python's :ref:`metaclass hierarchy `." +"``type[Any]`` is equivalent to :class:`type`, which is the root of Python's :" +"ref:`metaclass hierarchy `." msgstr "" "``type[Any]`` 等價於 :class:`type` ,其為 Python :ref:`metaclass 階層結構 " "(hierachy) `。" @@ -752,9 +752,9 @@ msgstr "" #: ../../library/typing.rst:450 msgid "" -"A generator can be annotated using the generic " -"type :class:`Generator[YieldType, SendType, ReturnType] " -"`. For example::" +"A generator can be annotated using the generic type :class:" +"`Generator[YieldType, SendType, ReturnType] `. " +"For example::" msgstr "" #: ../../library/typing.rst:454 @@ -801,9 +801,8 @@ msgstr "" #: ../../library/typing.rst:478 msgid "" "Simple generators that only ever yield values can also be annotated as " -"having a return type of either :class:`Iterable[YieldType] " -"` or :class:`Iterator[YieldType] " -"`::" +"having a return type of either :class:`Iterable[YieldType] ` or :class:`Iterator[YieldType] `::" msgstr "" #: ../../library/typing.rst:483 @@ -818,8 +817,8 @@ msgstr "" msgid "" "Async generators are handled in a similar fashion, but don't expect a " "``ReturnType`` type argument (:class:`AsyncGenerator[YieldType, SendType] " -"`). The ``SendType`` argument defaults " -"to :const:`!None`, so the following definitions are equivalent::" +"`). The ``SendType`` argument defaults to :" +"const:`!None`, so the following definitions are equivalent::" msgstr "" #: ../../library/typing.rst:494 @@ -837,9 +836,9 @@ msgstr "" #: ../../library/typing.rst:504 msgid "" -"As in the synchronous case, :class:`AsyncIterable[YieldType] " -"` and :class:`AsyncIterator[YieldType] " -"` are available as well::" +"As in the synchronous case, :class:`AsyncIterable[YieldType] ` and :class:`AsyncIterator[YieldType] ` are available as well::" msgstr "" #: ../../library/typing.rst:509 @@ -908,8 +907,8 @@ msgstr "" #: ../../library/typing.rst:557 msgid "" "Generic classes implicitly inherit from :class:`Generic`. For compatibility " -"with Python 3.11 and lower, it is also possible to inherit explicitly " -"from :class:`Generic` to indicate a generic class::" +"with Python 3.11 and lower, it is also possible to inherit explicitly from :" +"class:`Generic` to indicate a generic class::" msgstr "" "泛型類別隱性繼承了 :class:`Generic`。為了相容 Python 3.11 及更早版本,也可以" "明確的繼承 :class:`Generic` 並指出是一個泛型類別: ::" @@ -943,8 +942,8 @@ msgstr "" #: ../../library/typing.rst:577 msgid "" -"A generic type can have any number of type variables. All varieties " -"of :class:`TypeVar` are permissible as parameters for a generic type::" +"A generic type can have any number of type variables. All varieties of :" +"class:`TypeVar` are permissible as parameters for a generic type::" msgstr "" "一個泛型型別可以有任意數量的型別變數。所有種類的 :class:`TypeVar` 都可以作為" "泛型型別的參數: ::" @@ -1089,9 +1088,9 @@ msgid "" "substitute a :class:`ParamSpec`::" msgstr "" "使用者定義的參數運算式 (parameter expression) 泛型一樣有支援,透過 ``[**P]`` " -"格式的參數規格變數來進行表示。對於上述作為參數規格變數的型別變數,將持續" -"被 :mod:`!typing` 模組視為一個特定的型別變數。對此,其中一個例外是一個型別列" -"表可以替代 :class:`ParamSpec`: ::" +"格式的參數規格變數來進行表示。對於上述作為參數規格變數的型別變數,將持續被 :" +"mod:`!typing` 模組視為一個特定的型別變數。對此,其中一個例外是一個型別列表可" +"以替代 :class:`ParamSpec`: ::" #: ../../library/typing.rst:671 msgid "" @@ -1169,11 +1168,11 @@ msgstr "" #: ../../library/typing.rst:703 msgid "" -":class:`Generic` can now be parameterized over parameter expressions. " -"See :class:`ParamSpec` and :pep:`612` for more details." +":class:`Generic` can now be parameterized over parameter expressions. See :" +"class:`ParamSpec` and :pep:`612` for more details." msgstr "" -":class:`Generic` 現在可以透過參數運算式來進行參數化。詳細內容請" -"見 :class:`ParamSpec` 以及 :pep:`612`。" +":class:`Generic` 現在可以透過參數運算式來進行參數化。詳細內容請見 :class:" +"`ParamSpec` 以及 :pep:`612`。" #: ../../library/typing.rst:707 msgid "" @@ -1196,8 +1195,8 @@ msgid "" "every type as being compatible with :data:`Any` and :data:`Any` as being " "compatible with every type." msgstr "" -":data:`Any` 是一種特別的型別。一個靜態型別檢查器會將每個型別視為可相容" -"於 :data:`Any` 且 :data:`Any` 也可以相容於每個型別。" +":data:`Any` 是一種特別的型別。一個靜態型別檢查器會將每個型別視為可相容於 :" +"data:`Any` 且 :data:`Any` 也可以相容於每個型別。" #: ../../library/typing.rst:720 msgid "" @@ -1227,11 +1226,11 @@ msgstr "" #: ../../library/typing.rst:738 msgid "" -"Notice that no type checking is performed when assigning a value of " -"type :data:`Any` to a more precise type. For example, the static type " -"checker did not report an error when assigning ``a`` to ``s`` even though " -"``s`` was declared to be of type :class:`str` and receives an :class:`int` " -"value at runtime!" +"Notice that no type checking is performed when assigning a value of type :" +"data:`Any` to a more precise type. For example, the static type checker did " +"not report an error when assigning ``a`` to ``s`` even though ``s`` was " +"declared to be of type :class:`str` and receives an :class:`int` value at " +"runtime!" msgstr "" "請注意,當賦予型別為 :data:`Any` 的值更精確的型別時,將不會執行任何型別檢查。" "舉例來說,靜態型別檢查器不會在 runtime 中,將 ``a`` 賦值給 ``s`` 的情況下回報" @@ -1272,8 +1271,8 @@ msgid "" "subtype of every other type." msgstr "" ":data:`Any` 的行為對比 :class:`object` 的行為。與 :data:`Any` 相似,所有的型" -"別會作為 :class:`object` 的子型別。然而,不像 :data:`Any`,反之不亦" -"然::class:`object` 並\\ *不是*\\一個其他型別的子型別。" +"別會作為 :class:`object` 的子型別。然而,不像 :data:`Any`,反之不亦然::" +"class:`object` 並\\ *不是*\\一個其他型別的子型別。" #: ../../library/typing.rst:765 msgid "" @@ -1330,16 +1329,16 @@ msgstr "" #: ../../library/typing.rst:798 msgid "" -"This requirement previously also applied to abstract base classes, such " -"as :class:`~collections.abc.Iterable`. The problem with this approach is " -"that a class had to be explicitly marked to support them, which is " -"unpythonic and unlike what one would normally do in idiomatic dynamically " -"typed Python code. For example, this conforms to :pep:`484`::" +"This requirement previously also applied to abstract base classes, such as :" +"class:`~collections.abc.Iterable`. The problem with this approach is that a " +"class had to be explicitly marked to support them, which is unpythonic and " +"unlike what one would normally do in idiomatic dynamically typed Python " +"code. For example, this conforms to :pep:`484`::" msgstr "" "這個需求之前也被運用在抽象基底類別,例如 :class:`~collections.abc.Iterable`。" "這種方式的問題在於,一個類別需要顯式的標記來支援他們,這並不符合 Python 風" -"格,也不像一個常見的慣用動態型別 Python 程式碼。舉例來說,下列程式碼符" -"合 :pep:`484`: ::" +"格,也不像一個常見的慣用動態型別 Python 程式碼。舉例來說,下列程式碼符合 :" +"pep:`484`: ::" #: ../../library/typing.rst:804 msgid "" @@ -1486,10 +1485,9 @@ msgstr "" #: ../../library/typing.rst:877 msgid "" -"Note that, despite its name, ``AnyStr`` has nothing to do with " -"the :class:`Any` type, nor does it mean \"any string\". In particular, " -"``AnyStr`` and ``str | bytes`` are different from each other and have " -"different use cases::" +"Note that, despite its name, ``AnyStr`` has nothing to do with the :class:" +"`Any` type, nor does it mean \"any string\". In particular, ``AnyStr`` and " +"``str | bytes`` are different from each other and have different use cases::" msgstr "" "請注意,儘管他的名稱相近,``AnyStr`` 與 :class:`Any` 型別無關,更不代表是「任" "何字串」的意思。尤其,``AnyStr`` 與 ``str | bytes`` 兩者不同且具有不同的使用" @@ -1511,8 +1509,8 @@ msgstr "" #: ../../library/typing.rst:892 msgid "" "Deprecated in favor of the new :ref:`type parameter syntax `. " -"Use ``class A[T: (str, bytes)]: ...`` instead of importing ``AnyStr``. " -"See :pep:`695` for more details." +"Use ``class A[T: (str, bytes)]: ...`` instead of importing ``AnyStr``. See :" +"pep:`695` for more details." msgstr "" #: ../../library/typing.rst:897 @@ -1574,16 +1572,16 @@ msgstr "更多細節請見 :pep:`675`。" #: ../../library/typing.rst:940 msgid "" -":data:`!Never` and :data:`!NoReturn` represent the `bottom type `_, a type that has no members." +":data:`!Never` and :data:`!NoReturn` represent the `bottom type `_, a type that has no members." msgstr "" ":data:`!Never` 和 :data:`!NoReturn` 表示\\ `底部型別 (bottom type) `_,為一個沒有任何成員的型別。" #: ../../library/typing.rst:944 msgid "" -"They can be used to indicate that a function never returns, such " -"as :func:`sys.exit`::" +"They can be used to indicate that a function never returns, such as :func:" +"`sys.exit`::" msgstr "它們可以被用來代表一個不會回傳的函式,像是 :func:`sys.exit`: ::" #: ../../library/typing.rst:947 @@ -1603,8 +1601,8 @@ msgid "" "Or to define a function that should never be called, as there are no valid " "arguments, such as :func:`assert_never`::" msgstr "" -"或被用來定義一個不應被呼叫的函式,因為不會有有效的引數,、像" -"是 :func:`assert_never`: ::" +"或被用來定義一個不應被呼叫的函式,因為不會有有效的引數,、像是 :func:" +"`assert_never`: ::" #: ../../library/typing.rst:956 msgid "" @@ -1789,17 +1787,17 @@ msgstr "更多細節請見 :pep:`613`。" msgid "" ":data:`TypeAlias` is deprecated in favor of the :keyword:`type` statement, " "which creates instances of :class:`TypeAliasType` and which natively " -"supports forward references. Note that while :data:`TypeAlias` " -"and :class:`TypeAliasType` serve similar purposes and have similar names, " -"they are distinct and the latter is not the type of the former. Removal " -"of :data:`TypeAlias` is not currently planned, but users are encouraged to " -"migrate to :keyword:`type` statements." -msgstr "" -":data:`TypeAlias` 被棄用,請改用 :keyword:`type` 陳述式來建" -"立 :class:`TypeAliasType` 的實例,其自然可以支援傳遞參照的使用。請注意,雖" -"然 :data:`TypeAlias` 以及 :class:`TypeAliasType` 提供相似的用途且具有相似的名" -"稱,他們是不同的,且後者不是前者的型別。現在還沒有移除 :data:`TypeAlias` 的計" -"畫,但鼓勵使用者們遷移 (migrate) 至 :keyword:`type` 陳述式。" +"supports forward references. Note that while :data:`TypeAlias` and :class:" +"`TypeAliasType` serve similar purposes and have similar names, they are " +"distinct and the latter is not the type of the former. Removal of :data:" +"`TypeAlias` is not currently planned, but users are encouraged to migrate " +"to :keyword:`type` statements." +msgstr "" +":data:`TypeAlias` 被棄用,請改用 :keyword:`type` 陳述式來建立 :class:" +"`TypeAliasType` 的實例,其自然可以支援傳遞參照的使用。請注意,雖然 :data:" +"`TypeAlias` 以及 :class:`TypeAliasType` 提供相似的用途且具有相似的名稱,他們" +"是不同的,且後者不是前者的型別。現在還沒有移除 :data:`TypeAlias` 的計畫,但鼓" +"勵使用者們遷移 (migrate) 至 :keyword:`type` 陳述式。" #: ../../library/typing.rst:1084 msgid "Special forms" @@ -1959,9 +1957,9 @@ msgid "" "a :ref:`Callable `. The last parameter to " "``Concatenate`` must be a :class:`ParamSpec` or ellipsis (``...``)." msgstr "" -"``Concatenate`` 可以被用在\\ :ref:`可呼叫物件 `\\ " -"與 :class:`ParamSpec` 的接合 (conjunction) 並註釋一個高階的 Callable 物件可以" -"新增、移除、轉換另一個 Callable 物件的參數。使用方法是依照這個格式 " +"``Concatenate`` 可以被用在\\ :ref:`可呼叫物件 `\\ 與 :" +"class:`ParamSpec` 的接合 (conjunction) 並註釋一個高階的 Callable 物件可以新" +"增、移除、轉換另一個 Callable 物件的參數。使用方法是依照這個格式 " "``Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable]``。``Concatenate`` " "目前只在 :ref:`Callable 物件 `\\ 中第一個引數使用時有" "效。``Concatenate`` 的最後一個參數必須為一個 :class:`ParamSpec` 或是刪節號 " @@ -1969,13 +1967,13 @@ msgstr "" #: ../../library/typing.rst:1166 msgid "" -"For example, to annotate a decorator ``with_lock`` which provides " -"a :class:`threading.Lock` to the decorated function, ``Concatenate`` can be " -"used to indicate that ``with_lock`` expects a callable which takes in a " -"``Lock`` as the first argument, and returns a callable with a different type " -"signature. In this case, the :class:`ParamSpec` indicates that the returned " -"callable's parameter types are dependent on the parameter types of the " -"callable being passed in::" +"For example, to annotate a decorator ``with_lock`` which provides a :class:" +"`threading.Lock` to the decorated function, ``Concatenate`` can be used to " +"indicate that ``with_lock`` expects a callable which takes in a ``Lock`` as " +"the first argument, and returns a callable with a different type signature. " +"In this case, the :class:`ParamSpec` indicates that the returned callable's " +"parameter types are dependent on the parameter types of the callable being " +"passed in::" msgstr "" "舉例來說,註釋一個為裝飾過後的函式提供 :class:`threading.Lock` 的裝飾器 " "``with_lock``,``Concatenate`` 可以用於指出 ``with_lock`` 預期一個 Callable " @@ -2150,16 +2148,15 @@ msgstr ":data:`ClassVar` 只接受型別請不得使用下標。" #: ../../library/typing.rst:1279 msgid "" -":data:`ClassVar` is not a class itself, and should not be used " -"with :func:`isinstance` or :func:`issubclass`. :data:`ClassVar` does not " -"change Python runtime behavior, but it can be used by third-party type " -"checkers. For example, a type checker might flag the following code as an " -"error::" +":data:`ClassVar` is not a class itself, and should not be used with :func:" +"`isinstance` or :func:`issubclass`. :data:`ClassVar` does not change Python " +"runtime behavior, but it can be used by third-party type checkers. For " +"example, a type checker might flag the following code as an error::" msgstr "" -":data:`ClassVar` 並不代表該類別本身,而且不應該和 :func:`isinstance` 或" -"是 :func:`issubclass` 一起使用。:data:`ClassVar` 不會改變 Python runtime 的行" -"為,但它可以被第三方的型別檢查器使用。舉例來說,一個型別檢查器可能會標記下方" -"的程式碼為一個錯誤: ::" +":data:`ClassVar` 並不代表該類別本身,而且不應該和 :func:`isinstance` 或是 :" +"func:`issubclass` 一起使用。:data:`ClassVar` 不會改變 Python runtime 的行為," +"但它可以被第三方的型別檢查器使用。舉例來說,一個型別檢查器可能會標記下方的程" +"式碼為一個錯誤: ::" #: ../../library/typing.rst:1285 msgid "" @@ -2216,8 +2213,8 @@ msgid "" "This is mainly useful for ``total=False`` TypedDicts. See :class:`TypedDict` " "and :pep:`655` for more details." msgstr "" -"主要用於 ``total=False`` 的 TypedDict。更多細節請見 :class:`TypedDict` " -"與 :pep:`655`。" +"主要用於 ``total=False`` 的 TypedDict。更多細節請見 :class:`TypedDict` 與 :" +"pep:`655`。" #: ../../library/typing.rst:1333 msgid "" @@ -2379,8 +2376,8 @@ msgstr "" #: ../../library/typing.rst:1427 msgid "" "However, this does not apply to ``Annotated`` types referenced through a " -"type alias, to avoid forcing evaluation of the " -"underlying :class:`TypeAliasType`::" +"type alias, to avoid forcing evaluation of the underlying :class:" +"`TypeAliasType`::" msgstr "" #: ../../library/typing.rst:1430 @@ -2493,8 +2490,8 @@ msgstr "" #: ../../library/typing.rst:1487 msgid "" -"If you want to retrieve the original type wrapped by ``Annotated``, use " -"the :attr:`!__origin__` attribute:" +"If you want to retrieve the original type wrapped by ``Annotated``, use the :" +"attr:`!__origin__` attribute:" msgstr "" #: ../../library/typing.rst:1490 @@ -2567,9 +2564,9 @@ msgstr "" #: ../../library/typing.rst:1536 msgid "" "Sometimes it would be convenient to use a user-defined boolean function as a " -"type predicate. Such a function should use ``TypeIs[...]`` " -"or :data:`TypeGuard` as its return type to alert static type checkers to " -"this intention. ``TypeIs`` usually has more intuitive behavior than " +"type predicate. Such a function should use ``TypeIs[...]`` or :data:" +"`TypeGuard` as its return type to alert static type checkers to this " +"intention. ``TypeIs`` usually has more intuitive behavior than " "``TypeGuard``, but it cannot be used when the input and output types are " "incompatible (e.g., ``list[object]`` to ``list[int]``) or when the function " "does not return ``True`` for all instances of the narrowed type." @@ -2646,8 +2643,8 @@ msgstr "" #: ../../library/typing.rst:1590 msgid "" -"``TypeIs`` also works with type variables. For more information, " -"see :pep:`742` (Narrowing types with ``TypeIs``)." +"``TypeIs`` also works with type variables. For more information, see :pep:" +"`742` (Narrowing types with ``TypeIs``)." msgstr "" #: ../../library/typing.rst:1600 @@ -3081,9 +3078,9 @@ msgstr "" #: ../../library/typing.rst:1890 msgid "" "Return whether or not the type variable has a default value. This is " -"equivalent to checking whether :attr:`__default__` is not " -"the :data:`typing.NoDefault` singleton, except that it does not force " -"evaluation of the :ref:`lazily evaluated ` default value." +"equivalent to checking whether :attr:`__default__` is not the :data:`typing." +"NoDefault` singleton, except that it does not force evaluation of the :ref:" +"`lazily evaluated ` default value." msgstr "" #: ../../library/typing.rst:1899 @@ -3294,9 +3291,9 @@ msgstr "" #: ../../library/typing.rst:2028 msgid "" "Return whether or not the type variable tuple has a default value. This is " -"equivalent to checking whether :attr:`__default__` is not " -"the :data:`typing.NoDefault` singleton, except that it does not force " -"evaluation of the :ref:`lazily evaluated ` default value." +"equivalent to checking whether :attr:`__default__` is not the :data:`typing." +"NoDefault` singleton, except that it does not force evaluation of the :ref:" +"`lazily evaluated ` default value." msgstr "" #: ../../library/typing.rst:2039 @@ -3389,15 +3386,15 @@ msgstr "" #: ../../library/typing.rst:2101 msgid "" -"Since ``ParamSpec`` captures both positional and keyword parameters, " -"``P.args`` and ``P.kwargs`` can be used to split a ``ParamSpec`` into its " +"Since ``ParamSpec`` captures both positional and keyword parameters, ``P." +"args`` and ``P.kwargs`` can be used to split a ``ParamSpec`` into its " "components. ``P.args`` represents the tuple of positional parameters in a " "given call and should only be used to annotate ``*args``. ``P.kwargs`` " "represents the mapping of keyword parameters to their values in a given " "call, and should be only be used to annotate ``**kwargs``. Both attributes " "require the annotated parameter to be in scope. At runtime, ``P.args`` and " -"``P.kwargs`` are instances respectively of :class:`ParamSpecArgs` " -"and :class:`ParamSpecKwargs`." +"``P.kwargs`` are instances respectively of :class:`ParamSpecArgs` and :class:" +"`ParamSpecKwargs`." msgstr "" #: ../../library/typing.rst:2113 @@ -3406,25 +3403,25 @@ msgstr "" #: ../../library/typing.rst:2117 msgid "" -"The default value of the parameter specification, " -"or :data:`typing.NoDefault` if it has no default." +"The default value of the parameter specification, or :data:`typing." +"NoDefault` if it has no default." msgstr "" #: ../../library/typing.rst:2124 msgid "" "Return whether or not the parameter specification has a default value. This " -"is equivalent to checking whether :attr:`__default__` is not " -"the :data:`typing.NoDefault` singleton, except that it does not force " -"evaluation of the :ref:`lazily evaluated ` default value." +"is equivalent to checking whether :attr:`__default__` is not the :data:" +"`typing.NoDefault` singleton, except that it does not force evaluation of " +"the :ref:`lazily evaluated ` default value." msgstr "" #: ../../library/typing.rst:2131 msgid "" "Parameter specification variables created with ``covariant=True`` or " "``contravariant=True`` can be used to declare covariant or contravariant " -"generic types. The ``bound`` argument is also accepted, similar " -"to :class:`TypeVar`. However the actual semantics of these keywords are yet " -"to be decided." +"generic types. The ``bound`` argument is also accepted, similar to :class:" +"`TypeVar`. However the actual semantics of these keywords are yet to be " +"decided." msgstr "" #: ../../library/typing.rst:2141 @@ -3445,11 +3442,10 @@ msgstr ":data:`Concatenate`" #: ../../library/typing.rst:2161 msgid "" -"Arguments and keyword arguments attributes of a :class:`ParamSpec`. The " -"``P.args`` attribute of a ``ParamSpec`` is an instance of ``ParamSpecArgs``, " -"and ``P.kwargs`` is an instance of ``ParamSpecKwargs``. They are intended " -"for runtime introspection and have no special meaning to static type " -"checkers." +"Arguments and keyword arguments attributes of a :class:`ParamSpec`. The ``P." +"args`` attribute of a ``ParamSpec`` is an instance of ``ParamSpecArgs``, and " +"``P.kwargs`` is an instance of ``ParamSpecKwargs``. They are intended for " +"runtime introspection and have no special meaning to static type checkers." msgstr "" #: ../../library/typing.rst:2166 @@ -3800,11 +3796,11 @@ msgstr "" #: ../../library/typing.rst:2393 msgid "" -"See :pep:`544` for more details. Protocol classes decorated " -"with :func:`runtime_checkable` (described later) act as simple-minded " -"runtime protocols that check only the presence of given attributes, ignoring " -"their type signatures. Protocol classes without this decorator cannot be " -"used as the second argument to :func:`isinstance` or :func:`issubclass`." +"See :pep:`544` for more details. Protocol classes decorated with :func:" +"`runtime_checkable` (described later) act as simple-minded runtime protocols " +"that check only the presence of given attributes, ignoring their type " +"signatures. Protocol classes without this decorator cannot be used as the " +"second argument to :func:`isinstance` or :func:`issubclass`." msgstr "" #: ../../library/typing.rst:2399 @@ -3849,8 +3845,8 @@ msgstr "" msgid "" "Such a protocol can be used with :func:`isinstance` and :func:`issubclass`. " "This allows a simple-minded structural check, very similar to \"one trick " -"ponies\" in :mod:`collections.abc` such " -"as :class:`~collections.abc.Iterable`. For example::" +"ponies\" in :mod:`collections.abc` such as :class:`~collections.abc." +"Iterable`. For example::" msgstr "" #: ../../library/typing.rst:2424 @@ -3889,12 +3885,12 @@ msgstr "" #: ../../library/typing.rst:2441 msgid "" ":func:`!runtime_checkable` will check only the presence of the required " -"methods or attributes, not their type signatures or types. For " -"example, :class:`ssl.SSLObject` is a class, therefore it passes " -"an :func:`issubclass` check against :ref:`Callable `. " -"However, the ``ssl.SSLObject.__init__`` method exists only to raise " -"a :exc:`TypeError` with a more informative message, therefore making it " -"impossible to call (instantiate) :class:`ssl.SSLObject`." +"methods or attributes, not their type signatures or types. For example, :" +"class:`ssl.SSLObject` is a class, therefore it passes an :func:`issubclass` " +"check against :ref:`Callable `. However, the ``ssl." +"SSLObject.__init__`` method exists only to raise a :exc:`TypeError` with a " +"more informative message, therefore making it impossible to call " +"(instantiate) :class:`ssl.SSLObject`." msgstr "" #: ../../library/typing.rst:2452 @@ -3920,9 +3916,8 @@ msgid "" "The members of a runtime-checkable protocol are now considered \"frozen\" at " "runtime as soon as the class has been created. Monkey-patching attributes " "onto a runtime-checkable protocol will still work, but will have no impact " -"on :func:`isinstance` checks comparing objects to the protocol. " -"See :ref:`\"What's new in Python 3.12\" ` for more " -"details." +"on :func:`isinstance` checks comparing objects to the protocol. See :ref:" +"`What's new in Python 3.12 ` for more details." msgstr "" #: ../../library/typing.rst:2480 @@ -3964,10 +3959,10 @@ msgstr "Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})" #: ../../library/typing.rst:2504 msgid "" -"This functional syntax allows defining keys which are not " -"valid :ref:`identifiers `, for example because they are " -"keywords or contain hyphens, or when key names must not be :ref:`mangled " -"` like regular private names::" +"This functional syntax allows defining keys which are not valid :ref:" +"`identifiers `, for example because they are keywords or " +"contain hyphens, or when key names must not be :ref:`mangled ` like regular private names::" msgstr "" #: ../../library/typing.rst:2509 @@ -4179,10 +4174,9 @@ msgstr "" #: ../../library/typing.rst:2612 msgid "" -"A ``TypedDict`` can be introspected via annotations dicts " -"(see :ref:`annotations-howto` for more information on annotations best " -"practices), :attr:`__total__`, :attr:`__required_keys__`, " -"and :attr:`__optional_keys__`." +"A ``TypedDict`` can be introspected via annotations dicts (see :ref:" +"`annotations-howto` for more information on annotations best practices), :" +"attr:`__total__`, :attr:`__required_keys__`, and :attr:`__optional_keys__`." msgstr "" #: ../../library/typing.rst:2618 @@ -4227,8 +4221,8 @@ msgstr "" #: ../../library/typing.rst:2647 msgid "" -"``Point2D.__required_keys__`` and ``Point2D.__optional_keys__`` " -"return :class:`frozenset` objects containing required and non-required keys, " +"``Point2D.__required_keys__`` and ``Point2D.__optional_keys__`` return :" +"class:`frozenset` objects containing required and non-required keys, " "respectively." msgstr "" @@ -4306,8 +4300,8 @@ msgstr "" #: ../../library/typing.rst:2704 msgid "" -"Added support for marking individual keys as :data:`Required` " -"or :data:`NotRequired`. See :pep:`655`." +"Added support for marking individual keys as :data:`Required` or :data:" +"`NotRequired`. See :pep:`655`." msgstr "" #: ../../library/typing.rst:2708 @@ -4524,9 +4518,9 @@ msgstr "" #: ../../library/typing.rst:2863 msgid "" -"At runtime, this function prints the runtime type of its argument " -"to :data:`sys.stderr` and returns the argument unchanged (allowing the call " -"to be used within an expression)::" +"At runtime, this function prints the runtime type of its argument to :data:" +"`sys.stderr` and returns the argument unchanged (allowing the call to be " +"used within an expression)::" msgstr "" #: ../../library/typing.rst:2867 @@ -4553,8 +4547,8 @@ msgstr "" #: ../../library/typing.rst:2884 msgid "" -"Decorator to mark an object as providing :func:`dataclass " -"`-like behavior." +"Decorator to mark an object as providing :func:`dataclass `-like behavior." msgstr "" #: ../../library/typing.rst:2887 @@ -4639,9 +4633,9 @@ msgstr "" #: ../../library/typing.rst:2928 msgid "" "The ``CustomerModel`` classes defined above will be treated by type checkers " -"similarly to classes created with :func:`@dataclasses.dataclass " -"`. For example, type checkers will assume these " -"classes have ``__init__`` methods that accept ``id`` and ``name``." +"similarly to classes created with :func:`@dataclasses.dataclass `. For example, type checkers will assume these classes have " +"``__init__`` methods that accept ``id`` and ``name``." msgstr "" #: ../../library/typing.rst:2934 @@ -4817,8 +4811,8 @@ msgid "" "only, since they will be overwritten by the non-``@overload``-decorated " "definition. The non-``@overload``-decorated definition, meanwhile, will be " "used at runtime but should be ignored by a type checker. At runtime, " -"calling an ``@overload``-decorated function directly will " -"raise :exc:`NotImplementedError`." +"calling an ``@overload``-decorated function directly will raise :exc:" +"`NotImplementedError`." msgstr "" #: ../../library/typing.rst:3039 @@ -4860,8 +4854,8 @@ msgstr "" #: ../../library/typing.rst:3058 msgid "" -"Overloaded functions can now be introspected at runtime " -"using :func:`get_overloads`." +"Overloaded functions can now be introspected at runtime using :func:" +"`get_overloads`." msgstr "" #: ../../library/typing.rst:3065 @@ -5099,8 +5093,8 @@ msgstr "" #: ../../library/typing.rst:3236 msgid "" "The function recursively replaces all occurrences of ``Annotated[T, ...]`` " -"with ``T``, unless *include_extras* is set to ``True`` " -"(see :class:`Annotated` for more information)." +"with ``T``, unless *include_extras* is set to ``True`` (see :class:" +"`Annotated` for more information)." msgstr "" #: ../../library/typing.rst:3240 @@ -5112,8 +5106,8 @@ msgstr "" #: ../../library/typing.rst:3245 msgid "" "If any forward references in the annotations of *obj* are not resolvable or " -"are not valid Python code, this function will raise an exception such " -"as :exc:`NameError`. For example, this can happen with imported :ref:`type " +"are not valid Python code, this function will raise an exception such as :" +"exc:`NameError`. For example, this can happen with imported :ref:`type " "aliases ` that include forward references, or with names " "imported under :data:`if TYPE_CHECKING `." msgstr "" @@ -5123,8 +5117,8 @@ msgid "" "Added ``include_extras`` parameter as part of :pep:`593`. See the " "documentation on :data:`Annotated` for more information." msgstr "" -"新增 ``include_extras`` 參數(如 :pep:`593` 中所述)。更多資訊請" -"見 :data:`Annotated` 的文件。" +"新增 ``include_extras`` 參數(如 :pep:`593` 中所述)。更多資訊請見 :data:" +"`Annotated` 的文件。" #: ../../library/typing.rst:3255 msgid "" @@ -5142,9 +5136,9 @@ msgstr "" #: ../../library/typing.rst:3265 msgid "" "If ``X`` is a typing-module alias for a builtin or :mod:`collections` class, " -"it will be normalized to the original class. If ``X`` is an instance " -"of :class:`ParamSpecArgs` or :class:`ParamSpecKwargs`, return the " -"underlying :class:`ParamSpec`. Return ``None`` for unsupported objects." +"it will be normalized to the original class. If ``X`` is an instance of :" +"class:`ParamSpecArgs` or :class:`ParamSpecKwargs`, return the underlying :" +"class:`ParamSpec`. Return ``None`` for unsupported objects." msgstr "" #: ../../library/typing.rst:3271 ../../library/typing.rst:3295 @@ -5361,9 +5355,8 @@ msgstr "" msgid "" "If at some point it is decided to remove these deprecated aliases, a " "deprecation warning will be issued by the interpreter for at least two " -"releases prior to removal. The aliases are guaranteed to remain in " -"the :mod:`!typing` module without deprecation warnings until at least Python " -"3.14." +"releases prior to removal. The aliases are guaranteed to remain in the :mod:" +"`!typing` module without deprecation warnings until at least Python 3.14." msgstr "" #: ../../library/typing.rst:3443 @@ -5389,8 +5382,8 @@ msgstr "" #: ../../library/typing.rst:3459 msgid "" -":class:`builtins.dict ` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`builtins.dict ` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3465 @@ -5400,15 +5393,15 @@ msgstr "棄用 :class:`list` 的別名。" #: ../../library/typing.rst:3467 msgid "" "Note that to annotate arguments, it is preferred to use an abstract " -"collection type such as :class:`~collections.abc.Sequence` " -"or :class:`~collections.abc.Iterable` rather than to use :class:`list` " -"or :class:`!typing.List`." +"collection type such as :class:`~collections.abc.Sequence` or :class:" +"`~collections.abc.Iterable` rather than to use :class:`list` or :class:`!" +"typing.List`." msgstr "" #: ../../library/typing.rst:3472 msgid "" -":class:`builtins.list ` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`builtins.list ` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3478 @@ -5418,14 +5411,14 @@ msgstr "棄用 :class:`builtins.set ` 的別名。" #: ../../library/typing.rst:3480 msgid "" "Note that to annotate arguments, it is preferred to use an abstract " -"collection type such as :class:`collections.abc.Set` rather than to " -"use :class:`set` or :class:`typing.Set`." +"collection type such as :class:`collections.abc.Set` rather than to use :" +"class:`set` or :class:`typing.Set`." msgstr "" #: ../../library/typing.rst:3484 msgid "" -":class:`builtins.set ` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`builtins.set ` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3490 @@ -5444,14 +5437,14 @@ msgstr "棄用 :class:`tuple` 的別名。" #: ../../library/typing.rst:3501 msgid "" -":class:`tuple` and ``Tuple`` are special-cased in the type system; " -"see :ref:`annotating-tuples` for more details." +":class:`tuple` and ``Tuple`` are special-cased in the type system; see :ref:" +"`annotating-tuples` for more details." msgstr "" #: ../../library/typing.rst:3504 msgid "" -":class:`builtins.tuple ` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`builtins.tuple ` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3510 @@ -5466,8 +5459,8 @@ msgstr "" #: ../../library/typing.rst:3517 msgid "" -":class:`builtins.type ` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`builtins.type ` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3524 @@ -5480,8 +5473,8 @@ msgstr "棄用 :class:`collections.defaultdict` 的別名。" #: ../../library/typing.rst:3532 msgid "" -":class:`collections.defaultdict` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.defaultdict` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3538 @@ -5490,8 +5483,8 @@ msgstr "棄用 :class:`collections.OrderedDict` 的別名。" #: ../../library/typing.rst:3542 msgid "" -":class:`collections.OrderedDict` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.OrderedDict` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3548 @@ -5500,8 +5493,8 @@ msgstr "棄用 :class:`collections.ChainMap` 的別名。" #: ../../library/typing.rst:3552 msgid "" -":class:`collections.ChainMap` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.ChainMap` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3558 @@ -5510,8 +5503,8 @@ msgstr "棄用 :class:`collections.Counter` 的別名。" #: ../../library/typing.rst:3562 msgid "" -":class:`collections.Counter` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.Counter` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3568 @@ -5520,8 +5513,8 @@ msgstr "棄用 :class:`collections.deque` 的別名。" #: ../../library/typing.rst:3572 msgid "" -":class:`collections.deque` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.deque` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3579 @@ -5536,16 +5529,16 @@ msgstr "" #: ../../library/typing.rst:3587 msgid "" -"These types (and the corresponding functions) are generic " -"over :data:`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or " +"These types (and the corresponding functions) are generic over :data:" +"`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or " "``Pattern[bytes]``; ``Match`` can be specialised as ``Match[str]`` or " "``Match[bytes]``." msgstr "" #: ../../library/typing.rst:3592 msgid "" -"Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. " -"See :pep:`585` and :ref:`types-genericalias`." +"Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3598 @@ -5589,14 +5582,14 @@ msgstr "棄用 :class:`collections.abc.Set` 的別名。" #: ../../library/typing.rst:3628 msgid "" -":class:`collections.abc.Set` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Set` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3634 msgid "" -"This type represents the types :class:`bytes`, :class:`bytearray`, " -"and :class:`memoryview` of byte sequences." +"This type represents the types :class:`bytes`, :class:`bytearray`, and :" +"class:`memoryview` of byte sequences." msgstr "" #: ../../library/typing.rst:3637 @@ -5611,8 +5604,8 @@ msgstr "棄用 :class:`collections.abc.Collection` 的別名。" #: ../../library/typing.rst:3646 msgid "" -":class:`collections.abc.Collection` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Collection` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3652 @@ -5621,8 +5614,8 @@ msgstr "棄用 :class:`collections.abc.Container` 的別名。" #: ../../library/typing.rst:3654 msgid "" -":class:`collections.abc.Container` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Container` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3660 @@ -5631,8 +5624,8 @@ msgstr "棄用 :class:`collections.abc.ItemsView` 的別名。" #: ../../library/typing.rst:3662 msgid "" -":class:`collections.abc.ItemsView` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.ItemsView` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3668 @@ -5641,8 +5634,8 @@ msgstr "棄用 :class:`collections.abc.KeysView` 的別名。" #: ../../library/typing.rst:3670 msgid "" -":class:`collections.abc.KeysView` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.KeysView` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3676 @@ -5651,8 +5644,8 @@ msgstr "棄用 :class:`collections.abc.Mapping` 的別名。" #: ../../library/typing.rst:3678 msgid "" -":class:`collections.abc.Mapping` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Mapping` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3684 @@ -5691,8 +5684,8 @@ msgstr "棄用 :class:`collections.abc.MutableSet` 的別名。" #: ../../library/typing.rst:3712 msgid "" -":class:`collections.abc.MutableSet` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.MutableSet` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3718 @@ -5701,8 +5694,8 @@ msgstr "棄用 :class:`collections.abc.Sequence` 的別名。" #: ../../library/typing.rst:3720 msgid "" -":class:`collections.abc.Sequence` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Sequence` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3726 @@ -5711,8 +5704,8 @@ msgstr "棄用 :class:`collections.abc.ValuesView` 的別名。" #: ../../library/typing.rst:3728 msgid "" -":class:`collections.abc.ValuesView` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.ValuesView` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3735 @@ -5725,15 +5718,14 @@ msgstr "棄用 :class:`collections.abc.Coroutine` 的別名。" #: ../../library/typing.rst:3741 msgid "" -"See :ref:`annotating-generators-and-coroutines` for details on " -"using :class:`collections.abc.Coroutine` and ``typing.Coroutine`` in type " -"annotations." +"See :ref:`annotating-generators-and-coroutines` for details on using :class:" +"`collections.abc.Coroutine` and ``typing.Coroutine`` in type annotations." msgstr "" #: ../../library/typing.rst:3747 msgid "" -":class:`collections.abc.Coroutine` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Coroutine` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3753 @@ -5742,9 +5734,9 @@ msgstr "棄用 :class:`collections.abc.AsyncGenerator` 的別名。" #: ../../library/typing.rst:3755 msgid "" -"See :ref:`annotating-generators-and-coroutines` for details on " -"using :class:`collections.abc.AsyncGenerator` and ``typing.AsyncGenerator`` " -"in type annotations." +"See :ref:`annotating-generators-and-coroutines` for details on using :class:" +"`collections.abc.AsyncGenerator` and ``typing.AsyncGenerator`` in type " +"annotations." msgstr "" #: ../../library/typing.rst:3761 @@ -5783,8 +5775,8 @@ msgstr "棄用 :class:`collections.abc.Awaitable` 的別名。" #: ../../library/typing.rst:3795 msgid "" -":class:`collections.abc.Awaitable` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Awaitable` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3802 @@ -5797,8 +5789,8 @@ msgstr "棄用 :class:`collections.abc.Iterable` 的別名。" #: ../../library/typing.rst:3808 msgid "" -":class:`collections.abc.Iterable` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Iterable` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3814 @@ -5807,8 +5799,8 @@ msgstr "棄用 :class:`collections.abc.Iterator` 的別名。" #: ../../library/typing.rst:3816 msgid "" -":class:`collections.abc.Iterator` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Iterator` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3822 @@ -5817,15 +5809,14 @@ msgstr "棄用 :class:`collections.abc.Callable` 的別名。" #: ../../library/typing.rst:3824 msgid "" -"See :ref:`annotating-callables` for details on how to " -"use :class:`collections.abc.Callable` and ``typing.Callable`` in type " -"annotations." +"See :ref:`annotating-callables` for details on how to use :class:" +"`collections.abc.Callable` and ``typing.Callable`` in type annotations." msgstr "" #: ../../library/typing.rst:3827 msgid "" -":class:`collections.abc.Callable` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Callable` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3837 @@ -5834,15 +5825,14 @@ msgstr "棄用 :class:`collections.abc.Generator` 的別名。" #: ../../library/typing.rst:3839 msgid "" -"See :ref:`annotating-generators-and-coroutines` for details on " -"using :class:`collections.abc.Generator` and ``typing.Generator`` in type " -"annotations." +"See :ref:`annotating-generators-and-coroutines` for details on using :class:" +"`collections.abc.Generator` and ``typing.Generator`` in type annotations." msgstr "" #: ../../library/typing.rst:3843 msgid "" -":class:`collections.abc.Generator` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Generator` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3847 @@ -5863,8 +5853,8 @@ msgstr "棄用 :class:`collections.abc.Reversible` 的別名。" #: ../../library/typing.rst:3861 msgid "" -":class:`collections.abc.Reversible` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Reversible` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3867 @@ -5885,8 +5875,8 @@ msgstr "" #: ../../library/typing.rst:3881 msgid "" -"The first type parameter, ``T_co``, represents the type returned by " -"the :meth:`~object.__enter__` method. The optional second type parameter, " +"The first type parameter, ``T_co``, represents the type returned by the :" +"meth:`~object.__enter__` method. The optional second type parameter, " "``ExitT_co``, which defaults to ``bool | None``, represents the type " "returned by the :meth:`~object.__exit__` method." msgstr "" @@ -5907,8 +5897,8 @@ msgstr "" #: ../../library/typing.rst:3900 msgid "" -"The first type parameter, ``T_co``, represents the type returned by " -"the :meth:`~object.__aenter__` method. The optional second type parameter, " +"The first type parameter, ``T_co``, represents the type returned by the :" +"meth:`~object.__aenter__` method. The optional second type parameter, " "``AExitT_co``, which defaults to ``bool | None``, represents the type " "returned by the :meth:`~object.__aexit__` method." msgstr "" diff --git a/library/unittest.mock.po b/library/unittest.mock.po index 6fe3d592f0..0cc1d43f72 100644 --- a/library/unittest.mock.po +++ b/library/unittest.mock.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-09 00:16+0000\n" "PO-Revision-Date: 2024-02-19 21:27+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -722,13 +722,14 @@ msgid "Setting :attr:`side_effect` to ``None`` clears it:" msgstr "將 :attr:`side_effect` 設定為 ``None`` 可以清除它:" #: ../../library/unittest.mock.rst:639 +#, fuzzy msgid "" "This is either ``None`` (if the mock hasn't been called), or the arguments " "that the mock was last called with. This will be in the form of a tuple: the " "first member, which can also be accessed through the ``args`` property, is " -"any ordered arguments the mock was called with (or an empty tuple) and the " -"second member, which can also be accessed through the ``kwargs`` property, " -"is any keyword arguments (or an empty dictionary)." +"any positional arguments the mock was called with (or an empty tuple) and " +"the second member, which can also be accessed through the ``kwargs`` " +"property, is any keyword arguments (or an empty dictionary)." msgstr "" "這會是 ``None``\\ (如果 mock 尚未被呼叫),或是 mock 上次被呼叫時使用的引" "數。這將以元組的形式呈現:第一個成員 (member),其可以通過 ``args`` 屬性存取," From c93aff8ae21bdf7b81550e2803bb87b9ad231018 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 10 Aug 2025 00:20:32 +0000 Subject: [PATCH 10/23] sync with cpython a64c9488 --- howto/a-conceptual-overview-of-asyncio.po | 811 ++++++++++++++++++++++ howto/index.po | 62 +- library/asyncio-future.po | 92 +-- library/asyncio-task.po | 388 +++++------ library/asyncio.po | 66 +- library/time.po | 9 +- 6 files changed, 1123 insertions(+), 305 deletions(-) create mode 100644 howto/a-conceptual-overview-of-asyncio.po diff --git a/howto/a-conceptual-overview-of-asyncio.po b/howto/a-conceptual-overview-of-asyncio.po new file mode 100644 index 0000000000..16c9752003 --- /dev/null +++ b/howto/a-conceptual-overview-of-asyncio.po @@ -0,0 +1,811 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-08-10 00:19+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:5 +msgid "A Conceptual Overview of :mod:`!asyncio`" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:7 +msgid "" +"This :ref:`HOWTO ` article seeks to help you build a sturdy mental " +"model of how :mod:`asyncio` fundamentally works, helping you understand the " +"how and why behind the recommended patterns." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:11 +msgid "" +"You might be curious about some key :mod:`!asyncio` concepts. You'll be " +"comfortably able to answer these questions by the end of this article:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:15 +msgid "What's happening behind the scenes when an object is awaited?" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:16 +msgid "" +"How does :mod:`!asyncio` differentiate between a task which doesn't need CPU-" +"time (such as a network request or file read) as opposed to a task that does " +"(such as computing n-factorial)?" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:19 +msgid "" +"How to write an asynchronous variant of an operation, such as an async sleep " +"or database request." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:24 +msgid "" +"The `guide `_ that inspired this HOWTO article, by Alexander Nordin." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:26 +msgid "" +"This in-depth `YouTube tutorial series `_ on ``asyncio`` " +"created by Python core team member, Łukasz Langa." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:29 +msgid "" +"`500 Lines or Less: A Web Crawler With asyncio Coroutines `_ by A. Jesse Jiryu " +"Davis and Guido van Rossum." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:35 +msgid "A conceptual overview part 1: the high-level" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:37 +msgid "" +"In part 1, we'll cover the main, high-level building blocks of :mod:`!" +"asyncio`: the event loop, coroutine functions, coroutine objects, tasks and " +"``await``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:42 +msgid "Event Loop" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:44 +msgid "" +"Everything in :mod:`!asyncio` happens relative to the event loop. It's the " +"star of the show. It's like an orchestra conductor. It's behind the scenes " +"managing resources. Some power is explicitly granted to it, but a lot of its " +"ability to get things done comes from the respect and cooperation of its " +"worker bees." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:51 +msgid "" +"In more technical terms, the event loop contains a collection of jobs to be " +"run. Some jobs are added directly by you, and some indirectly by :mod:`!" +"asyncio`. The event loop takes a job from its backlog of work and invokes it " +"(or \"gives it control\"), similar to calling a function, and then that job " +"runs. Once it pauses or completes, it returns control to the event loop. The " +"event loop will then select another job from its pool and invoke it. You can " +"*roughly* think of the collection of jobs as a queue: jobs are added and " +"then processed one at a time, generally (but not always) in order. This " +"process repeats indefinitely with the event loop cycling endlessly onwards. " +"If there are no more jobs pending execution, the event loop is smart enough " +"to rest and avoid needlessly wasting CPU cycles, and will come back when " +"there's more work to be done." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:65 +msgid "" +"Effective execution relies on jobs sharing well and cooperating; a greedy " +"job could hog control and leave the other jobs to starve, rendering the " +"overall event loop approach rather useless." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:71 +msgid "" +"import asyncio\n" +"\n" +"# This creates an event loop and indefinitely cycles through\n" +"# its collection of jobs.\n" +"event_loop = asyncio.new_event_loop()\n" +"event_loop.run_forever()" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:80 +msgid "Asynchronous functions and coroutines" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:82 +msgid "This is a basic, boring Python function::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:84 +msgid "" +"def hello_printer():\n" +" print(\n" +" \"Hi, I am a lowly, simple printer, though I have all I \"\n" +" \"need in life -- \\nfresh paper and my dearly beloved octopus \"\n" +" \"partner in crime.\"\n" +" )" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:91 +msgid "Calling a regular function invokes its logic or body::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:93 +msgid "" +">>> hello_printer()\n" +"Hi, I am a lowly, simple printer, though I have all I need in life --\n" +"fresh paper and my dearly beloved octopus partner in crime." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:97 +msgid "" +"The :ref:`async def `, as opposed to just a plain ``def``, makes " +"this an asynchronous function (or \"coroutine function\"). Calling it " +"creates and returns a :ref:`coroutine ` object." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:103 +msgid "" +"async def loudmouth_penguin(magic_number: int):\n" +" print(\n" +" \"I am a super special talking penguin. Far cooler than that printer. " +"\"\n" +" f\"By the way, my lucky number is: {magic_number}.\"\n" +" )" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:109 +msgid "" +"Calling the async function, ``loudmouth_penguin``, does not execute the " +"print statement; instead, it creates a coroutine object::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:112 +msgid "" +">>> loudmouth_penguin(magic_number=3)\n" +"" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:115 +msgid "" +"The terms \"coroutine function\" and \"coroutine object\" are often " +"conflated as coroutine. That can be confusing! In this article, coroutine " +"specifically refers to a coroutine object, or more precisely, an instance " +"of :data:`types.CoroutineType` (native coroutine). Note that coroutines can " +"also exist as instances of :class:`collections.abc.Coroutine` -- a " +"distinction that matters for type checking." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:124 +msgid "" +"A coroutine represents the function's body or logic. A coroutine has to be " +"explicitly started; again, merely creating the coroutine does not start it. " +"Notably, the coroutine can be paused and resumed at various points within " +"the function's body. That pausing and resuming ability is what allows for " +"asynchronous behavior!" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:131 +msgid "" +"Coroutines and coroutine functions were built by leveraging the " +"functionality of :term:`generators ` and :term:" +"`generator functions `. Recall, a generator function is a " +"function that :keyword:`yield`\\s, like this one::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:137 +msgid "" +"def get_random_number():\n" +" # This would be a bad random number generator!\n" +" print(\"Hi\")\n" +" yield 1\n" +" print(\"Hello\")\n" +" yield 7\n" +" print(\"Howdy\")\n" +" yield 4\n" +" ..." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:147 +msgid "" +"Similar to a coroutine function, calling a generator function does not run " +"it. Instead, it creates a generator object::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:150 +msgid "" +">>> get_random_number()\n" +"" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:153 +msgid "" +"You can proceed to the next ``yield`` of a generator by using the built-in " +"function :func:`next`. In other words, the generator runs, then pauses. For " +"example::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:158 +msgid "" +">>> generator = get_random_number()\n" +">>> next(generator)\n" +"Hi\n" +"1\n" +">>> next(generator)\n" +"Hello\n" +"7" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:168 +msgid "Tasks" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:170 +msgid "" +"Roughly speaking, :ref:`tasks ` are coroutines (not " +"coroutine functions) tied to an event loop. A task also maintains a list of " +"callback functions whose importance will become clear in a moment when we " +"discuss :keyword:`await`. The recommended way to create tasks is via :func:" +"`asyncio.create_task`." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:176 +msgid "" +"Creating a task automatically schedules it for execution (by adding a " +"callback to run it in the event loop's to-do list, that is, collection of " +"jobs)." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:179 +msgid "" +"Since there's only one event loop (in each thread), :mod:`!asyncio` takes " +"care of associating the task with the event loop for you. As such, there's " +"no need to specify the event loop." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:185 +msgid "" +"coroutine = loudmouth_penguin(magic_number=5)\n" +"# This creates a Task object and schedules its execution via the event " +"loop.\n" +"task = asyncio.create_task(coroutine)" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:189 +msgid "" +"Earlier, we manually created the event loop and set it to run forever. In " +"practice, it's recommended to use (and common to see) :func:`asyncio.run`, " +"which takes care of managing the event loop and ensuring the provided " +"coroutine finishes before advancing. For example, many async programs follow " +"this setup::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:195 +msgid "" +"import asyncio\n" +"\n" +"async def main():\n" +" # Perform all sorts of wacky, wild asynchronous things...\n" +" ...\n" +"\n" +"if __name__ == \"__main__\":\n" +" asyncio.run(main())\n" +" # The program will not reach the following print statement until the\n" +" # coroutine main() finishes.\n" +" print(\"coroutine main() is done!\")" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:207 +msgid "" +"It's important to be aware that the task itself is not added to the event " +"loop, only a callback to the task is. This matters if the task object you " +"created is garbage collected before it's called by the event loop. For " +"example, consider this program:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:213 +msgid "" +"async def hello():\n" +" print(\"hello!\")\n" +"\n" +"async def main():\n" +" asyncio.create_task(hello())\n" +" # Other asynchronous instructions which run for a while\n" +" # and cede control to the event loop...\n" +" ...\n" +"\n" +"asyncio.run(main())" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:227 +msgid "" +"Because there's no reference to the task object created on line 5, it " +"*might* be garbage collected before the event loop invokes it. Later " +"instructions in the coroutine ``main()`` hand control back to the event loop " +"so it can invoke other jobs. When the event loop eventually tries to run the " +"task, it might fail and discover the task object does not exist! This can " +"also happen even if a coroutine keeps a reference to a task but completes " +"before that task finishes. When the coroutine exits, local variables go out " +"of scope and may be subject to garbage collection. In practice, ``asyncio`` " +"and Python's garbage collector work pretty hard to ensure this sort of thing " +"doesn't happen. But that's no reason to be reckless!" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:243 +msgid "await" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:245 +msgid "" +":keyword:`await` is a Python keyword that's commonly used in one of two " +"different ways::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:248 +msgid "" +"await task\n" +"await coroutine" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:251 +msgid "" +"In a crucial way, the behavior of ``await`` depends on the type of object " +"being awaited." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:254 +msgid "" +"Awaiting a task will cede control from the current task or coroutine to the " +"event loop. In the process of relinquishing control, a few important things " +"happen. We'll use the following code example to illustrate::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:259 +msgid "" +"async def plant_a_tree():\n" +" dig_the_hole_task = asyncio.create_task(dig_the_hole())\n" +" await dig_the_hole_task\n" +"\n" +" # Other instructions associated with planting a tree.\n" +" ..." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:266 +msgid "" +"In this example, imagine the event loop has passed control to the start of " +"the coroutine ``plant_a_tree()``. As seen above, the coroutine creates a " +"task and then awaits it. The ``await dig_the_hole_task`` instruction adds a " +"callback (which will resume ``plant_a_tree()``) to the ``dig_the_hole_task`` " +"object's list of callbacks. And then, the instruction cedes control to the " +"event loop. Some time later, the event loop will pass control to " +"``dig_the_hole_task`` and the task will finish whatever it needs to do. Once " +"the task finishes, it will add its various callbacks to the event loop, in " +"this case, a call to resume ``plant_a_tree()``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:277 +msgid "" +"Generally speaking, when the awaited task finishes (``dig_the_hole_task``), " +"the original task or coroutine (``plant_a_tree()``) is added back to the " +"event loops to-do list to be resumed." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:281 +msgid "" +"This is a basic, yet reliable mental model. In practice, the control " +"handoffs are slightly more complex, but not by much. In part 2, we'll walk " +"through the details that make this possible." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:285 +msgid "" +"**Unlike tasks, awaiting a coroutine does not hand control back to the event " +"loop!** Wrapping a coroutine in a task first, then awaiting that would cede " +"control. The behavior of ``await coroutine`` is effectively the same as " +"invoking a regular, synchronous Python function. Consider this program::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:293 +msgid "" +"import asyncio\n" +"\n" +"async def coro_a():\n" +" print(\"I am coro_a(). Hi!\")\n" +"\n" +"async def coro_b():\n" +" print(\"I am coro_b(). I sure hope no one hogs the event loop...\")\n" +"\n" +"async def main():\n" +" task_b = asyncio.create_task(coro_b())\n" +" num_repeats = 3\n" +" for _ in range(num_repeats):\n" +" await coro_a()\n" +" await task_b\n" +"\n" +"asyncio.run(main())" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:310 +msgid "" +"The first statement in the coroutine ``main()`` creates ``task_b`` and " +"schedules it for execution via the event loop. Then, ``coro_a()`` is " +"repeatedly awaited. Control never cedes to the event loop which is why we " +"see the output of all three ``coro_a()`` invocations before ``coro_b()``'s " +"output:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:316 +msgid "" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_b(). I sure hope no one hogs the event loop..." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:323 +msgid "" +"If we change ``await coro_a()`` to ``await asyncio.create_task(coro_a())``, " +"the behavior changes. The coroutine ``main()`` cedes control to the event " +"loop with that statement. The event loop then proceeds through its backlog " +"of work, calling ``task_b`` and then the task which wraps ``coro_a()`` " +"before resuming the coroutine ``main()``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:330 +msgid "" +"I am coro_b(). I sure hope no one hogs the event loop...\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:337 +msgid "" +"This behavior of ``await coroutine`` can trip a lot of people up! That " +"example highlights how using only ``await coroutine`` could unintentionally " +"hog control from other tasks and effectively stall the event loop. :func:" +"`asyncio.run` can help you detect such occurences via the ``debug=True`` " +"flag which accordingly enables :ref:`debug mode `. Among " +"other things, it will log any coroutines that monopolize execution for 100ms " +"or longer." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:347 +msgid "" +"The design intentionally trades off some conceptual clarity around usage of " +"``await`` for improved performance. Each time a task is awaited, control " +"needs to be passed all the way up the call stack to the event loop. That " +"might sound minor, but in a large program with many ``await``'s and a deep " +"callstack that overhead can add up to a meaningful performance drag." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:356 +msgid "A conceptual overview part 2: the nuts and bolts" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:358 +msgid "" +"Part 2 goes into detail on the mechanisms :mod:`!asyncio` uses to manage " +"control flow. This is where the magic happens. You'll come away from this " +"section knowing what ``await`` does behind the scenes and how to make your " +"own asynchronous operators." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:366 +msgid "The inner workings of coroutines" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:368 +msgid ":mod:`!asyncio` leverages four components to pass around control." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:370 +msgid "" +":meth:`coroutine.send(arg) ` is the method used to start or " +"resume a coroutine. If the coroutine was paused and is now being resumed, " +"the argument ``arg`` will be sent in as the return value of the ``yield`` " +"statement which originally paused it. If the coroutine is being used for the " +"first time (as opposed to being resumed) ``arg`` must be ``None``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:378 +msgid "" +"class Rock:\n" +" def __await__(self):\n" +" value_sent_in = yield 7\n" +" print(f\"Rock.__await__ resuming with value: {value_sent_in}.\")\n" +" return value_sent_in\n" +"\n" +"async def main():\n" +" print(\"Beginning coroutine main().\")\n" +" rock = Rock()\n" +" print(\"Awaiting rock...\")\n" +" value_from_rock = await rock\n" +" print(f\"Coroutine received value: {value_from_rock} from rock.\")\n" +" return 23\n" +"\n" +"coroutine = main()\n" +"intermediate_result = coroutine.send(None)\n" +"print(f\"Coroutine paused and returned intermediate value: " +"{intermediate_result}.\")\n" +"\n" +"print(f\"Resuming coroutine and sending in value: 42.\")\n" +"try:\n" +" coroutine.send(42)\n" +"except StopIteration as e:\n" +" returned_value = e.value\n" +"print(f\"Coroutine main() finished and provided value: {returned_value}.\")" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:406 +msgid "" +":ref:`yield `, like usual, pauses execution and returns control " +"to the caller. In the example above, the ``yield``, on line 3, is called by " +"``... = await rock`` on line 11. More broadly speaking, ``await`` calls the :" +"meth:`~object.__await__` method of the given object. ``await`` also does one " +"more very special thing: it propagates (or \"passes along\") any ``yield``\\ " +"s it receives up the call-chain. In this case, that's back to ``... = " +"coroutine.send(None)`` on line 16." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:416 +msgid "" +"The coroutine is resumed via the ``coroutine.send(42)`` call on line 21. The " +"coroutine picks back up from where it ``yield``\\ ed (or paused) on line 3 " +"and executes the remaining statements in its body. When a coroutine " +"finishes, it raises a :exc:`StopIteration` exception with the return value " +"attached in the :attr:`~StopIteration.value` attribute." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:422 +msgid "That snippet produces this output:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:424 +msgid "" +"Beginning coroutine main().\n" +"Awaiting rock...\n" +"Coroutine paused and returned intermediate value: 7.\n" +"Resuming coroutine and sending in value: 42.\n" +"Rock.__await__ resuming with value: 42.\n" +"Coroutine received value: 42 from rock.\n" +"Coroutine main() finished and provided value: 23." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:434 +msgid "" +"It's worth pausing for a moment here and making sure you followed the " +"various ways that control flow and values were passed. A lot of important " +"ideas were covered and it's worth ensuring your understanding is firm." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:438 +msgid "" +"The only way to yield (or effectively cede control) from a coroutine is to " +"``await`` an object that ``yield``\\ s in its ``__await__`` method. That " +"might sound odd to you. You might be thinking:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:442 +msgid "" +"1. What about a ``yield`` directly within the coroutine function? The " +"coroutine function becomes an :ref:`async generator function `, a different beast entirely." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:447 +msgid "" +"2. What about a :ref:`yield from ` within the coroutine function " +"to a (plain) generator? That causes the error: ``SyntaxError: yield from not " +"allowed in a coroutine.`` This was intentionally designed for the sake of " +"simplicity -- mandating only one way of using coroutines. Initially " +"``yield`` was barred as well, but was re-accepted to allow for async " +"generators. Despite that, ``yield from`` and ``await`` effectively do the " +"same thing." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:458 +msgid "Futures" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:460 +msgid "" +"A :ref:`future ` is an object meant to represent a " +"computation's status and result. The term is a nod to the idea of something " +"still to come or not yet happened, and the object is a way to keep an eye on " +"that something." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:465 +msgid "" +"A future has a few important attributes. One is its state which can be " +"either \"pending\", \"cancelled\" or \"done\". Another is its result, which " +"is set when the state transitions to done. Unlike a coroutine, a future does " +"not represent the actual computation to be done; instead, it represents the " +"status and result of that computation, kind of like a status light (red, " +"yellow or green) or indicator." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:472 +msgid "" +":class:`asyncio.Task` subclasses :class:`asyncio.Future` in order to gain " +"these various capabilities. The prior section said tasks store a list of " +"callbacks, which wasn't entirely accurate. It's actually the ``Future`` " +"class that implements this logic, which ``Task`` inherits." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:479 +msgid "" +"Futures may also be used directly (not via tasks). Tasks mark themselves as " +"done when their coroutine is complete. Futures are much more versatile and " +"will be marked as done when you say so. In this way, they're the flexible " +"interface for you to make your own conditions for waiting and resuming." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:487 +msgid "A homemade asyncio.sleep" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:489 +msgid "" +"We'll go through an example of how you could leverage a future to create " +"your own variant of asynchronous sleep (``async_sleep``) which mimics :func:" +"`asyncio.sleep`." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:493 +msgid "" +"This snippet registers a few tasks with the event loop and then awaits a " +"coroutine wrapped in a task: ``async_sleep(3)``. We want that task to finish " +"only after three seconds have elapsed, but without preventing other tasks " +"from running." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:500 +msgid "" +"async def other_work():\n" +" print(\"I like work. Work work.\")\n" +"\n" +"async def main():\n" +" # Add a few other tasks to the event loop, so there's something\n" +" # to do while asynchronously sleeping.\n" +" work_tasks = [\n" +" asyncio.create_task(other_work()),\n" +" asyncio.create_task(other_work()),\n" +" asyncio.create_task(other_work())\n" +" ]\n" +" print(\n" +" \"Beginning asynchronous sleep at time: \"\n" +" f\"{datetime.datetime.now().strftime(\"%H:%M:%S\")}.\"\n" +" )\n" +" await asyncio.create_task(async_sleep(3))\n" +" print(\n" +" \"Done asynchronous sleep at time: \"\n" +" f\"{datetime.datetime.now().strftime(\"%H:%M:%S\")}.\"\n" +" )\n" +" # asyncio.gather effectively awaits each task in the collection.\n" +" await asyncio.gather(*work_tasks)" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:524 +msgid "" +"Below, we use a future to enable custom control over when that task will be " +"marked as done. If :meth:`future.set_result() ` " +"(the method responsible for marking that future as done) is never called, " +"then this task will never finish. We've also enlisted the help of another " +"task, which we'll see in a moment, that will monitor how much time has " +"elapsed and, accordingly, call ``future.set_result()``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:535 +msgid "" +"async def async_sleep(seconds: float):\n" +" future = asyncio.Future()\n" +" time_to_wake = time.time() + seconds\n" +" # Add the watcher-task to the event loop.\n" +" watcher_task = asyncio.create_task(_sleep_watcher(future, " +"time_to_wake))\n" +" # Block until the future is marked as done.\n" +" await future" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:543 +msgid "" +"Below, we'll use a rather bare object, ``YieldToEventLoop()``, to ``yield`` " +"from ``__await__`` in order to cede control to the event loop. This is " +"effectively the same as calling ``asyncio.sleep(0)``, but this approach " +"offers more clarity, not to mention it's somewhat cheating to use ``asyncio." +"sleep`` when showcasing how to implement it!" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:549 +msgid "" +"As usual, the event loop cycles through its tasks, giving them control and " +"receiving control back when they pause or finish. The ``watcher_task``, " +"which runs the coroutine ``_sleep_watcher(...)``, will be invoked once per " +"full cycle of the event loop. On each resumption, it'll check the time and " +"if not enough has elapsed, then it'll pause once again and hand control back " +"to the event loop. Eventually, enough time will have elapsed, and " +"``_sleep_watcher(...)`` will mark the future as done, and then itself finish " +"too by breaking out of the infinite ``while`` loop. Given this helper task " +"is only invoked once per cycle of the event loop, you'd be correct to note " +"that this asynchronous sleep will sleep *at least* three seconds, rather " +"than exactly three seconds. Note this is also of true of ``asyncio.sleep``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:565 +msgid "" +"class YieldToEventLoop:\n" +" def __await__(self):\n" +" yield\n" +"\n" +"async def _sleep_watcher(future, time_to_wake):\n" +" while True:\n" +" if time.time() >= time_to_wake:\n" +" # This marks the future as done.\n" +" future.set_result(None)\n" +" break\n" +" else:\n" +" await YieldToEventLoop()" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:578 +msgid "Here is the full program's output:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:580 +msgid "" +"$ python custom-async-sleep.py\n" +"Beginning asynchronous sleep at time: 14:52:22.\n" +"I like work. Work work.\n" +"I like work. Work work.\n" +"I like work. Work work.\n" +"Done asynchronous sleep at time: 14:52:25." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:589 +msgid "" +"You might feel this implementation of asynchronous sleep was unnecessarily " +"convoluted. And, well, it was. The example was meant to showcase the " +"versatility of futures with a simple example that could be mimicked for more " +"complex needs. For reference, you could implement it without futures, like " +"so::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:596 +msgid "" +"async def simpler_async_sleep(seconds):\n" +" time_to_wake = time.time() + seconds\n" +" while True:\n" +" if time.time() >= time_to_wake:\n" +" return\n" +" else:\n" +" await YieldToEventLoop()" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:604 +msgid "" +"But, that's all for now. Hopefully you're ready to more confidently dive " +"into some async programming or check out advanced topics in the :mod:`rest " +"of the documentation `." +msgstr "" diff --git a/howto/index.po b/howto/index.po index d2b94700c4..76a2da176b 100644 --- a/howto/index.po +++ b/howto/index.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-04 00:13+0000\n" +"POT-Creation-Date: 2025-08-10 00:19+0000\n" "PO-Revision-Date: 2021-07-05 12:45+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,11 +20,11 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" "X-Generator: Poedit 2.4.3\n" -#: ../../howto/index.rst:3 +#: ../../howto/index.rst:5 msgid "Python HOWTOs" msgstr "Python 如何達成任務" -#: ../../howto/index.rst:5 +#: ../../howto/index.rst:7 msgid "" "Python HOWTOs are documents that cover a specific topic in-depth. Modeled on " "the Linux Documentation Project's HOWTO collection, this collection is an " @@ -35,106 +35,110 @@ msgstr "" "定的主題。以 Linux 說明文件專案的 HOWTO 系列為模範,本系列的目標是提供比 " "Python 函式庫參考手冊更實用的說明文件。" -#: ../../howto/index.rst:38 +#: ../../howto/index.rst:41 msgid "General:" msgstr "" -#: ../../howto/index.rst:40 +#: ../../howto/index.rst:43 +msgid ":ref:`a-conceptual-overview-of-asyncio`" +msgstr "" + +#: ../../howto/index.rst:44 msgid ":ref:`annotations-howto`" msgstr ":ref:`annotations-howto`" -#: ../../howto/index.rst:41 +#: ../../howto/index.rst:45 msgid ":ref:`argparse-tutorial`" msgstr ":ref:`argparse-tutorial`" -#: ../../howto/index.rst:42 +#: ../../howto/index.rst:46 msgid ":ref:`descriptorhowto`" msgstr ":ref:`descriptorhowto`" -#: ../../howto/index.rst:43 +#: ../../howto/index.rst:47 msgid ":ref:`enum-howto`" msgstr ":ref:`enum-howto`" -#: ../../howto/index.rst:44 +#: ../../howto/index.rst:48 msgid ":ref:`functional-howto`" msgstr ":ref:`functional-howto`" -#: ../../howto/index.rst:45 +#: ../../howto/index.rst:49 msgid ":ref:`ipaddress-howto`" msgstr ":ref:`ipaddress-howto`" -#: ../../howto/index.rst:46 +#: ../../howto/index.rst:50 msgid ":ref:`logging-howto`" msgstr ":ref:`logging-howto`" -#: ../../howto/index.rst:47 +#: ../../howto/index.rst:51 msgid ":ref:`logging-cookbook`" msgstr ":ref:`logging-cookbook`" -#: ../../howto/index.rst:48 +#: ../../howto/index.rst:52 msgid ":ref:`regex-howto`" msgstr ":ref:`regex-howto`" -#: ../../howto/index.rst:49 +#: ../../howto/index.rst:53 msgid ":ref:`sortinghowto`" msgstr ":ref:`sortinghowto`" -#: ../../howto/index.rst:50 +#: ../../howto/index.rst:54 msgid ":ref:`unicode-howto`" msgstr ":ref:`unicode-howto`" -#: ../../howto/index.rst:51 +#: ../../howto/index.rst:55 msgid ":ref:`urllib-howto`" msgstr ":ref:`urllib-howto`" -#: ../../howto/index.rst:53 +#: ../../howto/index.rst:57 msgid "Advanced development:" msgstr "" -#: ../../howto/index.rst:55 +#: ../../howto/index.rst:59 msgid ":ref:`curses-howto`" msgstr ":ref:`curses-howto`" -#: ../../howto/index.rst:56 +#: ../../howto/index.rst:60 msgid ":ref:`freethreading-python-howto`" msgstr ":ref:`freethreading-python-howto`" -#: ../../howto/index.rst:57 +#: ../../howto/index.rst:61 msgid ":ref:`freethreading-extensions-howto`" msgstr ":ref:`freethreading-extensions-howto`" -#: ../../howto/index.rst:58 +#: ../../howto/index.rst:62 msgid ":ref:`isolating-extensions-howto`" msgstr ":ref:`isolating-extensions-howto`" -#: ../../howto/index.rst:59 +#: ../../howto/index.rst:63 msgid ":ref:`python_2.3_mro`" msgstr ":ref:`python_2.3_mro`" -#: ../../howto/index.rst:60 +#: ../../howto/index.rst:64 msgid ":ref:`socket-howto`" msgstr ":ref:`socket-howto`" -#: ../../howto/index.rst:61 +#: ../../howto/index.rst:65 msgid ":ref:`timerfd-howto`" msgstr ":ref:`timerfd-howto`" -#: ../../howto/index.rst:62 +#: ../../howto/index.rst:66 msgid ":ref:`cporting-howto`" msgstr ":ref:`cporting-howto`" -#: ../../howto/index.rst:64 +#: ../../howto/index.rst:68 msgid "Debugging and profiling:" msgstr "" -#: ../../howto/index.rst:66 +#: ../../howto/index.rst:70 msgid ":ref:`gdb`" msgstr ":ref:`gdb`" -#: ../../howto/index.rst:67 +#: ../../howto/index.rst:71 msgid ":ref:`instrumentation`" msgstr ":ref:`instrumentation`" -#: ../../howto/index.rst:68 +#: ../../howto/index.rst:72 msgid ":ref:`perf_profiling`" msgstr ":ref:`perf_profiling`" diff --git a/library/asyncio-future.po b/library/asyncio-future.po index 94e7426522..4d8e563a85 100644 --- a/library/asyncio-future.po +++ b/library/asyncio-future.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-08-10 00:19+0000\n" "PO-Revision-Date: 2022-01-25 01:29+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -132,18 +132,18 @@ msgstr "" "如果 *future* 不是類 Future 物件且 *loop* 未被指定,同時沒有正在執行的事件迴" "圈,則會發出棄用警告。" -#: ../../library/asyncio-future.rst:79 +#: ../../library/asyncio-future.rst:80 msgid "Future Object" msgstr "Future 物件" -#: ../../library/asyncio-future.rst:83 +#: ../../library/asyncio-future.rst:84 msgid "" "A Future represents an eventual result of an asynchronous operation. Not " "thread-safe." msgstr "" "一個 Future 代表一個非同步運算的最終結果。並不支援執行緒安全 (thread-safe)。" -#: ../../library/asyncio-future.rst:86 +#: ../../library/asyncio-future.rst:87 msgid "" "Future is an :term:`awaitable` object. Coroutines can await on Future " "objects until they either have a result or an exception set, or until they " @@ -152,7 +152,7 @@ msgstr "" "Future 是一個 :term:`awaitable` 物件。協程可以等待 Future 物件直到它們有結果" "或例外被設置、或者被取消。一個 Future 可被多次等待而結果都會是相同的。" -#: ../../library/asyncio-future.rst:91 +#: ../../library/asyncio-future.rst:92 msgid "" "Typically Futures are used to enable low-level callback-based code (e.g. in " "protocols implemented using asyncio :ref:`transports `\\ )能夠與高階 async/await 程式互" "動。" -#: ../../library/asyncio-future.rst:96 +#: ../../library/asyncio-future.rst:97 msgid "" "The rule of thumb is to never expose Future objects in user-facing APIs, and " "the recommended way to create a Future object is to call :meth:`loop." @@ -173,21 +173,21 @@ msgstr "" "meth:`loop.create_future` 來建立 Future 物件。如此一來,不同實作的事件迴圈可" "以注入自己最佳化實作的 Future 物件。" -#: ../../library/asyncio-future.rst:102 +#: ../../library/asyncio-future.rst:103 msgid "Added support for the :mod:`contextvars` module." msgstr "加入對 :mod:`contextvars` 模組的支援。" -#: ../../library/asyncio-future.rst:105 +#: ../../library/asyncio-future.rst:106 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "如果未指定 *loop* 並且沒有正在執行的事件迴圈則會發出棄用警告。" -#: ../../library/asyncio-future.rst:111 +#: ../../library/asyncio-future.rst:112 msgid "Return the result of the Future." msgstr "回傳 Future 的結果。" -#: ../../library/asyncio-future.rst:113 +#: ../../library/asyncio-future.rst:114 msgid "" "If the Future is *done* and has a result set by the :meth:`set_result` " "method, the result value is returned." @@ -195,7 +195,7 @@ msgstr "" "如果 Future 狀態為 *done*\\ (完成),並擁有 :meth:`set_result` 方法設定的一" "個結果,則回傳該結果之值。" -#: ../../library/asyncio-future.rst:116 +#: ../../library/asyncio-future.rst:117 msgid "" "If the Future is *done* and has an exception set by the :meth:" "`set_exception` method, this method raises the exception." @@ -203,7 +203,7 @@ msgstr "" "如果 Future 狀態為 *done*,並擁有 :meth:`set_exception` 方法設定的一個例外," "那麼這個方法會引發該例外。" -#: ../../library/asyncio-future.rst:119 ../../library/asyncio-future.rst:207 +#: ../../library/asyncio-future.rst:120 ../../library/asyncio-future.rst:208 msgid "" "If the Future has been *cancelled*, this method raises a :exc:" "`CancelledError` exception." @@ -211,31 +211,31 @@ msgstr "" "如果 Future 已被 *cancelled*\\ (取消),此方法會引發一個 :exc:" "`CancelledError` 例外。" -#: ../../library/asyncio-future.rst:122 +#: ../../library/asyncio-future.rst:123 msgid "" "If the Future's result isn't yet available, this method raises an :exc:" "`InvalidStateError` exception." msgstr "" "如果 Future 的結果還不可用,此方法會引發一個 :exc:`InvalidStateError` 例外。" -#: ../../library/asyncio-future.rst:127 +#: ../../library/asyncio-future.rst:128 msgid "Mark the Future as *done* and set its result." msgstr "將 Future 標記為 *done* 並設定其結果。" -#: ../../library/asyncio-future.rst:129 ../../library/asyncio-future.rst:136 +#: ../../library/asyncio-future.rst:130 ../../library/asyncio-future.rst:137 msgid "" "Raises an :exc:`InvalidStateError` error if the Future is already *done*." msgstr "如果 Future 已經 *done* 則引發一個 :exc:`InvalidStateError` 錯誤。" -#: ../../library/asyncio-future.rst:134 +#: ../../library/asyncio-future.rst:135 msgid "Mark the Future as *done* and set an exception." msgstr "將 Future 標記為 *done* 並設定一個例外。" -#: ../../library/asyncio-future.rst:141 +#: ../../library/asyncio-future.rst:142 msgid "Return ``True`` if the Future is *done*." msgstr "如果 Future 已為 *done* 則回傳 ``True``。" -#: ../../library/asyncio-future.rst:143 +#: ../../library/asyncio-future.rst:144 msgid "" "A Future is *done* if it was *cancelled* or if it has a result or an " "exception set with :meth:`set_result` or :meth:`set_exception` calls." @@ -243,18 +243,18 @@ msgstr "" "如果 Future 有被 *cancelled*、:meth:`set_result` 有被呼叫來為其設定結果、或 :" "meth:`set_exception` 有被呼叫為其設定例外,那麼它就是 *done*。" -#: ../../library/asyncio-future.rst:149 +#: ../../library/asyncio-future.rst:150 msgid "Return ``True`` if the Future was *cancelled*." msgstr "如果 Future 已經被 *cancelled* 則回傳 ``True``。" -#: ../../library/asyncio-future.rst:151 +#: ../../library/asyncio-future.rst:152 msgid "" "The method is usually used to check if a Future is not *cancelled* before " "setting a result or an exception for it::" msgstr "" "這個方法通常在為 Future 設定結果或例外前用來確認它還沒被 *cancelled*: ::" -#: ../../library/asyncio-future.rst:154 +#: ../../library/asyncio-future.rst:155 msgid "" "if not fut.cancelled():\n" " fut.set_result(42)" @@ -262,15 +262,15 @@ msgstr "" "if not fut.cancelled():\n" " fut.set_result(42)" -#: ../../library/asyncio-future.rst:159 +#: ../../library/asyncio-future.rst:160 msgid "Add a callback to be run when the Future is *done*." msgstr "新增一個在 Future 為 *done* 時執行的回呼函式。" -#: ../../library/asyncio-future.rst:161 +#: ../../library/asyncio-future.rst:162 msgid "The *callback* is called with the Future object as its only argument." msgstr "呼叫 *callback* 並附帶做為唯一引數的 Future 物件。" -#: ../../library/asyncio-future.rst:164 +#: ../../library/asyncio-future.rst:165 msgid "" "If the Future is already *done* when this method is called, the callback is " "scheduled with :meth:`loop.call_soon`." @@ -278,7 +278,7 @@ msgstr "" "如果呼叫這個方法時 Future 已經為 *done*,回呼函式會被 :meth:`loop.call_soon` " "排程。" -#: ../../library/asyncio-future.rst:167 +#: ../../library/asyncio-future.rst:168 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *callback* to run in. The current " @@ -287,40 +287,40 @@ msgstr "" "可選僅限關鍵字引數 *context* 用來指定一個讓 *callback* 執行於其中的客製化 :" "class:`contextvars.Context` 物件。如果沒有提供 *context*,則使用目前情境。" -#: ../../library/asyncio-future.rst:171 +#: ../../library/asyncio-future.rst:172 msgid "" ":func:`functools.partial` can be used to pass parameters to the callback, e." "g.::" msgstr "可以用 :func:`functools.partial` 傳遞引數給回呼函式,例如: ::" -#: ../../library/asyncio-future.rst:174 +#: ../../library/asyncio-future.rst:175 msgid "" "# Call 'print(\"Future:\", fut)' when \"fut\" is done.\n" "fut.add_done_callback(\n" " functools.partial(print, \"Future:\"))" msgstr "" -#: ../../library/asyncio-future.rst:178 +#: ../../library/asyncio-future.rst:179 msgid "" "The *context* keyword-only parameter was added. See :pep:`567` for more " "details." msgstr "加入僅限關鍵字參數 *context*。更多細節請參閱 :pep:`567`。" -#: ../../library/asyncio-future.rst:184 +#: ../../library/asyncio-future.rst:185 msgid "Remove *callback* from the callbacks list." msgstr "從回呼列表中移除 *callback*。" -#: ../../library/asyncio-future.rst:186 +#: ../../library/asyncio-future.rst:187 msgid "" "Returns the number of callbacks removed, which is typically 1, unless a " "callback was added more than once." msgstr "回傳被移除的回呼函式數量,通常為 1,除非一個回呼函式被多次加入。" -#: ../../library/asyncio-future.rst:191 +#: ../../library/asyncio-future.rst:192 msgid "Cancel the Future and schedule callbacks." msgstr "取消 Future 並為回呼函式排程。" -#: ../../library/asyncio-future.rst:193 +#: ../../library/asyncio-future.rst:194 msgid "" "If the Future is already *done* or *cancelled*, return ``False``. Otherwise, " "change the Future's state to *cancelled*, schedule the callbacks, and return " @@ -329,33 +329,33 @@ msgstr "" "如果 Future 已經是 *done* 或 *cancelled*,回傳 ``False``。否則將 Future 狀態" "改為 *cancelled* 並在為回呼函式排程後回傳 ``True``。" -#: ../../library/asyncio-future.rst:197 +#: ../../library/asyncio-future.rst:198 msgid "Added the *msg* parameter." msgstr "新增 *msg* 參數。" -#: ../../library/asyncio-future.rst:202 +#: ../../library/asyncio-future.rst:203 msgid "Return the exception that was set on this Future." msgstr "回傳被設定於此 Future 的例外。" -#: ../../library/asyncio-future.rst:204 +#: ../../library/asyncio-future.rst:205 msgid "" "The exception (or ``None`` if no exception was set) is returned only if the " "Future is *done*." msgstr "" "只有 Future 在 *done* 時才回傳例外(如果沒有設定例外則回傳 ``None``\\ )。" -#: ../../library/asyncio-future.rst:210 +#: ../../library/asyncio-future.rst:211 msgid "" "If the Future isn't *done* yet, this method raises an :exc:" "`InvalidStateError` exception." msgstr "" "如果 Future 還不為 *done*,此方法會引發一個 :exc:`InvalidStateError` 例外。" -#: ../../library/asyncio-future.rst:215 +#: ../../library/asyncio-future.rst:216 msgid "Return the event loop the Future object is bound to." msgstr "回傳已被 Future 物件繫結 (bind) 的事件迴圈。" -#: ../../library/asyncio-future.rst:222 +#: ../../library/asyncio-future.rst:223 msgid "" "This example creates a Future object, creates and schedules an asynchronous " "Task to set result for the Future, and waits until the Future has a result::" @@ -363,7 +363,7 @@ msgstr "" "這個例子建立一個 Future 物件,建立一個非同步 Task 並為其排程以設定 Future 結" "果,然後等待 Future 結果出現: ::" -#: ../../library/asyncio-future.rst:226 +#: ../../library/asyncio-future.rst:227 msgid "" "async def set_after(fut, delay, value):\n" " # Sleep for *delay* seconds.\n" @@ -394,7 +394,7 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-future.rst:257 +#: ../../library/asyncio-future.rst:258 msgid "" "The Future object was designed to mimic :class:`concurrent.futures.Future`. " "Key differences include:" @@ -402,7 +402,7 @@ msgstr "" "該 Future 物件是為了模仿 :class:`concurrent.futures.Future` 而設計。主要差異" "包含:" -#: ../../library/asyncio-future.rst:260 +#: ../../library/asyncio-future.rst:261 msgid "" "unlike asyncio Futures, :class:`concurrent.futures.Future` instances cannot " "be awaited." @@ -410,7 +410,7 @@ msgstr "" "與 asyncio 的 Future 不同,:class:`concurrent.futures.Future` 實例不可被等" "待。" -#: ../../library/asyncio-future.rst:263 +#: ../../library/asyncio-future.rst:264 msgid "" ":meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception` do not " "accept the *timeout* argument." @@ -418,7 +418,7 @@ msgstr "" ":meth:`asyncio.Future.result` 和 :meth:`asyncio.Future.exception` 不接受 " "*timeout* 引數。" -#: ../../library/asyncio-future.rst:266 +#: ../../library/asyncio-future.rst:267 msgid "" ":meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception` raise an :" "exc:`InvalidStateError` exception when the Future is not *done*." @@ -426,7 +426,7 @@ msgstr "" "Future 不為 *done* 時 :meth:`asyncio.Future.result` 和 :meth:`asyncio.Future." "exception` 會引發一個 :exc:`InvalidStateError` 例外。" -#: ../../library/asyncio-future.rst:270 +#: ../../library/asyncio-future.rst:271 msgid "" "Callbacks registered with :meth:`asyncio.Future.add_done_callback` are not " "called immediately. They are scheduled with :meth:`loop.call_soon` instead." @@ -434,7 +434,7 @@ msgstr "" "使用 :meth:`asyncio.Future.add_done_callback` 註冊的回呼函式不會立即呼叫,而" "是被 :meth:`loop.call_soon` 排程。" -#: ../../library/asyncio-future.rst:274 +#: ../../library/asyncio-future.rst:275 msgid "" "asyncio Future is not compatible with the :func:`concurrent.futures.wait` " "and :func:`concurrent.futures.as_completed` functions." @@ -442,7 +442,7 @@ msgstr "" "asyncio Future 不能與 :func:`concurrent.futures.wait` 和 :func:`concurrent." "futures.as_completed` 函式相容。" -#: ../../library/asyncio-future.rst:278 +#: ../../library/asyncio-future.rst:279 msgid "" ":meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument, but :" "meth:`concurrent.futures.Future.cancel` does not." diff --git a/library/asyncio-task.po b/library/asyncio-task.po index 9d69ab5503..07925812b0 100644 --- a/library/asyncio-task.po +++ b/library/asyncio-task.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-14 00:15+0000\n" +"POT-Creation-Date: 2025-08-10 00:19+0000\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -199,8 +199,8 @@ msgstr "" #: ../../library/asyncio-task.rst:110 msgid "" -"The :class:`asyncio.TaskGroup` class provides a more modern alternative " -"to :func:`create_task`. Using this API, the last example becomes::" +"The :class:`asyncio.TaskGroup` class provides a more modern alternative to :" +"func:`create_task`. Using this API, the last example becomes::" msgstr "" #: ../../library/asyncio-task.rst:114 @@ -234,8 +234,8 @@ msgstr "" #: ../../library/asyncio-task.rst:139 msgid "" -"We say that an object is an **awaitable** object if it can be used in " -"an :keyword:`await` expression. Many asyncio APIs are designed to accept " +"We say that an object is an **awaitable** object if it can be used in an :" +"keyword:`await` expression. Many asyncio APIs are designed to accept " "awaitables." msgstr "" @@ -295,9 +295,8 @@ msgstr "" #: ../../library/asyncio-task.rst:183 msgid "" -"When a coroutine is wrapped into a *Task* with functions " -"like :func:`asyncio.create_task` the coroutine is automatically scheduled to " -"run soon::" +"When a coroutine is wrapped into a *Task* with functions like :func:`asyncio." +"create_task` the coroutine is automatically scheduled to run soon::" msgstr "" #: ../../library/asyncio-task.rst:187 @@ -367,8 +366,8 @@ msgstr "" #: ../../library/asyncio-task.rst:230 msgid "" -"A good example of a low-level function that returns a Future object " -"is :meth:`loop.run_in_executor`." +"A good example of a low-level function that returns a Future object is :meth:" +"`loop.run_in_executor`." msgstr "" #: ../../library/asyncio-task.rst:235 @@ -387,22 +386,21 @@ msgstr "" #: ../../library/asyncio-task.rst:246 msgid "" -"If *name* is not ``None``, it is set as the name of the task " -"using :meth:`Task.set_name`." +"If *name* is not ``None``, it is set as the name of the task using :meth:" +"`Task.set_name`." msgstr "" #: ../../library/asyncio-task.rst:249 msgid "" -"An optional keyword-only *context* argument allows specifying a " -"custom :class:`contextvars.Context` for the *coro* to run in. The current " -"context copy is created when no *context* is provided." +"An optional keyword-only *context* argument allows specifying a custom :" +"class:`contextvars.Context` for the *coro* to run in. The current context " +"copy is created when no *context* is provided." msgstr "" #: ../../library/asyncio-task.rst:253 msgid "" -"The task is executed in the loop returned " -"by :func:`get_running_loop`, :exc:`RuntimeError` is raised if there is no " -"running loop in current thread." +"The task is executed in the loop returned by :func:`get_running_loop`, :exc:" +"`RuntimeError` is raised if there is no running loop in current thread." msgstr "" #: ../../library/asyncio-task.rst:259 @@ -437,11 +435,11 @@ msgid "" " task.add_done_callback(background_tasks.discard)" msgstr "" -#: ../../library/asyncio-task.rst:287 ../../library/asyncio-task.rst:1192 +#: ../../library/asyncio-task.rst:287 ../../library/asyncio-task.rst:1193 msgid "Added the *name* parameter." msgstr "新增 *name* 參數。" -#: ../../library/asyncio-task.rst:290 ../../library/asyncio-task.rst:1199 +#: ../../library/asyncio-task.rst:290 ../../library/asyncio-task.rst:1200 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" @@ -451,30 +449,28 @@ msgstr "" #: ../../library/asyncio-task.rst:297 msgid "" -"Tasks can easily and safely be cancelled. When a task is " -"cancelled, :exc:`asyncio.CancelledError` will be raised in the task at the " -"next opportunity." +"Tasks can easily and safely be cancelled. When a task is cancelled, :exc:" +"`asyncio.CancelledError` will be raised in the task at the next opportunity." msgstr "" #: ../../library/asyncio-task.rst:301 msgid "" "It is recommended that coroutines use ``try/finally`` blocks to robustly " "perform clean-up logic. In case :exc:`asyncio.CancelledError` is explicitly " -"caught, it should generally be propagated when clean-up is " -"complete. :exc:`asyncio.CancelledError` directly " -"subclasses :exc:`BaseException` so most code will not need to be aware of it." +"caught, it should generally be propagated when clean-up is complete. :exc:" +"`asyncio.CancelledError` directly subclasses :exc:`BaseException` so most " +"code will not need to be aware of it." msgstr "" #: ../../library/asyncio-task.rst:307 msgid "" -"The asyncio components that enable structured concurrency, " -"like :class:`asyncio.TaskGroup` and :func:`asyncio.timeout`, are implemented " -"using cancellation internally and might misbehave if a coroutine " -"swallows :exc:`asyncio.CancelledError`. Similarly, user code should not " -"generally call :meth:`uncancel `. However, in cases " -"when suppressing :exc:`asyncio.CancelledError` is truly desired, it is " -"necessary to also call ``uncancel()`` to completely remove the cancellation " -"state." +"The asyncio components that enable structured concurrency, like :class:" +"`asyncio.TaskGroup` and :func:`asyncio.timeout`, are implemented using " +"cancellation internally and might misbehave if a coroutine swallows :exc:" +"`asyncio.CancelledError`. Similarly, user code should not generally call :" +"meth:`uncancel `. However, in cases when suppressing :" +"exc:`asyncio.CancelledError` is truly desired, it is necessary to also call " +"``uncancel()`` to completely remove the cancellation state." msgstr "" #: ../../library/asyncio-task.rst:319 @@ -496,10 +492,10 @@ msgstr "" #: ../../library/asyncio-task.rst:335 msgid "" -"Create a task in this task group. The signature matches that " -"of :func:`asyncio.create_task`. If the task group is inactive (e.g. not yet " -"entered, already finished, or in the process of shutting down), we will " -"close the given ``coro``." +"Create a task in this task group. The signature matches that of :func:" +"`asyncio.create_task`. If the task group is inactive (e.g. not yet entered, " +"already finished, or in the process of shutting down), we will close the " +"given ``coro``." msgstr "" #: ../../library/asyncio-task.rst:343 @@ -518,8 +514,8 @@ msgid "" " async with asyncio.TaskGroup() as tg:\n" " task1 = tg.create_task(some_coro(...))\n" " task2 = tg.create_task(another_coro(...))\n" -" print(f\"Both tasks have completed now: {task1.result()}, " -"{task2.result()}\")" +" print(f\"Both tasks have completed now: {task1.result()}, {task2." +"result()}\")" msgstr "" #: ../../library/asyncio-task.rst:353 @@ -536,11 +532,11 @@ msgid "" "The first time any of the tasks belonging to the group fails with an " "exception other than :exc:`asyncio.CancelledError`, the remaining tasks in " "the group are cancelled. No further tasks can then be added to the group. At " -"this point, if the body of the ``async with`` statement is still active " -"(i.e., :meth:`~object.__aexit__` hasn't been called yet), the task directly " -"containing the ``async with`` statement is also cancelled. The " -"resulting :exc:`asyncio.CancelledError` will interrupt an ``await``, but it " -"will not bubble out of the containing ``async with`` statement." +"this point, if the body of the ``async with`` statement is still active (i." +"e., :meth:`~object.__aexit__` hasn't been called yet), the task directly " +"containing the ``async with`` statement is also cancelled. The resulting :" +"exc:`asyncio.CancelledError` will interrupt an ``await``, but it will not " +"bubble out of the containing ``async with`` statement." msgstr "" #: ../../library/asyncio-task.rst:370 @@ -553,24 +549,23 @@ msgstr "" #: ../../library/asyncio-task.rst:377 msgid "" -"Two base exceptions are treated specially: If any task fails " -"with :exc:`KeyboardInterrupt` or :exc:`SystemExit`, the task group still " -"cancels the remaining tasks and waits for them, but then the " -"initial :exc:`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead " -"of :exc:`ExceptionGroup` or :exc:`BaseExceptionGroup`." +"Two base exceptions are treated specially: If any task fails with :exc:" +"`KeyboardInterrupt` or :exc:`SystemExit`, the task group still cancels the " +"remaining tasks and waits for them, but then the initial :exc:" +"`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead of :exc:" +"`ExceptionGroup` or :exc:`BaseExceptionGroup`." msgstr "" #: ../../library/asyncio-task.rst:383 msgid "" -"If the body of the ``async with`` statement exits with an exception " -"(so :meth:`~object.__aexit__` is called with an exception set), this is " -"treated the same as if one of the tasks failed: the remaining tasks are " -"cancelled and then waited for, and non-cancellation exceptions are grouped " -"into an exception group and raised. The exception passed " -"into :meth:`~object.__aexit__`, unless it is :exc:`asyncio.CancelledError`, " -"is also included in the exception group. The same special case is made " -"for :exc:`KeyboardInterrupt` and :exc:`SystemExit` as in the previous " -"paragraph." +"If the body of the ``async with`` statement exits with an exception (so :" +"meth:`~object.__aexit__` is called with an exception set), this is treated " +"the same as if one of the tasks failed: the remaining tasks are cancelled " +"and then waited for, and non-cancellation exceptions are grouped into an " +"exception group and raised. The exception passed into :meth:`~object." +"__aexit__`, unless it is :exc:`asyncio.CancelledError`, is also included in " +"the exception group. The same special case is made for :exc:" +"`KeyboardInterrupt` and :exc:`SystemExit` as in the previous paragraph." msgstr "" #: ../../library/asyncio-task.rst:395 @@ -587,16 +582,15 @@ msgstr "" #: ../../library/asyncio-task.rst:403 msgid "" "In the case where a task group is cancelled externally and also must raise " -"an :exc:`ExceptionGroup`, it will call the parent " -"task's :meth:`~asyncio.Task.cancel` method. This ensures that " -"a :exc:`asyncio.CancelledError` will be raised at the next :keyword:`await`, " -"so the cancellation is not lost." +"an :exc:`ExceptionGroup`, it will call the parent task's :meth:`~asyncio." +"Task.cancel` method. This ensures that a :exc:`asyncio.CancelledError` will " +"be raised at the next :keyword:`await`, so the cancellation is not lost." msgstr "" #: ../../library/asyncio-task.rst:409 msgid "" -"Task groups preserve the cancellation count reported " -"by :meth:`asyncio.Task.cancelling`." +"Task groups preserve the cancellation count reported by :meth:`asyncio.Task." +"cancelling`." msgstr "" #: ../../library/asyncio-task.rst:414 @@ -863,12 +857,12 @@ msgstr "" #: ../../library/asyncio-task.rst:618 msgid "" -"When using this factory " -"(via :meth:`loop.set_task_factory(asyncio.eager_task_factory) " -"`), coroutines begin execution synchronously " -"during :class:`Task` construction. Tasks are only scheduled on the event " -"loop if they block. This can be a performance improvement as the overhead of " -"loop scheduling is avoided for coroutines that complete synchronously." +"When using this factory (via :meth:`loop.set_task_factory(asyncio." +"eager_task_factory) `), coroutines begin execution " +"synchronously during :class:`Task` construction. Tasks are only scheduled on " +"the event loop if they block. This can be a performance improvement as the " +"overhead of loop scheduling is avoided for coroutines that complete " +"synchronously." msgstr "" #: ../../library/asyncio-task.rst:624 @@ -896,15 +890,15 @@ msgstr "" #: ../../library/asyncio-task.rst:644 msgid "" "*custom_task_constructor* must be a *callable* with the signature matching " -"the signature of :class:`Task.__init__ `. The callable must return " -"a :class:`asyncio.Task`-compatible object." +"the signature of :class:`Task.__init__ `. The callable must return a :" +"class:`asyncio.Task`-compatible object." msgstr "" #: ../../library/asyncio-task.rst:648 msgid "" "This function returns a *callable* intended to be used as a task factory of " -"an event loop via :meth:`loop.set_task_factory(factory) " -"`)." +"an event loop via :meth:`loop.set_task_factory(factory) `)." msgstr "" #: ../../library/asyncio-task.rst:655 @@ -913,8 +907,8 @@ msgstr "" #: ../../library/asyncio-task.rst:659 msgid "" -"Protect an :ref:`awaitable object ` from " -"being :meth:`cancelled `." +"Protect an :ref:`awaitable object ` from being :meth:" +"`cancelled `." msgstr "" #: ../../library/asyncio-task.rst:662 ../../library/asyncio-task.rst:829 @@ -946,8 +940,8 @@ msgid "" "*except* that if the coroutine containing it is cancelled, the Task running " "in ``something()`` is not cancelled. From the point of view of " "``something()``, the cancellation did not happen. Although its caller is " -"still cancelled, so the \"await\" expression still raises " -"a :exc:`CancelledError`." +"still cancelled, so the \"await\" expression still raises a :exc:" +"`CancelledError`." msgstr "" #: ../../library/asyncio-task.rst:679 @@ -1010,8 +1004,8 @@ msgstr "" #: ../../library/asyncio-task.rst:721 msgid "" -"In either case, the context manager can be rescheduled after creation " -"using :meth:`Timeout.reschedule`." +"In either case, the context manager can be rescheduled after creation using :" +"meth:`Timeout.reschedule`." msgstr "" #: ../../library/asyncio-task.rst:726 @@ -1027,16 +1021,16 @@ msgstr "" #: ../../library/asyncio-task.rst:730 msgid "" "If ``long_running_task`` takes more than 10 seconds to complete, the context " -"manager will cancel the current task and handle the " -"resulting :exc:`asyncio.CancelledError` internally, transforming it into " -"a :exc:`TimeoutError` which can be caught and handled." +"manager will cancel the current task and handle the resulting :exc:`asyncio." +"CancelledError` internally, transforming it into a :exc:`TimeoutError` which " +"can be caught and handled." msgstr "" #: ../../library/asyncio-task.rst:737 msgid "" -"The :func:`asyncio.timeout` context manager is what transforms " -"the :exc:`asyncio.CancelledError` into a :exc:`TimeoutError`, which means " -"the :exc:`TimeoutError` can only be caught *outside* of the context manager." +"The :func:`asyncio.timeout` context manager is what transforms the :exc:" +"`asyncio.CancelledError` into a :exc:`TimeoutError`, which means the :exc:" +"`TimeoutError` can only be caught *outside* of the context manager." msgstr "" #: ../../library/asyncio-task.rst:742 @@ -1157,8 +1151,8 @@ msgstr "" #: ../../library/asyncio-task.rst:838 msgid "" -"To avoid the task :meth:`cancellation `, wrap it " -"in :func:`shield`." +"To avoid the task :meth:`cancellation `, wrap it in :func:" +"`shield`." msgstr "" #: ../../library/asyncio-task.rst:841 @@ -1264,8 +1258,8 @@ msgstr "" #: ../../library/asyncio-task.rst:919 msgid "" "The function will return when any future finishes by raising an exception. " -"If no future raises an exception then it is equivalent " -"to :const:`ALL_COMPLETED`." +"If no future raises an exception then it is equivalent to :const:" +"`ALL_COMPLETED`." msgstr "" #: ../../library/asyncio-task.rst:924 @@ -1295,11 +1289,11 @@ msgstr "" #: ../../library/asyncio-task.rst:945 msgid "" -"The object returned by ``as_completed()`` can be iterated as " -"an :term:`asynchronous iterator` or a plain :term:`iterator`. When " -"asynchronous iteration is used, the originally-supplied awaitables are " -"yielded if they are tasks or futures. This makes it easy to correlate " -"previously-scheduled tasks with their results. Example::" +"The object returned by ``as_completed()`` can be iterated as an :term:" +"`asynchronous iterator` or a plain :term:`iterator`. When asynchronous " +"iteration is used, the originally-supplied awaitables are yielded if they " +"are tasks or futures. This makes it easy to correlate previously-scheduled " +"tasks with their results. Example::" msgstr "" #: ../../library/asyncio-task.rst:951 @@ -1530,17 +1524,17 @@ msgstr "" msgid "Return ``True`` if *obj* is a coroutine object." msgstr "" -#: ../../library/asyncio-task.rst:1140 +#: ../../library/asyncio-task.rst:1141 msgid "Task Object" msgstr "Task 物件" -#: ../../library/asyncio-task.rst:1144 +#: ../../library/asyncio-task.rst:1145 msgid "" "A :class:`Future-like ` object that runs a Python :ref:`coroutine " "`. Not thread-safe." msgstr "" -#: ../../library/asyncio-task.rst:1147 +#: ../../library/asyncio-task.rst:1148 msgid "" "Tasks are used to run coroutines in event loops. If a coroutine awaits on a " "Future, the Task suspends the execution of the coroutine and waits for the " @@ -1548,21 +1542,21 @@ msgid "" "wrapped coroutine resumes." msgstr "" -#: ../../library/asyncio-task.rst:1153 +#: ../../library/asyncio-task.rst:1154 msgid "" "Event loops use cooperative scheduling: an event loop runs one Task at a " "time. While a Task awaits for the completion of a Future, the event loop " "runs other Tasks, callbacks, or performs IO operations." msgstr "" -#: ../../library/asyncio-task.rst:1158 +#: ../../library/asyncio-task.rst:1159 msgid "" "Use the high-level :func:`asyncio.create_task` function to create Tasks, or " "the low-level :meth:`loop.create_task` or :func:`ensure_future` functions. " "Manual instantiation of Tasks is discouraged." msgstr "" -#: ../../library/asyncio-task.rst:1163 +#: ../../library/asyncio-task.rst:1164 msgid "" "To cancel a running Task use the :meth:`cancel` method. Calling it will " "cause the Task to throw a :exc:`CancelledError` exception into the wrapped " @@ -1570,28 +1564,28 @@ msgid "" "cancellation, the Future object will be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1168 +#: ../../library/asyncio-task.rst:1169 msgid "" ":meth:`cancelled` can be used to check if the Task was cancelled. The method " -"returns ``True`` if the wrapped coroutine did not suppress " -"the :exc:`CancelledError` exception and was actually cancelled." +"returns ``True`` if the wrapped coroutine did not suppress the :exc:" +"`CancelledError` exception and was actually cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1173 +#: ../../library/asyncio-task.rst:1174 msgid "" -":class:`asyncio.Task` inherits from :class:`Future` all of its APIs " -"except :meth:`Future.set_result` and :meth:`Future.set_exception`." +":class:`asyncio.Task` inherits from :class:`Future` all of its APIs except :" +"meth:`Future.set_result` and :meth:`Future.set_exception`." msgstr "" -#: ../../library/asyncio-task.rst:1177 +#: ../../library/asyncio-task.rst:1178 msgid "" -"An optional keyword-only *context* argument allows specifying a " -"custom :class:`contextvars.Context` for the *coro* to run in. If no " -"*context* is provided, the Task copies the current context and later runs " -"its coroutine in the copied context." +"An optional keyword-only *context* argument allows specifying a custom :" +"class:`contextvars.Context` for the *coro* to run in. If no *context* is " +"provided, the Task copies the current context and later runs its coroutine " +"in the copied context." msgstr "" -#: ../../library/asyncio-task.rst:1182 +#: ../../library/asyncio-task.rst:1183 msgid "" "An optional keyword-only *eager_start* argument allows eagerly starting the " "execution of the :class:`asyncio.Task` at task creation time. If set to " @@ -1601,96 +1595,96 @@ msgid "" "eagerly and will skip scheduling to the event loop." msgstr "" -#: ../../library/asyncio-task.rst:1189 +#: ../../library/asyncio-task.rst:1190 msgid "Added support for the :mod:`contextvars` module." msgstr "新增對 :mod:`contextvars` 模組的支援。" -#: ../../library/asyncio-task.rst:1195 +#: ../../library/asyncio-task.rst:1196 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "" -#: ../../library/asyncio-task.rst:1202 +#: ../../library/asyncio-task.rst:1203 msgid "Added the *eager_start* parameter." msgstr "新增 *eager_start* 參數。" -#: ../../library/asyncio-task.rst:1207 +#: ../../library/asyncio-task.rst:1208 msgid "Return ``True`` if the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1209 +#: ../../library/asyncio-task.rst:1210 msgid "" "A Task is *done* when the wrapped coroutine either returned a value, raised " "an exception, or the Task was cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1214 +#: ../../library/asyncio-task.rst:1215 msgid "Return the result of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1216 +#: ../../library/asyncio-task.rst:1217 msgid "" "If the Task is *done*, the result of the wrapped coroutine is returned (or " "if the coroutine raised an exception, that exception is re-raised.)" msgstr "" -#: ../../library/asyncio-task.rst:1220 ../../library/asyncio-task.rst:1234 +#: ../../library/asyncio-task.rst:1221 ../../library/asyncio-task.rst:1235 msgid "" "If the Task has been *cancelled*, this method raises a :exc:`CancelledError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1223 +#: ../../library/asyncio-task.rst:1224 msgid "" -"If the Task's result isn't yet available, this method raises " -"an :exc:`InvalidStateError` exception." +"If the Task's result isn't yet available, this method raises an :exc:" +"`InvalidStateError` exception." msgstr "" -#: ../../library/asyncio-task.rst:1228 +#: ../../library/asyncio-task.rst:1229 msgid "Return the exception of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1230 +#: ../../library/asyncio-task.rst:1231 msgid "" "If the wrapped coroutine raised an exception that exception is returned. If " "the wrapped coroutine returned normally this method returns ``None``." msgstr "" -#: ../../library/asyncio-task.rst:1237 +#: ../../library/asyncio-task.rst:1238 msgid "" "If the Task isn't *done* yet, this method raises an :exc:`InvalidStateError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1242 +#: ../../library/asyncio-task.rst:1243 msgid "Add a callback to be run when the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1244 ../../library/asyncio-task.rst:1253 +#: ../../library/asyncio-task.rst:1245 ../../library/asyncio-task.rst:1254 msgid "This method should only be used in low-level callback-based code." msgstr "" -#: ../../library/asyncio-task.rst:1246 +#: ../../library/asyncio-task.rst:1247 msgid "" "See the documentation of :meth:`Future.add_done_callback` for more details." msgstr "" -#: ../../library/asyncio-task.rst:1251 +#: ../../library/asyncio-task.rst:1252 msgid "Remove *callback* from the callbacks list." msgstr "" -#: ../../library/asyncio-task.rst:1255 +#: ../../library/asyncio-task.rst:1256 msgid "" "See the documentation of :meth:`Future.remove_done_callback` for more " "details." msgstr "" -#: ../../library/asyncio-task.rst:1260 +#: ../../library/asyncio-task.rst:1261 msgid "Return the list of stack frames for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1262 +#: ../../library/asyncio-task.rst:1263 msgid "" "If the wrapped coroutine is not done, this returns the stack where it is " "suspended. If the coroutine has completed successfully or was cancelled, " @@ -1698,15 +1692,15 @@ msgid "" "this returns the list of traceback frames." msgstr "" -#: ../../library/asyncio-task.rst:1268 +#: ../../library/asyncio-task.rst:1269 msgid "The frames are always ordered from oldest to newest." msgstr "" -#: ../../library/asyncio-task.rst:1270 +#: ../../library/asyncio-task.rst:1271 msgid "Only one stack frame is returned for a suspended coroutine." msgstr "" -#: ../../library/asyncio-task.rst:1272 +#: ../../library/asyncio-task.rst:1273 msgid "" "The optional *limit* argument sets the maximum number of frames to return; " "by default all available frames are returned. The ordering of the returned " @@ -1715,113 +1709,113 @@ msgid "" "are returned. (This matches the behavior of the traceback module.)" msgstr "" -#: ../../library/asyncio-task.rst:1281 +#: ../../library/asyncio-task.rst:1282 msgid "Print the stack or traceback for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1283 +#: ../../library/asyncio-task.rst:1284 msgid "" "This produces output similar to that of the traceback module for the frames " "retrieved by :meth:`get_stack`." msgstr "" -#: ../../library/asyncio-task.rst:1286 +#: ../../library/asyncio-task.rst:1287 msgid "The *limit* argument is passed to :meth:`get_stack` directly." msgstr "" -#: ../../library/asyncio-task.rst:1288 +#: ../../library/asyncio-task.rst:1289 msgid "" "The *file* argument is an I/O stream to which the output is written; by " "default output is written to :data:`sys.stdout`." msgstr "" -#: ../../library/asyncio-task.rst:1293 +#: ../../library/asyncio-task.rst:1294 msgid "Return the coroutine object wrapped by the :class:`Task`." msgstr "" -#: ../../library/asyncio-task.rst:1297 +#: ../../library/asyncio-task.rst:1298 msgid "" "This will return ``None`` for Tasks which have already completed eagerly. " "See the :ref:`Eager Task Factory `." msgstr "" -#: ../../library/asyncio-task.rst:1304 +#: ../../library/asyncio-task.rst:1305 msgid "Newly added eager task execution means result may be ``None``." msgstr "" -#: ../../library/asyncio-task.rst:1308 +#: ../../library/asyncio-task.rst:1309 msgid "" "Return the :class:`contextvars.Context` object associated with the task." msgstr "" -#: ../../library/asyncio-task.rst:1315 +#: ../../library/asyncio-task.rst:1316 msgid "Return the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1317 +#: ../../library/asyncio-task.rst:1318 msgid "" "If no name has been explicitly assigned to the Task, the default asyncio " "Task implementation generates a default name during instantiation." msgstr "" -#: ../../library/asyncio-task.rst:1325 +#: ../../library/asyncio-task.rst:1326 msgid "Set the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1327 +#: ../../library/asyncio-task.rst:1328 msgid "" "The *value* argument can be any object, which is then converted to a string." msgstr "" -#: ../../library/asyncio-task.rst:1330 +#: ../../library/asyncio-task.rst:1331 msgid "" -"In the default Task implementation, the name will be visible in " -"the :func:`repr` output of a task object." +"In the default Task implementation, the name will be visible in the :func:" +"`repr` output of a task object." msgstr "" -#: ../../library/asyncio-task.rst:1337 +#: ../../library/asyncio-task.rst:1338 msgid "Request the Task to be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1339 +#: ../../library/asyncio-task.rst:1340 msgid "" "If the Task is already *done* or *cancelled*, return ``False``, otherwise, " "return ``True``." msgstr "" -#: ../../library/asyncio-task.rst:1342 +#: ../../library/asyncio-task.rst:1343 msgid "" "The method arranges for a :exc:`CancelledError` exception to be thrown into " "the wrapped coroutine on the next cycle of the event loop." msgstr "" -#: ../../library/asyncio-task.rst:1345 +#: ../../library/asyncio-task.rst:1346 msgid "" "The coroutine then has a chance to clean up or even deny the request by " "suppressing the exception with a :keyword:`try` ... ... ``except " -"CancelledError`` ... :keyword:`finally` block. Therefore, " -"unlike :meth:`Future.cancel`, :meth:`Task.cancel` does not guarantee that " -"the Task will be cancelled, although suppressing cancellation completely is " -"not common and is actively discouraged. Should the coroutine nevertheless " -"decide to suppress the cancellation, it needs to call :meth:`Task.uncancel` " -"in addition to catching the exception." +"CancelledError`` ... :keyword:`finally` block. Therefore, unlike :meth:" +"`Future.cancel`, :meth:`Task.cancel` does not guarantee that the Task will " +"be cancelled, although suppressing cancellation completely is not common and " +"is actively discouraged. Should the coroutine nevertheless decide to " +"suppress the cancellation, it needs to call :meth:`Task.uncancel` in " +"addition to catching the exception." msgstr "" -#: ../../library/asyncio-task.rst:1355 +#: ../../library/asyncio-task.rst:1356 msgid "Added the *msg* parameter." msgstr "新增 *msg* 參數。" -#: ../../library/asyncio-task.rst:1358 +#: ../../library/asyncio-task.rst:1359 msgid "The ``msg`` parameter is propagated from cancelled task to its awaiter." msgstr "" -#: ../../library/asyncio-task.rst:1363 +#: ../../library/asyncio-task.rst:1364 msgid "" "The following example illustrates how coroutines can intercept the " "cancellation request::" msgstr "" -#: ../../library/asyncio-task.rst:1366 +#: ../../library/asyncio-task.rst:1367 msgid "" "async def cancel_me():\n" " print('cancel_me(): before sleep')\n" @@ -1858,41 +1852,41 @@ msgid "" "# main(): cancel_me is cancelled now" msgstr "" -#: ../../library/asyncio-task.rst:1402 +#: ../../library/asyncio-task.rst:1403 msgid "Return ``True`` if the Task is *cancelled*." msgstr "" -#: ../../library/asyncio-task.rst:1404 +#: ../../library/asyncio-task.rst:1405 msgid "" -"The Task is *cancelled* when the cancellation was requested " -"with :meth:`cancel` and the wrapped coroutine propagated " -"the :exc:`CancelledError` exception thrown into it." +"The Task is *cancelled* when the cancellation was requested with :meth:" +"`cancel` and the wrapped coroutine propagated the :exc:`CancelledError` " +"exception thrown into it." msgstr "" -#: ../../library/asyncio-task.rst:1410 +#: ../../library/asyncio-task.rst:1411 msgid "Decrement the count of cancellation requests to this Task." msgstr "" -#: ../../library/asyncio-task.rst:1412 +#: ../../library/asyncio-task.rst:1413 msgid "Returns the remaining number of cancellation requests." msgstr "" -#: ../../library/asyncio-task.rst:1414 +#: ../../library/asyncio-task.rst:1415 msgid "" -"Note that once execution of a cancelled task completed, further calls " -"to :meth:`uncancel` are ineffective." +"Note that once execution of a cancelled task completed, further calls to :" +"meth:`uncancel` are ineffective." msgstr "" -#: ../../library/asyncio-task.rst:1419 +#: ../../library/asyncio-task.rst:1420 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. In particular, if a Task gets successfully uncancelled, this " -"allows for elements of structured concurrency like :ref:`taskgroups` " -"and :func:`asyncio.timeout` to continue running, isolating cancellation to " -"the respective structured block. For example::" +"allows for elements of structured concurrency like :ref:`taskgroups` and :" +"func:`asyncio.timeout` to continue running, isolating cancellation to the " +"respective structured block. For example::" msgstr "" -#: ../../library/asyncio-task.rst:1426 +#: ../../library/asyncio-task.rst:1427 msgid "" "async def make_request_with_timeout():\n" " try:\n" @@ -1906,42 +1900,42 @@ msgid "" " await unrelated_code()" msgstr "" -#: ../../library/asyncio-task.rst:1437 +#: ../../library/asyncio-task.rst:1438 msgid "" "While the block with ``make_request()`` and ``make_another_request()`` might " "get cancelled due to the timeout, ``unrelated_code()`` should continue " -"running even in case of the timeout. This is implemented " -"with :meth:`uncancel`. :class:`TaskGroup` context managers " -"use :func:`uncancel` in a similar fashion." +"running even in case of the timeout. This is implemented with :meth:" +"`uncancel`. :class:`TaskGroup` context managers use :func:`uncancel` in a " +"similar fashion." msgstr "" -#: ../../library/asyncio-task.rst:1443 +#: ../../library/asyncio-task.rst:1444 msgid "" -"If end-user code is, for some reason, suppressing cancellation by " -"catching :exc:`CancelledError`, it needs to call this method to remove the " +"If end-user code is, for some reason, suppressing cancellation by catching :" +"exc:`CancelledError`, it needs to call this method to remove the " "cancellation state." msgstr "" -#: ../../library/asyncio-task.rst:1447 +#: ../../library/asyncio-task.rst:1448 msgid "" "When this method decrements the cancellation count to zero, the method " -"checks if a previous :meth:`cancel` call had arranged " -"for :exc:`CancelledError` to be thrown into the task. If it hasn't been " -"thrown yet, that arrangement will be rescinded (by resetting the internal " +"checks if a previous :meth:`cancel` call had arranged for :exc:" +"`CancelledError` to be thrown into the task. If it hasn't been thrown yet, " +"that arrangement will be rescinded (by resetting the internal " "``_must_cancel`` flag)." msgstr "" -#: ../../library/asyncio-task.rst:1453 +#: ../../library/asyncio-task.rst:1454 msgid "Changed to rescind pending cancellation requests upon reaching zero." msgstr "" -#: ../../library/asyncio-task.rst:1458 +#: ../../library/asyncio-task.rst:1459 msgid "" "Return the number of pending cancellation requests to this Task, i.e., the " "number of calls to :meth:`cancel` less the number of :meth:`uncancel` calls." msgstr "" -#: ../../library/asyncio-task.rst:1462 +#: ../../library/asyncio-task.rst:1463 msgid "" "Note that if this number is greater than zero but the Task is still " "executing, :meth:`cancelled` will still return ``False``. This is because " @@ -1950,7 +1944,7 @@ msgid "" "to zero." msgstr "" -#: ../../library/asyncio-task.rst:1468 +#: ../../library/asyncio-task.rst:1469 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. See :meth:`uncancel` for more details." diff --git a/library/asyncio.po b/library/asyncio.po index 1d0919783b..ffff473328 100644 --- a/library/asyncio.po +++ b/library/asyncio.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-11 00:13+0000\n" +"POT-Creation-Date: 2025-08-10 00:19+0000\n" "PO-Revision-Date: 2025-07-06 17:13+0800\n" "Last-Translator: Weilin Du\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,15 +21,15 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asyncio.rst:91 +#: ../../library/asyncio.rst:96 msgid "High-level APIs" msgstr "高階 API" -#: ../../library/asyncio.rst:103 +#: ../../library/asyncio.rst:108 msgid "Low-level APIs" msgstr "低階 API" -#: ../../library/asyncio.rst:114 +#: ../../library/asyncio.rst:119 msgid "Guides and Tutorials" msgstr "指南與教學" @@ -85,53 +85,61 @@ msgid "" msgstr "" "asyncio 往往是個建構 IO 密集型與高階層\\ **結構化**\\ 網路程式碼的完美選擇。" -#: ../../library/asyncio.rst:32 +#: ../../library/asyncio.rst:34 +msgid ":ref:`a-conceptual-overview-of-asyncio`" +msgstr "" + +#: ../../library/asyncio.rst:35 +msgid "Explanation of the fundamentals of asyncio." +msgstr "" + +#: ../../library/asyncio.rst:37 msgid "asyncio provides a set of **high-level** APIs to:" msgstr "asyncio 提供了一系列\\ **高階** API:" -#: ../../library/asyncio.rst:34 +#: ../../library/asyncio.rst:39 msgid "" ":ref:`run Python coroutines ` concurrently and have full control " "over their execution;" msgstr "" "並行地\\ :ref:`運行 Python 協程 (coroutine) ` 並擁有完整控制權;" -#: ../../library/asyncio.rst:37 +#: ../../library/asyncio.rst:42 msgid "perform :ref:`network IO and IPC `;" msgstr "執行\\ :ref:`網路 IO 與 IPC `;" -#: ../../library/asyncio.rst:39 +#: ../../library/asyncio.rst:44 msgid "control :ref:`subprocesses `;" msgstr "控制\\ :ref:`子行程 (subprocess) `;" -#: ../../library/asyncio.rst:41 +#: ../../library/asyncio.rst:46 msgid "distribute tasks via :ref:`queues `;" msgstr "透過\\ :ref:`佇列 (queue) ` 分配任務;" -#: ../../library/asyncio.rst:43 +#: ../../library/asyncio.rst:48 msgid ":ref:`synchronize ` concurrent code;" msgstr ":ref:`同步 `\\ 並行程式碼;" -#: ../../library/asyncio.rst:45 +#: ../../library/asyncio.rst:50 msgid "" "Additionally, there are **low-level** APIs for *library and framework " "developers* to:" msgstr "" "此外,還有一些給\\ *函式庫與框架 (framework) 開發者*\\ 的\\ **低階** API:" -#: ../../library/asyncio.rst:48 +#: ../../library/asyncio.rst:53 msgid "" "create and manage :ref:`event loops `, which provide " -"asynchronous APIs for :ref:`networking `, " -"running :ref:`subprocesses `, handling :ref:`OS " -"signals `, etc;" +"asynchronous APIs for :ref:`networking `, running :ref:" +"`subprocesses `, handling :ref:`OS signals " +"`, etc;" msgstr "" "建立與管理 :ref:`event loops(事件迴圈) `,它提供了能被" "用於\\ :ref:`網路 `、執行\\ :ref:`子行程 " "`、處理\\ :ref:`作業系統訊號 " "`\\ 等任務的非同步 API;" -#: ../../library/asyncio.rst:53 +#: ../../library/asyncio.rst:58 msgid "" "implement efficient protocols using :ref:`transports `;" @@ -139,7 +147,7 @@ msgstr "" "使用 :ref:`transports(asyncio 底層傳輸相關類別) `\\ 來實作高效能協定;" -#: ../../library/asyncio.rst:56 +#: ../../library/asyncio.rst:61 msgid "" ":ref:`bridge ` callback-based libraries and code with async/" "await syntax." @@ -159,18 +167,18 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/asyncio.rst:64 +#: ../../library/asyncio.rst:69 msgid "asyncio REPL" msgstr "asyncio REPL" -#: ../../library/asyncio.rst:65 +#: ../../library/asyncio.rst:70 msgid "" -"You can experiment with an ``asyncio`` concurrent context in " -"the :term:`REPL`:" +"You can experiment with an ``asyncio`` concurrent context in the :term:" +"`REPL`:" msgstr "" "你能在 :term:`REPL` 中對一個 ``asyncio`` 的並行情境 (context) 進行實驗:" -#: ../../library/asyncio.rst:67 +#: ../../library/asyncio.rst:72 msgid "" "$ python -m asyncio\n" "asyncio REPL ...\n" @@ -190,28 +198,28 @@ msgstr "" ">>> await asyncio.sleep(10, result='hello')\n" "'hello'" -#: ../../library/asyncio.rst:77 +#: ../../library/asyncio.rst:82 msgid "" "Raises an :ref:`auditing event ` ``cpython.run_stdin`` with no " "arguments." msgstr "產生一個 :ref:`稽核事件 ` ``cpython.run_stdin`` 且沒有引數。" -#: ../../library/asyncio.rst:79 +#: ../../library/asyncio.rst:84 msgid "(also 3.11.10, 3.10.15, 3.9.20, and 3.8.20) Emits audit events." msgstr "(也包括 3.11.10、3.10.15、3.9.20 及 3.8.20)發出稽核事件。" -#: ../../library/asyncio.rst:82 +#: ../../library/asyncio.rst:87 msgid "" "Uses PyREPL if possible, in which case :envvar:`PYTHONSTARTUP` is also " "executed. Emits audit events." msgstr "" -"可能的話使用 PyREPL,在這種情況下 :envvar:`PYTHONSTARTUP` 也會被執行。發出稽核" -"事件。" +"可能的話使用 PyREPL,在這種情況下 :envvar:`PYTHONSTARTUP` 也會被執行。發出稽" +"核事件。" -#: ../../library/asyncio.rst:90 +#: ../../library/asyncio.rst:95 msgid "Reference" msgstr "參閱" -#: ../../library/asyncio.rst:123 +#: ../../library/asyncio.rst:128 msgid "The source code for asyncio can be found in :source:`Lib/asyncio/`." msgstr "asyncio 的原始碼可以在 :source:`Lib/asyncio/` 中找到。" diff --git a/library/time.po b/library/time.po index f4ff4dcee8..d1f6d8d81b 100644 --- a/library/time.po +++ b/library/time.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-10 00:16+0000\n" +"POT-Creation-Date: 2025-08-10 00:19+0000\n" "PO-Revision-Date: 2024-11-20 15:25+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -532,8 +532,8 @@ msgid "" "only the difference between the results of two calls is valid." msgstr "" "回傳性能計數器的值(以帶有小數的秒數表示),即具有最高可用解析度來測量短時間" -"間隔的時鐘。它包括睡眠時經過的時間,且時鐘對於所有行程都會是相同。回傳值的參考點沒有定" -"義,因此只有兩次呼叫結果之間的差異才是有效的。" +"間隔的時鐘。它包括睡眠時經過的時間,且時鐘對於所有行程都會是相同。回傳值的參" +"考點沒有定義,因此只有兩次呼叫結果之間的差異才是有效的。" #: ../../library/time.rst:336 msgid "" @@ -1597,9 +1597,10 @@ msgid "High-resolution per-process timer from the CPU." msgstr "來自 CPU 的高解析度每個行程的計時器。" #: ../../library/time.rst:938 +#, fuzzy msgid "" "`International Atomic Time `_" +"division/how-utcnist-related-coordinated-universal-time-utc-international>`_" msgstr "" "`國際原子時間 `_" From 79d4b220193561b0c5b0c2abe1b43624e48d93aa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 12 Aug 2025 00:18:24 +0000 Subject: [PATCH 11/23] sync with cpython c1e1c880 --- c-api/hash.po | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/c-api/hash.po b/c-api/hash.po index dcb8889a1b..d3322bf338 100644 --- a/c-api/hash.po +++ b/c-api/hash.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-08-12 00:17+0000\n" "PO-Revision-Date: 2024-04-30 00:20+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -62,6 +62,10 @@ msgstr "用於複數虛數部分的乘數。" msgid "Hash function definition used by :c:func:`PyHash_GetFuncDef`." msgstr ":c:func:`PyHash_GetFuncDef` 所使用的雜湊函式定義。" +#: ../../c-api/hash.rst:56 +msgid "Hash function." +msgstr "" + #: ../../c-api/hash.rst:60 msgid "Hash function name (UTF-8 encoded string)." msgstr "雜湊函式名稱(UTF-8 編碼字串)。" From 85e3e176dcb075d30fedc5d5ad7acc2ddd847c80 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 13 Aug 2025 00:17:36 +0000 Subject: [PATCH 12/23] sync with cpython 30194914 --- howto/enum.po | 223 ++++++++++++------------- library/enum.po | 435 ++++++++++++++++++++++++++---------------------- 2 files changed, 343 insertions(+), 315 deletions(-) diff --git a/howto/enum.po b/howto/enum.po index 92490f02e6..31233ba902 100644 --- a/howto/enum.po +++ b/howto/enum.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-08-13 00:16+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -315,15 +315,15 @@ msgstr "" #: ../../howto/enum.rst:154 msgid "" ">>> chores_for_ethan = {\n" -"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | " -"Weekday.FRIDAY,\n" +"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | Weekday." +"FRIDAY,\n" "... 'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,\n" "... 'answer SO questions': Weekday.SATURDAY,\n" "... }" msgstr "" ">>> chores_for_ethan = {\n" -"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | " -"Weekday.FRIDAY,\n" +"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | Weekday." +"FRIDAY,\n" "... 'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,\n" "... 'answer SO questions': Weekday.SATURDAY,\n" "... }" @@ -386,8 +386,8 @@ msgstr "" #: ../../howto/enum.rst:191 msgid "" -"Sometimes it's useful to access members in enumerations programmatically " -"(i.e. situations where ``Color.RED`` won't do because the exact color is not " +"Sometimes it's useful to access members in enumerations programmatically (i." +"e. situations where ``Color.RED`` won't do because the exact color is not " "known at program-writing time). ``Enum`` allows such access::" msgstr "" @@ -627,16 +627,16 @@ msgid "" ">>> list(Shape)\n" "[, , ]\n" ">>> list(Weekday)\n" -"[, , , " -", , , " -"]" +"[, , , , , , ]" msgstr "" ">>> list(Shape)\n" "[, , ]\n" ">>> list(Weekday)\n" -"[, , , " -", , , " -"]" +"[, , , , , , ]" #: ../../howto/enum.rst:319 msgid "" @@ -839,25 +839,24 @@ msgid "" "The rules for what is allowed are as follows: names that start and end with " "a single underscore are reserved by enum and cannot be used; all other " "attributes defined within an enumeration will become members of this " -"enumeration, with the exception of special methods " -"(:meth:`~object.__str__`, :meth:`~object.__add__`, etc.), descriptors " -"(methods are also descriptors), and variable names listed " -"in :attr:`~Enum._ignore_`." +"enumeration, with the exception of special methods (:meth:`~object." +"__str__`, :meth:`~object.__add__`, etc.), descriptors (methods are also " +"descriptors), and variable names listed in :attr:`~Enum._ignore_`." msgstr "" #: ../../howto/enum.rst:432 msgid "" -"Note: if your enumeration defines :meth:`~object.__new__` and/" -"or :meth:`~object.__init__`, any value(s) given to the enum member will be " -"passed into those methods. See `Planet`_ for an example." +"Note: if your enumeration defines :meth:`~object.__new__` and/or :meth:" +"`~object.__init__`, any value(s) given to the enum member will be passed " +"into those methods. See `Planet`_ for an example." msgstr "" #: ../../howto/enum.rst:438 msgid "" "The :meth:`~object.__new__` method, if defined, is used during creation of " "the Enum members; it is then replaced by Enum's :meth:`~object.__new__` " -"which is used after class creation for lookup of existing members. " -"See :ref:`new-vs-init` for more details." +"which is used after class creation for lookup of existing members. See :ref:" +"`new-vs-init` for more details." msgstr "" #: ../../howto/enum.rst:445 @@ -939,8 +938,8 @@ msgstr "" #: ../../howto/enum.rst:486 msgid "" -"When inheriting from a :class:`~dataclasses.dataclass`, " -"the :meth:`~Enum.__repr__` omits the inherited class' name. For example::" +"When inheriting from a :class:`~dataclasses.dataclass`, the :meth:`~Enum." +"__repr__` omits the inherited class' name. For example::" msgstr "" #: ../../howto/enum.rst:489 @@ -1041,10 +1040,9 @@ msgstr "" #: ../../howto/enum.rst:547 msgid "" -"It is possible to modify how enum members are pickled/unpickled by " -"defining :meth:`~object.__reduce_ex__` in the enumeration class. The " -"default method is by-value, but enums with complicated values may want to " -"use by-name::" +"It is possible to modify how enum members are pickled/unpickled by defining :" +"meth:`~object.__reduce_ex__` in the enumeration class. The default method " +"is by-value, but enums with complicated values may want to use by-name::" msgstr "" #: ../../howto/enum.rst:551 @@ -1153,10 +1151,10 @@ msgstr "" #: ../../howto/enum.rst:611 msgid "" -"The new pickle protocol 4 also, in some circumstances, relies " -"on :attr:`~type.__qualname__` being set to the location where pickle will be " -"able to find the class. For example, if the class was made available in " -"class SomeData in the global scope::" +"The new pickle protocol 4 also, in some circumstances, relies on :attr:" +"`~type.__qualname__` being set to the location where pickle will be able to " +"find the class. For example, if the class was made available in class " +"SomeData in the global scope::" msgstr "" #: ../../howto/enum.rst:616 @@ -1259,10 +1257,10 @@ msgstr "IntEnum" #: ../../howto/enum.rst:667 msgid "" -"The first variation of :class:`Enum` that is provided is also a subclass " -"of :class:`int`. Members of an :class:`IntEnum` can be compared to " -"integers; by extension, integer enumerations of different types can also be " -"compared to each other::" +"The first variation of :class:`Enum` that is provided is also a subclass of :" +"class:`int`. Members of an :class:`IntEnum` can be compared to integers; by " +"extension, integer enumerations of different types can also be compared to " +"each other::" msgstr "" #: ../../howto/enum.rst:672 @@ -1371,9 +1369,9 @@ msgid "" "The next variation of :class:`Enum` provided, :class:`IntFlag`, is also " "based on :class:`int`. The difference being :class:`IntFlag` members can be " "combined using the bitwise operators (&, \\|, ^, ~) and the result is still " -"an :class:`IntFlag` member, if possible. " -"Like :class:`IntEnum`, :class:`IntFlag` members are also integers and can be " -"used wherever an :class:`int` is used." +"an :class:`IntFlag` member, if possible. Like :class:`IntEnum`, :class:" +"`IntFlag` members are also integers and can be used wherever an :class:`int` " +"is used." msgstr "" #: ../../howto/enum.rst:733 @@ -1463,8 +1461,8 @@ msgstr "" #: ../../howto/enum.rst:781 msgid "" "Another important difference between :class:`IntFlag` and :class:`Enum` is " -"that if no flags are set (the value is 0), its boolean evaluation " -"is :data:`False`::" +"that if no flags are set (the value is 0), its boolean evaluation is :data:" +"`False`::" msgstr "" #: ../../howto/enum.rst:784 @@ -1532,10 +1530,10 @@ msgstr "Flag" #: ../../howto/enum.rst:817 msgid "" "The last variation is :class:`Flag`. Like :class:`IntFlag`, :class:`Flag` " -"members can be combined using the bitwise operators (&, \\|, ^, ~). " -"Unlike :class:`IntFlag`, they cannot be combined with, nor compared against, " -"any other :class:`Flag` enumeration, nor :class:`int`. While it is possible " -"to specify the values directly it is recommended to use :class:`auto` as the " +"members can be combined using the bitwise operators (&, \\|, ^, ~). Unlike :" +"class:`IntFlag`, they cannot be combined with, nor compared against, any " +"other :class:`Flag` enumeration, nor :class:`int`. While it is possible to " +"specify the values directly it is recommended to use :class:`auto` as the " "value and let :class:`Flag` select an appropriate value." msgstr "" @@ -1644,10 +1642,10 @@ msgid "" "For the majority of new code, :class:`Enum` and :class:`Flag` are strongly " "recommended, since :class:`IntEnum` and :class:`IntFlag` break some semantic " "promises of an enumeration (by being comparable to integers, and thus by " -"transitivity to other unrelated enumerations). :class:`IntEnum` " -"and :class:`IntFlag` should be used only in cases where :class:`Enum` " -"and :class:`Flag` will not do; for example, when integer constants are " -"replaced with enumerations, or for interoperability with other systems." +"transitivity to other unrelated enumerations). :class:`IntEnum` and :class:" +"`IntFlag` should be used only in cases where :class:`Enum` and :class:`Flag` " +"will not do; for example, when integer constants are replaced with " +"enumerations, or for interoperability with other systems." msgstr "" #: ../../howto/enum.rst:886 @@ -1671,8 +1669,8 @@ msgstr "" #: ../../howto/enum.rst:894 msgid "" "This demonstrates how similar derived enumerations can be defined; for " -"example a :class:`!FloatEnum` that mixes in :class:`float` instead " -"of :class:`int`." +"example a :class:`!FloatEnum` that mixes in :class:`float` instead of :class:" +"`int`." msgstr "" #: ../../howto/enum.rst:897 @@ -1681,24 +1679,24 @@ msgstr "一些規則:" #: ../../howto/enum.rst:899 msgid "" -"When subclassing :class:`Enum`, mix-in types must appear before " -"the :class:`Enum` class itself in the sequence of bases, as in " -"the :class:`IntEnum` example above." +"When subclassing :class:`Enum`, mix-in types must appear before the :class:" +"`Enum` class itself in the sequence of bases, as in the :class:`IntEnum` " +"example above." msgstr "" #: ../../howto/enum.rst:902 msgid "" -"Mix-in types must be subclassable. For example, :class:`bool` " -"and :class:`range` are not subclassable and will throw an error during Enum " -"creation if used as the mix-in type." +"Mix-in types must be subclassable. For example, :class:`bool` and :class:" +"`range` are not subclassable and will throw an error during Enum creation if " +"used as the mix-in type." msgstr "" #: ../../howto/enum.rst:905 msgid "" "While :class:`Enum` can have members of any type, once you mix in an " -"additional type, all the members must have values of that type, " -"e.g. :class:`int` above. This restriction does not apply to mix-ins which " -"only add methods and don't specify another type." +"additional type, all the members must have values of that type, e.g. :class:" +"`int` above. This restriction does not apply to mix-ins which only add " +"methods and don't specify another type." msgstr "" #: ../../howto/enum.rst:909 @@ -1710,30 +1708,30 @@ msgstr "" #: ../../howto/enum.rst:912 msgid "" -"A ``data type`` is a mixin that defines :meth:`~object.__new__`, or " -"a :class:`~dataclasses.dataclass`" +"A ``data type`` is a mixin that defines :meth:`~object.__new__`, or a :class:" +"`~dataclasses.dataclass`" msgstr "" #: ../../howto/enum.rst:914 msgid "" -"%-style formatting: ``%s`` and ``%r`` call the :class:`Enum` " -"class's :meth:`~object.__str__` and :meth:`~object.__repr__` respectively; " -"other codes (such as ``%i`` or ``%h`` for IntEnum) treat the enum member as " -"its mixed-in type." +"%-style formatting: ``%s`` and ``%r`` call the :class:`Enum` class's :meth:" +"`~object.__str__` and :meth:`~object.__repr__` respectively; other codes " +"(such as ``%i`` or ``%h`` for IntEnum) treat the enum member as its mixed-in " +"type." msgstr "" #: ../../howto/enum.rst:917 msgid "" -":ref:`Formatted string literals `, :meth:`str.format`, " -"and :func:`format` will use the enum's :meth:`~object.__str__` method." +":ref:`Formatted string literals `, :meth:`str.format`, and :func:" +"`format` will use the enum's :meth:`~object.__str__` method." msgstr "" #: ../../howto/enum.rst:922 msgid "" "Because :class:`IntEnum`, :class:`IntFlag`, and :class:`StrEnum` are " -"designed to be drop-in replacements for existing constants, " -"their :meth:`~object.__str__` method has been reset to their data " -"types' :meth:`~object.__str__` method." +"designed to be drop-in replacements for existing constants, their :meth:" +"`~object.__str__` method has been reset to their data types' :meth:`~object." +"__str__` method." msgstr "" #: ../../howto/enum.rst:930 @@ -1744,8 +1742,8 @@ msgstr "" msgid "" ":meth:`~object.__new__` must be used whenever you want to customize the " "actual value of the :class:`Enum` member. Any other modifications may go in " -"either :meth:`~object.__new__` or :meth:`~object.__init__`, " -"with :meth:`~object.__init__` being preferred." +"either :meth:`~object.__new__` or :meth:`~object.__init__`, with :meth:" +"`~object.__init__` being preferred." msgstr "" #: ../../howto/enum.rst:936 @@ -1802,9 +1800,9 @@ msgstr "" #: ../../howto/enum.rst:976 msgid "" ":meth:`~object.__new__`, if specified, must create and return the enum " -"members; it is also a very good idea to set the " -"member's :attr:`~Enum._value_` appropriately. Once all the members are " -"created it is no longer used." +"members; it is also a very good idea to set the member's :attr:`~Enum." +"_value_` appropriately. Once all the members are created it is no longer " +"used." msgstr "" #: ../../howto/enum.rst:982 @@ -1827,9 +1825,9 @@ msgstr "" #: ../../howto/enum.rst:988 msgid "" -":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or " -"a :class:`str`, that will not be transformed into members, and will be " -"removed from the final class" +":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a :" +"class:`str`, that will not be transformed into members, and will be removed " +"from the final class" msgstr "" #: ../../howto/enum.rst:991 @@ -1840,13 +1838,13 @@ msgstr "" #: ../../howto/enum.rst:993 msgid "" -":meth:`~EnumType._add_alias_` -- adds a new name as an alias to an existing " +":meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing " "member." msgstr "" #: ../../howto/enum.rst:995 msgid "" -":meth:`~EnumType._add_value_alias_` -- adds a new value as an alias to an " +":meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an " "existing member. See `MultiValueEnum`_ for an example." msgstr "" @@ -1973,11 +1971,11 @@ msgstr "" #: ../../howto/enum.rst:1074 msgid "" -"Enum classes that are mixed with non-:class:`Enum` types (such " -"as :class:`int`, :class:`str`, etc.) are evaluated according to the mixed-in " -"type's rules; otherwise, all members evaluate as :data:`True`. To make your " -"own enum's boolean evaluation depend on the member's value add the following " -"to your class::" +"Enum classes that are mixed with non-:class:`Enum` types (such as :class:" +"`int`, :class:`str`, etc.) are evaluated according to the mixed-in type's " +"rules; otherwise, all members evaluate as :data:`True`. To make your own " +"enum's boolean evaluation depend on the member's value add the following to " +"your class::" msgstr "" #: ../../howto/enum.rst:1080 @@ -2230,8 +2228,8 @@ msgstr "" #: ../../howto/enum.rst:1202 msgid "" "The default for Flag is ``STRICT``, the default for ``IntFlag`` is " -"``EJECT``, and the default for ``_convert_`` is ``KEEP`` (see " -"``ssl.Options`` for an example of when ``KEEP`` is needed)." +"``EJECT``, and the default for ``_convert_`` is ``KEEP`` (see ``ssl." +"Options`` for an example of when ``KEEP`` is needed)." msgstr "" #: ../../howto/enum.rst:1210 @@ -2240,8 +2238,8 @@ msgstr "Enums 和 Flags 有何不同?" #: ../../howto/enum.rst:1212 msgid "" -"Enums have a custom metaclass that affects many aspects of both " -"derived :class:`Enum` classes and their instances (members)." +"Enums have a custom metaclass that affects many aspects of both derived :" +"class:`Enum` classes and their instances (members)." msgstr "" #: ../../howto/enum.rst:1217 @@ -2250,14 +2248,14 @@ msgstr "Enum 類別" #: ../../howto/enum.rst:1219 msgid "" -"The :class:`EnumType` metaclass is responsible for providing " -"the :meth:`~object.__contains__`, :meth:`~object.__dir__`, :meth:`~object.__iter__` " +"The :class:`EnumType` metaclass is responsible for providing the :meth:" +"`~object.__contains__`, :meth:`~object.__dir__`, :meth:`~object.__iter__` " "and other methods that allow one to do things with an :class:`Enum` class " "that fail on a typical class, such as ``list(Color)`` or ``some_enum_var in " "Color``. :class:`EnumType` is responsible for ensuring that various other " -"methods on the final :class:`Enum` class are correct (such " -"as :meth:`~object.__new__`, :meth:`~object.__getnewargs__`, :meth:`~object.__str__` " -"and :meth:`~object.__repr__`)." +"methods on the final :class:`Enum` class are correct (such as :meth:`~object." +"__new__`, :meth:`~object.__getnewargs__`, :meth:`~object.__str__` and :meth:" +"`~object.__repr__`)." msgstr "" #: ../../howto/enum.rst:1228 @@ -2268,8 +2266,8 @@ msgstr "Flag 類別" msgid "" "Flags have an expanded view of aliasing: to be canonical, the value of a " "flag needs to be a power-of-two value, and not a duplicate name. So, in " -"addition to the :class:`Enum` definition of alias, a flag with no value " -"(a.k.a. ``0``) or with more than one power-of-two value (e.g. ``3``) is " +"addition to the :class:`Enum` definition of alias, a flag with no value (a.k." +"a. ``0``) or with more than one power-of-two value (e.g. ``3``) is " "considered an alias." msgstr "" @@ -2279,11 +2277,11 @@ msgstr "" #: ../../howto/enum.rst:1238 msgid "" -"The most interesting thing about enum members is that they are " -"singletons. :class:`EnumType` creates them all while it is creating the enum " -"class itself, and then puts a custom :meth:`~object.__new__` in place to " -"ensure that no new ones are ever instantiated by returning only the existing " -"member instances." +"The most interesting thing about enum members is that they are singletons. :" +"class:`EnumType` creates them all while it is creating the enum class " +"itself, and then puts a custom :meth:`~object.__new__` in place to ensure " +"that no new ones are ever instantiated by returning only the existing member " +"instances." msgstr "" #: ../../howto/enum.rst:1244 @@ -2342,11 +2340,10 @@ msgstr "" #: ../../howto/enum.rst:1273 msgid "" -"While :class:`Enum`, :class:`IntEnum`, :class:`StrEnum`, :class:`Flag`, " -"and :class:`IntFlag` are expected to cover the majority of use-cases, they " -"cannot cover them all. Here are recipes for some different types of " -"enumerations that can be used directly, or as examples for creating one's " -"own." +"While :class:`Enum`, :class:`IntEnum`, :class:`StrEnum`, :class:`Flag`, and :" +"class:`IntFlag` are expected to cover the majority of use-cases, they cannot " +"cover them all. Here are recipes for some different types of enumerations " +"that can be used directly, or as examples for creating one's own." msgstr "" #: ../../howto/enum.rst:1280 @@ -2438,8 +2435,8 @@ msgstr "" #: ../../howto/enum.rst:1323 msgid "" -"This is also a good example of why you might want to write your " -"own :meth:`~object.__repr__`::" +"This is also a good example of why you might want to write your own :meth:" +"`~object.__repr__`::" msgstr "" #: ../../howto/enum.rst:1326 @@ -2780,11 +2777,11 @@ msgid "" "... Period['day_%d' % i] = i\n" "...\n" ">>> list(Period)[:2]\n" -"[, ]\n" +"[, ]\n" ">>> list(Period)[-2:]\n" -"[, ]" +"[, ]" msgstr "" #: ../../howto/enum.rst:1558 diff --git a/library/enum.po b/library/enum.po index d6d9120849..acd468baa1 100644 --- a/library/enum.po +++ b/library/enum.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-23 00:17+0000\n" +"POT-Creation-Date: 2025-08-13 00:16+0000\n" "PO-Revision-Date: 2024-12-21 13:50+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -367,10 +367,16 @@ msgstr "" "員、正確處理重複、提供列舉類別的疊代等等。" #: ../../library/enum.rst:180 +msgid "" +"Before 3.11 ``EnumType`` was called ``EnumMeta``, which is still available " +"as an alias." +msgstr "在 3.11 之前,``EnumType`` 稱作 ``EnumMeta``,其目前仍可作為別名使用。" + +#: ../../library/enum.rst:184 msgid "This method is called in two different ways:" msgstr "這個方法可以用兩種不同的方式呼叫:" -#: ../../library/enum.rst:182 +#: ../../library/enum.rst:186 msgid "to look up an existing member:" msgstr "查詢已存在的成員:" @@ -378,7 +384,7 @@ msgstr "查詢已存在的成員:" msgid "cls" msgstr "cls" -#: ../../library/enum.rst:184 ../../library/enum.rst:190 +#: ../../library/enum.rst:188 ../../library/enum.rst:194 msgid "The enum class being called." msgstr "所呼叫的列舉類別。" @@ -386,17 +392,17 @@ msgstr "所呼叫的列舉類別。" msgid "value" msgstr "value" -#: ../../library/enum.rst:185 +#: ../../library/enum.rst:189 msgid "The value to lookup." msgstr "要查詢的值。" -#: ../../library/enum.rst:187 +#: ../../library/enum.rst:191 msgid "" "to use the ``cls`` enum to create a new enum (only if the existing enum does " "not have any members):" msgstr "使用 ``cls`` 列舉來建立新列舉(只有在現有列舉沒有任何成員時)" -#: ../../library/enum.rst:191 +#: ../../library/enum.rst:195 msgid "The name of the new Enum to create." msgstr "要建立的新列舉的名稱。" @@ -404,7 +410,7 @@ msgstr "要建立的新列舉的名稱。" msgid "names" msgstr "names" -#: ../../library/enum.rst:192 +#: ../../library/enum.rst:196 msgid "The names/values of the members for the new Enum." msgstr "新列舉的成員的名稱/值。" @@ -412,7 +418,7 @@ msgstr "新列舉的成員的名稱/值。" msgid "module" msgstr "module" -#: ../../library/enum.rst:193 +#: ../../library/enum.rst:197 msgid "The name of the module the new Enum is created in." msgstr "新列舉要建立在哪個模組名稱下。" @@ -420,7 +426,7 @@ msgstr "新列舉要建立在哪個模組名稱下。" msgid "qualname" msgstr "qualname" -#: ../../library/enum.rst:194 +#: ../../library/enum.rst:198 msgid "The actual location in the module where this Enum can be found." msgstr "這個列舉在模組裡實際上的位置。" @@ -428,7 +434,7 @@ msgstr "這個列舉在模組裡實際上的位置。" msgid "type" msgstr "type" -#: ../../library/enum.rst:195 +#: ../../library/enum.rst:199 msgid "A mix-in type for the new Enum." msgstr "新列舉的混合型別。" @@ -436,7 +442,7 @@ msgstr "新列舉的混合型別。" msgid "start" msgstr "start" -#: ../../library/enum.rst:196 +#: ../../library/enum.rst:200 msgid "The first integer value for the Enum (used by :class:`auto`)." msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" @@ -444,16 +450,16 @@ msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" msgid "boundary" msgstr "boundary" -#: ../../library/enum.rst:197 +#: ../../library/enum.rst:201 msgid "" "How to handle out-of-range values from bit operations (:class:`Flag` only)." msgstr "在位元操作時怎麼處理範圍外的值(只有 :class:`Flag` 會用到)" -#: ../../library/enum.rst:201 +#: ../../library/enum.rst:205 msgid "Returns ``True`` if member belongs to the ``cls``::" msgstr "如果 member 屬於 ``cls`` 則回傳 ``True``: ::" -#: ../../library/enum.rst:203 +#: ../../library/enum.rst:207 msgid "" ">>> some_var = Color.RED\n" ">>> some_var in Color\n" @@ -467,7 +473,7 @@ msgstr "" ">>> Color.RED.value in Color\n" "True" -#: ../../library/enum.rst:211 +#: ../../library/enum.rst:215 msgid "" "Before Python 3.12, a ``TypeError`` is raised if a non-Enum-member is used " "in a containment check." @@ -475,7 +481,7 @@ msgstr "" "在 Python 3.12 之前,如果用非列舉成員做屬於檢查 (containment check) 會引發 " "``TypeError``。" -#: ../../library/enum.rst:216 +#: ../../library/enum.rst:220 msgid "" "Returns ``['__class__', '__doc__', '__members__', '__module__']`` and the " "names of the members in *cls*::" @@ -483,7 +489,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__members__', '__module__']`` 及 *cls* 的成" "員名稱: ::" -#: ../../library/enum.rst:219 +#: ../../library/enum.rst:223 msgid "" ">>> dir(Color)\n" "['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', " @@ -495,13 +501,13 @@ msgstr "" "'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', " "'__module__', '__name__', '__qualname__']" -#: ../../library/enum.rst:224 +#: ../../library/enum.rst:228 msgid "" "Returns the Enum member in *cls* matching *name*, or raises a :exc:" "`KeyError`::" msgstr "回傳 *cls* 中符合 *name* 的列舉成員,或引發 :exc:`KeyError`: ::" -#: ../../library/enum.rst:226 +#: ../../library/enum.rst:230 msgid "" ">>> Color['BLUE']\n" "" @@ -509,11 +515,11 @@ msgstr "" ">>> Color['BLUE']\n" "" -#: ../../library/enum.rst:231 +#: ../../library/enum.rst:235 msgid "Returns each member in *cls* in definition order::" msgstr "以定義的順序回傳在 *cls* 中的每個成員: ::" -#: ../../library/enum.rst:233 +#: ../../library/enum.rst:237 msgid "" ">>> list(Color)\n" "[, , ]" @@ -521,11 +527,11 @@ msgstr "" ">>> list(Color)\n" "[, , ]" -#: ../../library/enum.rst:238 +#: ../../library/enum.rst:242 msgid "Returns the number of member in *cls*::" msgstr "回傳 *cls* 的成員數量: ::" -#: ../../library/enum.rst:240 +#: ../../library/enum.rst:244 msgid "" ">>> len(Color)\n" "3" @@ -533,15 +539,15 @@ msgstr "" ">>> len(Color)\n" "3" -#: ../../library/enum.rst:245 +#: ../../library/enum.rst:249 msgid "Returns a mapping of every enum name to its member, including aliases" msgstr "回傳每個列舉名稱到其成員的對映,包括別名" -#: ../../library/enum.rst:249 +#: ../../library/enum.rst:253 msgid "Returns each member in *cls* in reverse definition order::" msgstr "以跟定義相反的順序回傳 *cls* 的每個成員: ::" -#: ../../library/enum.rst:251 +#: ../../library/enum.rst:255 msgid "" ">>> list(reversed(Color))\n" "[, , ]" @@ -549,37 +555,15 @@ msgstr "" ">>> list(reversed(Color))\n" "[, , ]" -#: ../../library/enum.rst:256 -msgid "" -"Adds a new name as an alias to an existing member. Raises a :exc:" -"`NameError` if the name is already assigned to a different member." -msgstr "" -"新增一個名稱作為現有成員的別名。如果該名稱已被指派給不同的成員,則會引發 :" -"exc:`NameError`。" - #: ../../library/enum.rst:261 -msgid "" -"Adds a new value as an alias to an existing member. Raises a :exc:" -"`ValueError` if the value is already linked with a different member." -msgstr "" -"新增一個值作為現有成員的別名。如果該值已與不同成員連結,則會引發 :exc:" -"`ValueError`。" - -#: ../../library/enum.rst:266 -msgid "" -"Before 3.11 ``EnumType`` was called ``EnumMeta``, which is still available " -"as an alias." -msgstr "在 3.11 之前,``EnumType`` 稱作 ``EnumMeta``,其目前仍可作為別名使用。" - -#: ../../library/enum.rst:271 msgid "*Enum* is the base class for all *enum* enumerations." msgstr "*Enum* 是所有 *enum* 列舉的基礎類別。" -#: ../../library/enum.rst:275 +#: ../../library/enum.rst:265 msgid "The name used to define the ``Enum`` member::" msgstr "用來定義 ``Enum`` 成員的名稱: ::" -#: ../../library/enum.rst:277 +#: ../../library/enum.rst:267 msgid "" ">>> Color.BLUE.name\n" "'BLUE'" @@ -587,11 +571,11 @@ msgstr "" ">>> Color.BLUE.name\n" "'BLUE'" -#: ../../library/enum.rst:282 +#: ../../library/enum.rst:272 msgid "The value given to the ``Enum`` member::" msgstr "``Enum`` 成員給定的值: ::" -#: ../../library/enum.rst:284 +#: ../../library/enum.rst:274 msgid "" ">>> Color.RED.value\n" "1" @@ -599,15 +583,15 @@ msgstr "" ">>> Color.RED.value\n" "1" -#: ../../library/enum.rst:287 ../../library/enum.rst:307 +#: ../../library/enum.rst:277 ../../library/enum.rst:297 msgid "Value of the member, can be set in :meth:`~Enum.__new__`." msgstr "成員的值,可以在 :meth:`~Enum.__new__` 設定。" -#: ../../library/enum.rst:289 +#: ../../library/enum.rst:279 msgid "Enum member values" msgstr "列舉成員的值" -#: ../../library/enum.rst:291 +#: ../../library/enum.rst:281 msgid "" "Member values can be anything: :class:`int`, :class:`str`, etc. If the " "exact value is unimportant you may use :class:`auto` instances and an " @@ -617,7 +601,7 @@ msgstr "" "重要,你可以使用 :class:`auto` 實例,它會為你選擇合適的值。更多細節請參考 :" "class:`auto`。" -#: ../../library/enum.rst:296 +#: ../../library/enum.rst:286 msgid "" "While mutable/unhashable values, such as :class:`dict`, :class:`list` or a " "mutable :class:`~dataclasses.dataclass`, can be used, they will have a " @@ -628,23 +612,23 @@ msgstr "" "`dict`、:class:`list` 或可變的 :class:`~dataclasses.dataclass`,它們在建立期" "間會對效能產生相對於列舉中可變的 / 不可雜湊的值總數量的二次方影響。" -#: ../../library/enum.rst:303 +#: ../../library/enum.rst:293 msgid "Name of the member." msgstr "成員名稱。" -#: ../../library/enum.rst:311 +#: ../../library/enum.rst:301 msgid "" "No longer used, kept for backward compatibility. (class attribute, removed " "during class creation)." msgstr "已不再使用,只為了向後相容而保留(類別屬性,在類別建立時移除)" -#: ../../library/enum.rst:316 +#: ../../library/enum.rst:306 msgid "" "``_ignore_`` is only used during creation and is removed from the " "enumeration once creation is complete." msgstr "``_ignore_`` 只有在建立的時候用到,在列舉建立完成後會被移除。" -#: ../../library/enum.rst:319 +#: ../../library/enum.rst:309 msgid "" "``_ignore_`` is a list of names that will not become members, and whose " "names will also be removed from the completed enumeration. See :ref:" @@ -653,7 +637,7 @@ msgstr "" "``_ignore_`` 是一個不會變成成員的名稱串列,在列舉建立完成後其名稱會被移除。範" "例請參考 :ref:`TimePeriod `。" -#: ../../library/enum.rst:325 +#: ../../library/enum.rst:315 msgid "" "Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and any " "public methods defined on *self.__class__*::" @@ -661,7 +645,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__module__', 'name', 'value']`` 及任何 " "*self.__class__* 上定義的公開方法: ::" -#: ../../library/enum.rst:328 +#: ../../library/enum.rst:318 msgid "" ">>> from datetime import date\n" ">>> class Weekday(Enum):\n" @@ -701,11 +685,11 @@ msgstr "" msgid "name" msgstr "name" -#: ../../library/enum.rst:346 +#: ../../library/enum.rst:336 msgid "The name of the member being defined (e.g. 'RED')." msgstr "定義的成員名稱(例如 'RED')。" -#: ../../library/enum.rst:347 +#: ../../library/enum.rst:337 msgid "The start value for the Enum; the default is 1." msgstr "列舉的開始值,預設為 1。" @@ -713,7 +697,7 @@ msgstr "列舉的開始值,預設為 1。" msgid "count" msgstr "count" -#: ../../library/enum.rst:348 +#: ../../library/enum.rst:338 msgid "The number of members currently defined, not including this one." msgstr "已定義的成員數量,不包含目前這一個。" @@ -721,17 +705,17 @@ msgstr "已定義的成員數量,不包含目前這一個。" msgid "last_values" msgstr "last_values" -#: ../../library/enum.rst:349 +#: ../../library/enum.rst:339 msgid "A list of the previous values." msgstr "一個之前值的串列。" -#: ../../library/enum.rst:351 +#: ../../library/enum.rst:341 msgid "" "A *staticmethod* that is used to determine the next value returned by :class:" "`auto`::" msgstr "一個 *staticmethod*,用來決定 :class:`auto` 下一個要回傳的值的: ::" -#: ../../library/enum.rst:354 +#: ../../library/enum.rst:344 msgid "" ">>> from enum import auto\n" ">>> class PowersOfThree(Enum):\n" @@ -755,7 +739,7 @@ msgstr "" ">>> PowersOfThree.SECOND.value\n" "9" -#: ../../library/enum.rst:367 +#: ../../library/enum.rst:357 msgid "" "By default, does nothing. If multiple values are given in the member " "assignment, those values become separate arguments to ``__init__``; e.g." @@ -763,19 +747,19 @@ msgstr "" "預設情況下,不執行任何操作。如果在成員賦值中給出多個值,這些值將成為與 " "``__init__`` 分別的引數;例如" -#: ../../library/enum.rst:374 +#: ../../library/enum.rst:364 msgid "" "``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, " "'Mon')``" msgstr "``Weekday.__init__()`` 將被稱為 ``Weekday.__init__(self, 1, 'Mon')``" -#: ../../library/enum.rst:378 +#: ../../library/enum.rst:368 msgid "" "A *classmethod* that is used to further configure subsequent subclasses. By " "default, does nothing." msgstr "一個 *classmethod*,用來進一步設定後續的子類別,預設不做任何事。" -#: ../../library/enum.rst:383 +#: ../../library/enum.rst:373 msgid "" "A *classmethod* for looking up values not found in *cls*. By default it " "does nothing, but can be overridden to implement custom search behavior::" @@ -783,7 +767,7 @@ msgstr "" "一個 *classmethod*,用來查詢在 *cls* 裡找不到的值。預設不做任何事,但可以被覆" "寫以實作客製化的搜尋行為: ::" -#: ../../library/enum.rst:386 +#: ../../library/enum.rst:376 msgid "" ">>> from enum import StrEnum\n" ">>> class Build(StrEnum):\n" @@ -819,7 +803,7 @@ msgstr "" ">>> Build('deBUG')\n" "" -#: ../../library/enum.rst:405 +#: ../../library/enum.rst:395 msgid "" "By default, doesn't exist. If specified, either in the enum class " "definition or in a mixin class (such as ``int``), all values given in the " @@ -828,12 +812,12 @@ msgstr "" "預設情況下不存在。如果有指定,無論是在列舉類別定義中還是在 mixin 類別中(例" "如 ``int``\\ ),都將傳遞成員賦值中給出的所有值;例如" -#: ../../library/enum.rst:413 +#: ../../library/enum.rst:403 msgid "" "results in the call ``int('1a', 16)`` and a value of ``26`` for the member." msgstr "會產生呼叫 ``int('1a', 16)`` 而該成員的值為 ``26``。" -#: ../../library/enum.rst:417 +#: ../../library/enum.rst:407 msgid "" "When writing a custom ``__new__``, do not use ``super().__new__`` -- call " "the appropriate ``__new__`` instead." @@ -841,7 +825,7 @@ msgstr "" "當寫自訂的 ``__new__`` 時,不要使用 ``super().__new__``,而是要呼叫適當的 " "``__new__``。" -#: ../../library/enum.rst:422 +#: ../../library/enum.rst:412 msgid "" "Returns the string used for *repr()* calls. By default, returns the *Enum* " "name, member name, and value, but can be overridden::" @@ -849,7 +833,7 @@ msgstr "" "回傳呼叫 *repr()* 時使用的字串。預設回傳 *Enum* 名稱、成員名稱及值,但可以被" "覆寫: ::" -#: ../../library/enum.rst:425 +#: ../../library/enum.rst:415 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -875,7 +859,7 @@ msgstr "" "ALTERNATE}\"\n" "(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" -#: ../../library/enum.rst:438 +#: ../../library/enum.rst:428 msgid "" "Returns the string used for *str()* calls. By default, returns the *Enum* " "name and member name, but can be overridden::" @@ -883,7 +867,7 @@ msgstr "" "回傳呼叫 *str()* 時使用的字串。預設回傳 *Enum* 名稱及成員名稱,但可以被覆" "寫: ::" -#: ../../library/enum.rst:441 +#: ../../library/enum.rst:431 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -907,7 +891,7 @@ msgstr "" "ALTERNATE}\"\n" "(, 'ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:453 +#: ../../library/enum.rst:443 msgid "" "Returns the string used for *format()* and *f-string* calls. By default, " "returns :meth:`__str__` return value, but can be overridden::" @@ -915,7 +899,7 @@ msgstr "" "回傳呼叫 *format()* 及 *f-string* 時使用的字串。預設回傳 :meth:`__str__` 的回" "傳值,但可以被覆寫: ::" -#: ../../library/enum.rst:456 +#: ../../library/enum.rst:446 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -939,17 +923,62 @@ msgstr "" "ALTERNATE}\"\n" "(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:468 +#: ../../library/enum.rst:458 msgid "" "Using :class:`auto` with :class:`Enum` results in integers of increasing " "value, starting with ``1``." msgstr ":class:`Enum` 使用 :class:`auto` 會產生從 ``1`` 開始遞增的整數。" -#: ../../library/enum.rst:471 +#: ../../library/enum.rst:461 msgid "Added :ref:`enum-dataclass-support`" msgstr "新增 :ref:`enum-dataclass-support`" -#: ../../library/enum.rst:476 +#: ../../library/enum.rst:465 +#, fuzzy +msgid "Adds a new name as an alias to an existing member::" +msgstr ":meth:`~EnumType._add_alias_` -- 新增一個名稱作為現有成員的別名。" + +#: ../../library/enum.rst:467 +#, fuzzy +msgid "" +">>> Color.RED._add_alias_(\"ERROR\")\n" +">>> Color.ERROR\n" +"" +msgstr "" +">>> Color.RED | Color.GREEN\n" +"" + +#: ../../library/enum.rst:471 +#, fuzzy +msgid "" +"Raises a :exc:`NameError` if the name is already assigned to a different " +"member." +msgstr "" +"新增一個名稱作為現有成員的別名。如果該名稱已被指派給不同的成員,則會引發 :" +"exc:`NameError`。" + +#: ../../library/enum.rst:477 +#, fuzzy +msgid "Adds a new value as an alias to an existing member::" +msgstr ":meth:`~EnumType._add_value_alias_` -- 新增一個值作為現有成員的別名。" + +#: ../../library/enum.rst:479 +msgid "" +">>> Color.RED._add_value_alias_(42)\n" +">>> Color(42)\n" +"" +msgstr "" + +#: ../../library/enum.rst:483 +#, fuzzy +msgid "" +"Raises a :exc:`ValueError` if the value is already linked with a different " +"member." +msgstr "" +"新增一個值作為現有成員的別名。如果該值已與不同成員連結,則會引發 :exc:" +"`ValueError`。" + +#: ../../library/enum.rst:490 msgid "" "*IntEnum* is the same as :class:`Enum`, but its members are also integers " "and can be used anywhere that an integer can be used. If any integer " @@ -959,13 +988,13 @@ msgstr "" "*IntEnum* 和 :class:`Enum` 一樣,但其成員同時也是整數而可以被用在任何使用整數" "的地方。如果 *IntEnum* 成員經過任何整數運算,結果值會失去其列舉狀態。" -#: ../../library/enum.rst:497 +#: ../../library/enum.rst:511 msgid "" "Using :class:`auto` with :class:`IntEnum` results in integers of increasing " "value, starting with ``1``." msgstr ":class:`IntEnum` 使用 :class:`auto` 會產生從 ``1`` 開始遞增的整數。" -#: ../../library/enum.rst:500 +#: ../../library/enum.rst:514 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` was " @@ -975,17 +1004,17 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:507 +#: ../../library/enum.rst:521 msgid "" "*StrEnum* is the same as :class:`Enum`, but its members are also strings and " "can be used in most of the same places that a string can be used. The result " "of any string operation performed on or with a *StrEnum* member is not part " "of the enumeration." msgstr "" -"*StrEnum* 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使" -"用字串的地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" +"*StrEnum* 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使用" +"字串的地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" -#: ../../library/enum.rst:528 +#: ../../library/enum.rst:542 msgid "" "There are places in the stdlib that check for an exact :class:`str` instead " "of a :class:`str` subclass (i.e. ``type(unknown) == str`` instead of " @@ -996,13 +1025,13 @@ msgstr "" "是 ``type(unknown) == str`` 而不是 ``isinstance(unknown, str)``),在這些地方" "你需要使用 ``str(MyStrEnum.MY_MEMBER)``。" -#: ../../library/enum.rst:535 +#: ../../library/enum.rst:549 msgid "" "Using :class:`auto` with :class:`StrEnum` results in the lower-cased member " "name as the value." msgstr ":class:`StrEnum` 使用 :class:`auto` 會產生小寫的成員名稱當作值。" -#: ../../library/enum.rst:540 +#: ../../library/enum.rst:554 msgid "" ":meth:`~object.__str__` is :meth:`!str.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` is " @@ -1012,7 +1041,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!str.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 也會是 :meth:`!str.__format__`。" -#: ../../library/enum.rst:548 +#: ../../library/enum.rst:562 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " @@ -1022,11 +1051,11 @@ msgstr "" "(*OR*)、``^`` (*XOR*) 和 ``~`` (*INVERT*);這些操作的結果是列舉的成員(的別" "名)。" -#: ../../library/enum.rst:554 +#: ../../library/enum.rst:568 msgid "Returns *True* if value is in self::" msgstr "如果 value 在 self 裡則回傳 *True*: ::" -#: ../../library/enum.rst:556 +#: ../../library/enum.rst:570 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1062,11 +1091,11 @@ msgstr "" ">>> white in purple\n" "False" -#: ../../library/enum.rst:575 +#: ../../library/enum.rst:589 msgid "Returns all contained non-alias members::" msgstr "回傳所有包含的非別名成員: ::" -#: ../../library/enum.rst:577 +#: ../../library/enum.rst:591 msgid "" ">>> list(Color.RED)\n" "[]\n" @@ -1078,11 +1107,11 @@ msgstr "" ">>> list(purple)\n" "[, ]" -#: ../../library/enum.rst:586 +#: ../../library/enum.rst:600 msgid "Returns number of members in flag::" msgstr "回傳旗標裡的成員數量: ::" -#: ../../library/enum.rst:588 +#: ../../library/enum.rst:602 msgid "" ">>> len(Color.GREEN)\n" "1\n" @@ -1094,11 +1123,11 @@ msgstr "" ">>> len(white)\n" "3" -#: ../../library/enum.rst:597 +#: ../../library/enum.rst:611 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "如果成員在旗標裡則回傳 *True*,否則回傳 *False*: ::" -#: ../../library/enum.rst:599 +#: ../../library/enum.rst:613 msgid "" ">>> bool(Color.GREEN)\n" "True\n" @@ -1116,11 +1145,11 @@ msgstr "" ">>> bool(black)\n" "False" -#: ../../library/enum.rst:609 +#: ../../library/enum.rst:623 msgid "Returns current flag binary or'ed with other::" msgstr "回傳和 other 做 OR 過後的二進位旗標: ::" -#: ../../library/enum.rst:611 +#: ../../library/enum.rst:625 msgid "" ">>> Color.RED | Color.GREEN\n" "" @@ -1128,11 +1157,11 @@ msgstr "" ">>> Color.RED | Color.GREEN\n" "" -#: ../../library/enum.rst:616 +#: ../../library/enum.rst:630 msgid "Returns current flag binary and'ed with other::" msgstr "回傳和 other 做 AND 過後的二進位旗標: ::" -#: ../../library/enum.rst:618 +#: ../../library/enum.rst:632 msgid "" ">>> purple & white\n" "\n" @@ -1144,11 +1173,11 @@ msgstr "" ">>> purple & Color.GREEN\n" "" -#: ../../library/enum.rst:625 +#: ../../library/enum.rst:639 msgid "Returns current flag binary xor'ed with other::" msgstr "回傳和 other 做 XOR 過後的二進位旗標: ::" -#: ../../library/enum.rst:627 +#: ../../library/enum.rst:641 msgid "" ">>> purple ^ white\n" "\n" @@ -1160,11 +1189,11 @@ msgstr "" ">>> purple ^ Color.GREEN\n" "" -#: ../../library/enum.rst:634 +#: ../../library/enum.rst:648 msgid "Returns all the flags in *type(self)* that are not in *self*::" msgstr "回傳所有在 *type(self)* 但不在 *self* 裡的旗標: ::" -#: ../../library/enum.rst:636 +#: ../../library/enum.rst:650 msgid "" ">>> ~white\n" "\n" @@ -1180,7 +1209,7 @@ msgstr "" ">>> ~Color.RED\n" "" -#: ../../library/enum.rst:645 +#: ../../library/enum.rst:659 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." @@ -1188,17 +1217,17 @@ msgstr "" "用來格式化任何剩下未命名數值的函式。預設是值的 repr,常見選擇是 :func:`hex` " "和 :func:`oct`。" -#: ../../library/enum.rst:650 +#: ../../library/enum.rst:664 msgid "" "Using :class:`auto` with :class:`Flag` results in integers that are powers " "of two, starting with ``1``." msgstr ":class:`Flag` 使用 :class:`auto` 會產生從 ``1`` 開始 2 的次方的整數。" -#: ../../library/enum.rst:653 +#: ../../library/enum.rst:667 msgid "The *repr()* of zero-valued flags has changed. It is now::" msgstr "值為 0 的旗標的 *repr()* 已改變。現在是: ::" -#: ../../library/enum.rst:661 +#: ../../library/enum.rst:675 msgid "" "``IntFlag`` is the same as :class:`Flag`, but its members are also integers " "and can be used anywhere that an integer can be used." @@ -1206,13 +1235,13 @@ msgstr "" "``IntFlag`` 和 :class:`Flag` 一樣,但其成員同時也是整數而可以被用在任何使用整" "數的地方。" -#: ../../library/enum.rst:675 +#: ../../library/enum.rst:689 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "如果 *IntFlag* 成員經過任何整數運算,其結果不是 *IntFlag*: ::" -#: ../../library/enum.rst:678 +#: ../../library/enum.rst:692 msgid "" ">>> Color.RED + 2\n" "3" @@ -1220,32 +1249,32 @@ msgstr "" ">>> Color.RED + 2\n" "3" -#: ../../library/enum.rst:681 +#: ../../library/enum.rst:695 msgid "If a :class:`Flag` operation is performed with an *IntFlag* member and:" msgstr "如果 *IntFlag* 成員經過 :class:`Flag` 操作且:" -#: ../../library/enum.rst:683 +#: ../../library/enum.rst:697 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "結果是合法的 *IntFlag*:回傳 *IntFlag*" -#: ../../library/enum.rst:684 +#: ../../library/enum.rst:698 msgid "" "the result is not a valid *IntFlag*: the result depends on the :class:" "`FlagBoundary` setting" msgstr "結果不是合法的 *IntFlag*:結果會根據 :class:`FlagBoundary` 的設定" -#: ../../library/enum.rst:686 +#: ../../library/enum.rst:700 msgid "The :func:`repr` of unnamed zero-valued flags has changed. It is now:" msgstr "未命名且值為 0 的旗標的 :func:`repr` 已改變。現在是:" -#: ../../library/enum.rst:693 +#: ../../library/enum.rst:707 msgid "" "Using :class:`auto` with :class:`IntFlag` results in integers that are " "powers of two, starting with ``1``." msgstr "" ":class:`IntFlag` 使用 :class:`auto` 會產生從 ``1`` 開始 2 的次方的整數。" -#: ../../library/enum.rst:698 +#: ../../library/enum.rst:712 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` " @@ -1255,7 +1284,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:702 +#: ../../library/enum.rst:716 msgid "" "Inversion of an :class:`!IntFlag` now returns a positive value that is the " "union of all flags not in the given flag, rather than a negative value. This " @@ -1264,7 +1293,7 @@ msgstr "" ":class:`!IntFlag` 的反轉 (inversion) 現在會回傳正值,該值是不在給定旗標的所有" "旗標聯集,而不是一個負值。這符合現有 :class:`Flag` 的行為。" -#: ../../library/enum.rst:708 +#: ../../library/enum.rst:722 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" @@ -1272,15 +1301,15 @@ msgstr "" ":class:`!ReprEnum` 使用 :class:`Enum` 的 :meth:`repr() `,但使" "用混合資料型別的 :class:`str() `:" -#: ../../library/enum.rst:711 +#: ../../library/enum.rst:725 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "對 :class:`IntEnum` 和 :class:`IntFlag` 是 :meth:`!int.__str__`" -#: ../../library/enum.rst:712 +#: ../../library/enum.rst:726 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "對 :class:`StrEnum` 是 :meth:`!str.__str__`" -#: ../../library/enum.rst:714 +#: ../../library/enum.rst:728 msgid "" "Inherit from :class:`!ReprEnum` to keep the :class:`str() ` / :func:" "`format` of the mixed-in data type instead of using the :class:`Enum`-" @@ -1289,7 +1318,7 @@ msgstr "" "繼承 :class:`!ReprEnum` 來保留混合資料型別的 :class:`str() ` / :func:" "`format`,而不是使用 :class:`Enum` 預設的 :meth:`str() `。" -#: ../../library/enum.rst:723 +#: ../../library/enum.rst:737 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." @@ -1297,11 +1326,11 @@ msgstr "" "*EnumCheck* 包含 :func:`verify` 裝飾器使用的選項,以確保多樣的限制,不符合限" "制會產生 :exc:`ValueError`。" -#: ../../library/enum.rst:728 +#: ../../library/enum.rst:742 msgid "Ensure that each value has only one name::" msgstr "確保每個值只有一個名稱: ::" -#: ../../library/enum.rst:730 +#: ../../library/enum.rst:744 msgid "" ">>> from enum import Enum, verify, UNIQUE\n" ">>> @verify(UNIQUE)\n" @@ -1325,13 +1354,13 @@ msgstr "" "...\n" "ValueError: aliases found in : CRIMSON -> RED" -#: ../../library/enum.rst:744 +#: ../../library/enum.rst:758 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "確保在最小值成員跟最大值成員間沒有缺少值: ::" -#: ../../library/enum.rst:747 +#: ../../library/enum.rst:761 msgid "" ">>> from enum import Enum, verify, CONTINUOUS\n" ">>> @verify(CONTINUOUS)\n" @@ -1353,7 +1382,7 @@ msgstr "" "...\n" "ValueError: invalid enum 'Color': missing values 3, 4" -#: ../../library/enum.rst:759 +#: ../../library/enum.rst:773 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" @@ -1361,7 +1390,7 @@ msgstr "" "確保任何旗標群組 / 遮罩只包含命名旗標 -- 當值是用指定而不是透過 :func:`auto` " "產生時是很實用的: ::" -#: ../../library/enum.rst:762 +#: ../../library/enum.rst:776 msgid "" ">>> from enum import Flag, verify, NAMED_FLAGS\n" ">>> @verify(NAMED_FLAGS)\n" @@ -1389,24 +1418,24 @@ msgstr "" "ValueError: invalid Flag 'Color': aliases WHITE and NEON are missing " "combined values of 0x18 [use enum.show_flag_values(value) for details]" -#: ../../library/enum.rst:776 +#: ../../library/enum.rst:790 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "CONTINUOUS 和 NAMED_FLAGS 是設計用來運作在整數值的成員上。" -#: ../../library/enum.rst:782 +#: ../../library/enum.rst:796 msgid "" "``FlagBoundary`` controls how out-of-range values are handled in :class:" "`Flag` and its subclasses." msgstr "``FlagBoundary`` 控制在 :class:`Flag` 及其子類別中如何處理範圍外的值。" -#: ../../library/enum.rst:787 +#: ../../library/enum.rst:801 msgid "" "Out-of-range values cause a :exc:`ValueError` to be raised. This is the " "default for :class:`Flag`::" msgstr "範圍外的值會引發 :exc:`ValueError`。這是 :class:`Flag` 的預設行為: ::" -#: ../../library/enum.rst:790 +#: ../../library/enum.rst:804 msgid "" ">>> from enum import Flag, STRICT, auto\n" ">>> class StrictFlag(Flag, boundary=STRICT):\n" @@ -1434,13 +1463,13 @@ msgstr "" " given 0b0 10100\n" " allowed 0b0 00111" -#: ../../library/enum.rst:805 +#: ../../library/enum.rst:819 msgid "" "Out-of-range values have invalid values removed, leaving a valid :class:" "`Flag` value::" msgstr "會移除範圍外的值中的非法值,留下合法的 :class:`Flag` 值: ::" -#: ../../library/enum.rst:808 +#: ../../library/enum.rst:822 msgid "" ">>> from enum import Flag, CONFORM, auto\n" ">>> class ConformFlag(Flag, boundary=CONFORM):\n" @@ -1460,13 +1489,13 @@ msgstr "" ">>> ConformFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:819 +#: ../../library/enum.rst:833 msgid "" "Out-of-range values lose their :class:`Flag` membership and revert to :class:" "`int`." msgstr "範圍外的值會失去它們的 :class:`Flag` 成員資格且恢復成 :class:`int`。" -#: ../../library/enum.rst:832 +#: ../../library/enum.rst:846 msgid "" "Out-of-range values are kept, and the :class:`Flag` membership is kept. This " "is the default for :class:`IntFlag`::" @@ -1474,7 +1503,7 @@ msgstr "" "範圍外的值會被保留,:class:`Flag` 成員資格也會被保留。這是 :class:`IntFlag` " "的預設行為: ::" -#: ../../library/enum.rst:835 +#: ../../library/enum.rst:849 msgid "" ">>> from enum import Flag, KEEP, auto\n" ">>> class KeepFlag(Flag, boundary=KEEP):\n" @@ -1494,7 +1523,7 @@ msgstr "" ">>> KeepFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:848 +#: ../../library/enum.rst:862 msgid "" "*EnumDict* is a subclass of :class:`dict` that is used as the namespace for " "defining enum classes (see :ref:`prepare`). It is exposed to allow " @@ -1508,7 +1537,7 @@ msgstr "" "如讓每個成員有多個值。它應該在被呼叫時帶上正在建立的列舉類別名稱,否則私有名" "稱和內部類別將無法被正確處理。" -#: ../../library/enum.rst:855 +#: ../../library/enum.rst:869 msgid "" "Note that only the :class:`~collections.abc.MutableMapping` interface (:meth:" "`~object.__setitem__` and :meth:`~dict.update`) is overridden. It may be " @@ -1519,15 +1548,15 @@ msgstr "" "__setitem__` 和 :meth:`~dict.update`)被覆寫。可能可以使用其他 :class:`!" "dict` 操作來繞過檢查,例如 :meth:`|= `。" -#: ../../library/enum.rst:862 +#: ../../library/enum.rst:876 msgid "A list of member names." msgstr "一個成員名稱的串列。" -#: ../../library/enum.rst:869 +#: ../../library/enum.rst:883 msgid "Supported ``__dunder__`` names" msgstr "支援的 ``__dunder__`` 名稱" -#: ../../library/enum.rst:871 +#: ../../library/enum.rst:885 msgid "" ":attr:`~EnumType.__members__` is a read-only ordered mapping of " "``member_name``:``member`` items. It is only available on the class." @@ -1535,7 +1564,7 @@ msgstr "" ":attr:`~EnumType.__members__` 是一個唯讀有序的\\ ``成員名稱``:``成員``\\ 項" "目的對映。只有在類別上可用。" -#: ../../library/enum.rst:874 +#: ../../library/enum.rst:888 msgid "" ":meth:`~Enum.__new__`, if specified, must create and return the enum " "members; it is also a very good idea to set the member's :attr:`!_value_` " @@ -1545,38 +1574,26 @@ msgstr "" "的 :attr:`!_value_` 也是一個很好的主意。一旦所有成員都建立之後就不會再被用" "到。" -#: ../../library/enum.rst:880 +#: ../../library/enum.rst:894 msgid "Supported ``_sunder_`` names" msgstr "支援的 ``_sunder_`` 名稱" -#: ../../library/enum.rst:882 -msgid "" -":meth:`~EnumType._add_alias_` -- adds a new name as an alias to an existing " -"member." -msgstr ":meth:`~EnumType._add_alias_` -- 新增一個名稱作為現有成員的別名。" - -#: ../../library/enum.rst:884 -msgid "" -":meth:`~EnumType._add_value_alias_` -- adds a new value as an alias to an " -"existing member." -msgstr ":meth:`~EnumType._add_value_alias_` -- 新增一個值作為現有成員的別名。" - -#: ../../library/enum.rst:886 +#: ../../library/enum.rst:896 msgid ":attr:`~Enum._name_` -- name of the member" msgstr ":attr:`~Enum._name_` -- 成員名稱" -#: ../../library/enum.rst:887 +#: ../../library/enum.rst:897 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr ":attr:`~Enum._value_` -- 成員的值;可以在 ``__new__`` 設定" -#: ../../library/enum.rst:888 +#: ../../library/enum.rst:898 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" ":meth:`~Enum._missing_` -- 當值沒有被找到時會使用的查詢函式;可以被覆寫" -#: ../../library/enum.rst:890 +#: ../../library/enum.rst:900 msgid "" ":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a :" "class:`str`, that will not be transformed into members, and will be removed " @@ -1585,7 +1602,7 @@ msgstr "" ":attr:`~Enum._ignore_` -- 一個名稱的串列,可以是 :class:`list` 或 :class:" "`str`,它不會被轉換成成員,且在最後的類別上會被移除" -#: ../../library/enum.rst:893 +#: ../../library/enum.rst:903 msgid "" ":attr:`~Enum._order_` -- no longer used, kept for backward compatibility " "(class attribute, removed during class creation)" @@ -1593,28 +1610,42 @@ msgstr "" ":attr:`~Enum._order_` -- 不再被使用,僅為了向後相容而保留(類別屬性,在類別建" "立時移除)" -#: ../../library/enum.rst:895 +#: ../../library/enum.rst:905 msgid "" ":meth:`~Enum._generate_next_value_` -- used to get an appropriate value for " "an enum member; may be overridden" msgstr "" ":meth:`~Enum._generate_next_value_` -- 用來為列舉成員取得合適的值;可以被覆寫" -#: ../../library/enum.rst:900 +#: ../../library/enum.rst:910 msgid "" "For standard :class:`Enum` classes the next value chosen is the highest " "value seen incremented by one." msgstr "" "對標準的 :class:`Enum` 類別來說,下一個被選擇的值是所看過的最大值加一。" -#: ../../library/enum.rst:903 +#: ../../library/enum.rst:913 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two." msgstr "" "對 :class:`Flag` 類別來說,下一個被選擇的值是下一個最大的 2 的次方的數字。" -#: ../../library/enum.rst:906 +#: ../../library/enum.rst:916 +#, fuzzy +msgid "" +":meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing " +"member." +msgstr ":meth:`~EnumType._add_alias_` -- 新增一個名稱作為現有成員的別名。" + +#: ../../library/enum.rst:918 +#, fuzzy +msgid "" +":meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an " +"existing member." +msgstr ":meth:`~EnumType._add_value_alias_` -- 新增一個值作為現有成員的別名。" + +#: ../../library/enum.rst:921 msgid "" "While ``_sunder_`` names are generally reserved for the further development " "of the :class:`Enum` class and can not be used, some are explicitly allowed:" @@ -1622,30 +1653,30 @@ msgstr "" "雖然 ``_sunder_`` 名稱通常保留用於 :class:`Enum` 類別的進一步開發而不能被使" "用,但有些是明確允許的:" -#: ../../library/enum.rst:909 +#: ../../library/enum.rst:924 msgid "" "``_repr_*`` (e.g. ``_repr_html_``), as used in `IPython's rich display`_" msgstr "" "``_repr_*``\\ (例如 ``_repr_html_``),例如用於 `IPython 的豐富顯示 " "`_" -#: ../../library/enum.rst:911 +#: ../../library/enum.rst:926 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``、``_order_``、``_generate_next_value_``" -#: ../../library/enum.rst:912 +#: ../../library/enum.rst:927 msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../library/enum.rst:913 +#: ../../library/enum.rst:928 msgid "``_add_alias_``, ``_add_value_alias_``, ``_repr_*``" msgstr "``_add_alias_``、``_add_value_alias_``、``_repr_*``" -#: ../../library/enum.rst:919 +#: ../../library/enum.rst:934 msgid "Utilities and Decorators" msgstr "通用項目與裝飾器" -#: ../../library/enum.rst:923 +#: ../../library/enum.rst:938 msgid "" "*auto* can be used in place of a value. If used, the *Enum* machinery will " "call an :class:`Enum`'s :meth:`~Enum._generate_next_value_` to get an " @@ -1661,16 +1692,16 @@ msgstr "" "`IntFlag` 來說,是第一個比最大值還大的 2 的次方的數字;對 :class:`StrEnum` 來" "說,是成員名稱的小寫版本。如果混用 *auto()* 和手動指定值的話要特別注意。" -#: ../../library/enum.rst:931 +#: ../../library/enum.rst:946 msgid "" "*auto* instances are only resolved when at the top level of an assignment:" msgstr "*auto* 實例只有在最上層的賦值時才會被解析:" -#: ../../library/enum.rst:933 +#: ../../library/enum.rst:948 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "``FIRST = auto()`` 可以運作(auto() 會被取代成 ``1``)" -#: ../../library/enum.rst:934 +#: ../../library/enum.rst:949 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is used to create the ``SECOND`` enum member;" @@ -1678,7 +1709,7 @@ msgstr "" "``SECOND = auto(), -2`` 可以運作(auto 會被取代成 ``2``, 因此 ``2, -2`` 會被" "用來建立列舉成員 ``SECOND``;" -#: ../../library/enum.rst:936 +#: ../../library/enum.rst:951 msgid "" "``THREE = [auto(), -3]`` will *not* work (``, -3`` is used to " "create the ``THREE`` enum member)" @@ -1686,19 +1717,19 @@ msgstr "" "``THREE = [auto(), -3]`` *無法*\\ 運作(\\ ``, -3`` 會被用來建立列" "舉成員 ``THREE``)" -#: ../../library/enum.rst:941 +#: ../../library/enum.rst:956 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "在之前的版本中,``auto()`` 必須是賦值行裡的唯一內容才能運作正確。" -#: ../../library/enum.rst:944 +#: ../../library/enum.rst:959 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "可以覆寫 ``_generate_next_value_`` 來客製 *auto* 使用的值。" -#: ../../library/enum.rst:947 +#: ../../library/enum.rst:962 msgid "" "in 3.13 the default ``_generate_next_value_`` will always return the highest " "member value incremented by 1, and will fail if any member is an " @@ -1707,7 +1738,7 @@ msgstr "" "在 3.13 預設 ``_generate_next_value_`` 總是回傳最大的成員值加一,如果任何成員" "是不相容的型別就會失敗。" -#: ../../library/enum.rst:953 +#: ../../library/enum.rst:968 msgid "" "A decorator similar to the built-in *property*, but specifically for " "enumerations. It allows member attributes to have the same names as members " @@ -1716,7 +1747,7 @@ msgstr "" "和內建的 *property* 相似的裝飾器,但只專門針對列舉。它允許成員屬性和成員本身" "有相同名稱。" -#: ../../library/enum.rst:957 +#: ../../library/enum.rst:972 msgid "" "the *property* and the member must be defined in separate classes; for " "example, the *value* and *name* attributes are defined in the *Enum* class, " @@ -1726,7 +1757,7 @@ msgstr "" "*屬性*\\ 和成員必須定義在分開的類別裡;例如 *value* 和 *name* 屬性定義在 " "*Enum* 類別而 *Enum* 子類別可以定義成員名稱為 ``value`` 和 ``name``。" -#: ../../library/enum.rst:966 +#: ../../library/enum.rst:981 msgid "" "A :keyword:`class` decorator specifically for enumerations. It searches an " "enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; " @@ -1736,7 +1767,7 @@ msgstr "" "__members__`,蒐集任何它找到的別名;如果有找到任何別名則引發 :exc:" "`ValueError` 並附上細節: ::" -#: ../../library/enum.rst:970 +#: ../../library/enum.rst:985 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -1762,7 +1793,7 @@ msgstr "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" -#: ../../library/enum.rst:984 +#: ../../library/enum.rst:999 msgid "" "A :keyword:`class` decorator specifically for enumerations. Members from :" "class:`EnumCheck` are used to specify which constraints should be checked on " @@ -1771,15 +1802,15 @@ msgstr "" "專門針對列舉的 :keyword:`class` 裝飾器。使用 :class:`EnumCheck` 裡的成員來指" "定在裝飾的列舉上應該檢查什麼限制。" -#: ../../library/enum.rst:992 +#: ../../library/enum.rst:1007 msgid "A decorator for use in enums: its target will become a member." msgstr "列舉所使用的裝飾器:其目標會變成成員。" -#: ../../library/enum.rst:998 +#: ../../library/enum.rst:1013 msgid "A decorator for use in enums: its target will not become a member." msgstr "列舉所使用的裝飾器:其目標不會變成成員。" -#: ../../library/enum.rst:1004 +#: ../../library/enum.rst:1019 msgid "" "A decorator to change the :class:`str() ` and :func:`repr` of an enum " "to show its members as belonging to the module instead of its class. Should " @@ -1790,19 +1821,19 @@ msgstr "" "組而不是其類別。應該只有當列舉成員被匯出到模組的全域命名空間才使用(範例請參" "考 :class:`re.RegexFlag`)。" -#: ../../library/enum.rst:1013 +#: ../../library/enum.rst:1028 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "回傳在旗標\\ *值*\\ 中包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:1021 +#: ../../library/enum.rst:1036 msgid "Notes" msgstr "備註" -#: ../../library/enum.rst:1023 +#: ../../library/enum.rst:1038 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr ":class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag`" -#: ../../library/enum.rst:1025 +#: ../../library/enum.rst:1040 msgid "" "These three enum types are designed to be drop-in replacements for existing " "integer- and string-based values; as such, they have extra limitations:" @@ -1810,17 +1841,17 @@ msgstr "" "這三種列舉型別是設計來直接取代現有以整數及字串為基底的值;因此它們有額外的限" "制:" -#: ../../library/enum.rst:1028 +#: ../../library/enum.rst:1043 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "``__str__`` 使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:1030 +#: ../../library/enum.rst:1045 msgid "" "``__format__``, because it uses ``__str__``, will also use the value of the " "enum member instead of its name" msgstr "``__format__`` 因為使用 ``__str__``,也會使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:1033 +#: ../../library/enum.rst:1048 msgid "" "If you do not need/want those limitations, you can either create your own " "base class by mixing in the ``int`` or ``str`` type yourself::" @@ -1828,7 +1859,7 @@ msgstr "" "如果你不需要或不想要這些限制,你可以透過混合 ``int`` 或 ``str`` 型別來建立自" "己的基礎類別: ::" -#: ../../library/enum.rst:1036 +#: ../../library/enum.rst:1051 msgid "" ">>> from enum import Enum\n" ">>> class MyIntEnum(int, Enum):\n" @@ -1838,11 +1869,11 @@ msgstr "" ">>> class MyIntEnum(int, Enum):\n" "... pass" -#: ../../library/enum.rst:1040 +#: ../../library/enum.rst:1055 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "或者你也可以在你的列舉重新給定合適的 :meth:`str`: ::" -#: ../../library/enum.rst:1042 +#: ../../library/enum.rst:1057 msgid "" ">>> from enum import Enum, IntEnum\n" ">>> class MyIntEnum(IntEnum):\n" From 91e85c2ae9da4e63d46eeb5a20d4dbd716e8e34a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 14 Aug 2025 00:17:29 +0000 Subject: [PATCH 13/23] sync with cpython 9417ea59 --- library/functions.po | 308 +++++++++++++++++----------------- library/locale.po | 386 ++++++++++++++++++++++++++----------------- 2 files changed, 394 insertions(+), 300 deletions(-) diff --git a/library/functions.po b/library/functions.po index fee1a48f99..59195e3e29 100644 --- a/library/functions.po +++ b/library/functions.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-09 00:16+0000\n" +"POT-Creation-Date: 2025-08-14 00:16+0000\n" "PO-Revision-Date: 2024-05-06 17:06+0800\n" "Last-Translator: KNChiu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -2716,17 +2716,29 @@ msgid "The ``'U'`` mode has been removed." msgstr "``'U'`` 模式被移除。" #: ../../library/functions.rst:1555 +msgid "Return the ordinal value of a character." +msgstr "" + +#: ../../library/functions.rst:1557 +#, fuzzy msgid "" -"Given a string representing one Unicode character, return an integer " -"representing the Unicode code point of that character. For example, " -"``ord('a')`` returns the integer ``97`` and ``ord('€')`` (Euro sign) returns " -"``8364``. This is the inverse of :func:`chr`." +"If the argument is a one-character string, return the Unicode code point of " +"that character. For example, ``ord('a')`` returns the integer ``97`` and " +"``ord('€')`` (Euro sign) returns ``8364``. This is the inverse of :func:" +"`chr`." msgstr "" "對於代表單個 Unicode 字元的字串,回傳代表它 Unicode 編碼位置的整數。例如 " "``ord('a')`` 回傳整數 ``97``、``ord('€')``\\ (歐元符號)回傳 ``8364``。這" "是 :func:`chr` 的逆函式。" -#: ../../library/functions.rst:1563 +#: ../../library/functions.rst:1562 +msgid "" +"If the argument is a :class:`bytes` or :class:`bytearray` object of length " +"1, return its single byte value. For example, ``ord(b'a')`` returns the " +"integer ``97``." +msgstr "" + +#: ../../library/functions.rst:1569 msgid "" "Return *base* to the power *exp*; if *mod* is present, return *base* to the " "power *exp*, modulo *mod* (computed more efficiently than ``pow(base, exp) % " @@ -2737,7 +2749,7 @@ msgstr "" "*mod* 取餘數(比直接呼叫 ``pow(base, exp) % mod`` 計算更高效)。兩個引數形式" "的 ``pow(exp, exp)`` 等價於次方運算子:``base**exp``。" -#: ../../library/functions.rst:1568 +#: ../../library/functions.rst:1574 #, fuzzy msgid "" "When arguments are builtin numeric types with mixed operand types, the " @@ -2762,7 +2774,7 @@ msgstr "" "`float` 的負數且指數為整數,則會得到一個浮點數的結果,例如 ``pow(-9, 2.0)`` " "會回傳 ``81.0``。" -#: ../../library/functions.rst:1580 +#: ../../library/functions.rst:1586 msgid "" "For :class:`int` operands *base* and *exp*, if *mod* is present, *mod* must " "also be of integer type and *mod* must be nonzero. If *mod* is present and " @@ -2775,11 +2787,11 @@ msgstr "" "與 *mod* 互質。在這種情況下,會回傳 ``pow(inv_base, -exp, mod)``,其中 " "*inv_base* 是 *base* 對 *mod* 的模倒數 (inverse modulo)。" -#: ../../library/functions.rst:1586 +#: ../../library/functions.rst:1592 msgid "Here's an example of computing an inverse for ``38`` modulo ``97``::" msgstr "以下是一個計算 ``38`` 對 ``97`` 取模倒數的範例: ::" -#: ../../library/functions.rst:1588 +#: ../../library/functions.rst:1594 msgid "" ">>> pow(38, -1, mod=97)\n" "23\n" @@ -2791,7 +2803,7 @@ msgstr "" ">>> 23 * 38 % 97 == 1\n" "True" -#: ../../library/functions.rst:1593 +#: ../../library/functions.rst:1599 msgid "" "For :class:`int` operands, the three-argument form of ``pow`` now allows the " "second argument to be negative, permitting computation of modular inverses." @@ -2799,12 +2811,12 @@ msgstr "" "對於 :class:`int` 運算元,現在 ``pow`` 的三引數形式允許第二個引數為負數,也容" "許模倒數的計算。" -#: ../../library/functions.rst:1598 +#: ../../library/functions.rst:1604 msgid "" "Allow keyword arguments. Formerly, only positional arguments were supported." msgstr "允許關鍵字引數。在此之前只支援位置引數。" -#: ../../library/functions.rst:1605 +#: ../../library/functions.rst:1611 msgid "" "Print *objects* to the text stream *file*, separated by *sep* and followed " "by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as " @@ -2813,7 +2825,7 @@ msgstr "" "將 *objects* 列印到文字資料串流 *file*,用 *sep* 分隔並以 *end* 結尾。如果有" "給定 *sep*、*end*、*file* 和 *flush*,那麼它們必須是關鍵字引數的形式。" -#: ../../library/functions.rst:1609 +#: ../../library/functions.rst:1615 msgid "" "All non-keyword arguments are converted to strings like :func:`str` does and " "written to the stream, separated by *sep* and followed by *end*. Both *sep* " @@ -2826,7 +2838,7 @@ msgstr "" "以是 ``None``,這表示使用預設值。如果沒有給定 *objects*,:func:`print` 就只會" "寫入 *end*。" -#: ../../library/functions.rst:1615 +#: ../../library/functions.rst:1621 msgid "" "The *file* argument must be an object with a ``write(string)`` method; if it " "is not present or ``None``, :data:`sys.stdout` will be used. Since printed " @@ -2838,7 +2850,7 @@ msgstr "" "串,所以 :func:`print` 不能用於二進位模式的檔案物件。對於此類物件,請改用 " "``file.write(...)``。" -#: ../../library/functions.rst:1620 +#: ../../library/functions.rst:1626 msgid "" "Output buffering is usually determined by *file*. However, if *flush* is " "true, the stream is forcibly flushed." @@ -2846,15 +2858,15 @@ msgstr "" "輸出緩衝通常會由 *file* 決定。但是如果 *flush* 為 true,則資料串流會被強制清" "除。" -#: ../../library/functions.rst:1624 +#: ../../library/functions.rst:1630 msgid "Added the *flush* keyword argument." msgstr "增加了 *flush* 關鍵字引數。" -#: ../../library/functions.rst:1630 +#: ../../library/functions.rst:1636 msgid "Return a property attribute." msgstr "回傳 property 屬性。" -#: ../../library/functions.rst:1632 +#: ../../library/functions.rst:1638 msgid "" "*fget* is a function for getting an attribute value. *fset* is a function " "for setting an attribute value. *fdel* is a function for deleting an " @@ -2863,11 +2875,11 @@ msgstr "" "*fget* 是一個用於取得屬性值的函式,*fset* 是一個用於設定屬性值的函式,*fdel* " "是一個用於刪除屬性值的函式,而 *doc* 會為該屬性建立一個說明字串。" -#: ../../library/functions.rst:1636 +#: ../../library/functions.rst:1642 msgid "A typical use is to define a managed attribute ``x``::" msgstr "一個典型的用途是定義一個受管理的屬性 ``x``: ::" -#: ../../library/functions.rst:1638 +#: ../../library/functions.rst:1644 msgid "" "class C:\n" " def __init__(self):\n" @@ -2899,7 +2911,7 @@ msgstr "" "\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" -#: ../../library/functions.rst:1653 +#: ../../library/functions.rst:1659 msgid "" "If *c* is an instance of *C*, ``c.x`` will invoke the getter, ``c.x = " "value`` will invoke the setter, and ``del c.x`` the deleter." @@ -2907,7 +2919,7 @@ msgstr "" "如果 *c* 是 *C* 的一個實例,則 ``c.x`` 將會叫用取得器 (getter),``c.x = " "value`` 會呼叫設定器 (setter),而 ``del c.x`` 會叫用刪除器 (deleter)。" -#: ../../library/functions.rst:1656 +#: ../../library/functions.rst:1662 msgid "" "If given, *doc* will be the docstring of the property attribute. Otherwise, " "the property will copy *fget*'s docstring (if it exists). This makes it " @@ -2918,7 +2930,7 @@ msgstr "" "*fget* 的說明字串(如果它存在的話)。這樣一來,就能夠輕鬆地使用 :func:" "`property` 作為\\ :term:`裝飾器 `\\ 來建立唯讀屬性: ::" -#: ../../library/functions.rst:1660 +#: ../../library/functions.rst:1666 msgid "" "class Parrot:\n" " def __init__(self):\n" @@ -2930,14 +2942,14 @@ msgid "" " return self._voltage" msgstr "" -#: ../../library/functions.rst:1669 +#: ../../library/functions.rst:1675 msgid "" "The ``@property`` decorator turns the :meth:`!voltage` method into a " "\"getter\" for a read-only attribute with the same name, and it sets the " "docstring for *voltage* to \"Get the current voltage.\"" msgstr "" -#: ../../library/functions.rst:1677 +#: ../../library/functions.rst:1683 msgid "" "A property object has ``getter``, ``setter``, and ``deleter`` methods usable " "as decorators that create a copy of the property with the corresponding " @@ -2945,7 +2957,7 @@ msgid "" "with an example:" msgstr "" -#: ../../library/functions.rst:1682 +#: ../../library/functions.rst:1688 msgid "" "class C:\n" " def __init__(self):\n" @@ -2981,36 +2993,36 @@ msgstr "" " def x(self):\n" " del self._x" -#: ../../library/functions.rst:1701 +#: ../../library/functions.rst:1707 msgid "" "This code is exactly equivalent to the first example. Be sure to give the " "additional functions the same name as the original property (``x`` in this " "case.)" msgstr "" -#: ../../library/functions.rst:1705 +#: ../../library/functions.rst:1711 msgid "" "The returned property object also has the attributes ``fget``, ``fset``, and " "``fdel`` corresponding to the constructor arguments." msgstr "" -#: ../../library/functions.rst:1708 +#: ../../library/functions.rst:1714 msgid "The docstrings of property objects are now writeable." msgstr "" -#: ../../library/functions.rst:1713 +#: ../../library/functions.rst:1719 msgid "" "Attribute holding the name of the property. The name of the property can be " "changed at runtime." msgstr "" -#: ../../library/functions.rst:1724 +#: ../../library/functions.rst:1730 msgid "" "Rather than being a function, :class:`range` is actually an immutable " "sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`." msgstr "" -#: ../../library/functions.rst:1730 +#: ../../library/functions.rst:1736 msgid "" "Return a string containing a printable representation of an object. For " "many types, this function makes an attempt to return a string that would " @@ -3023,11 +3035,11 @@ msgid "" "raise :exc:`RuntimeError`." msgstr "" -#: ../../library/functions.rst:1741 +#: ../../library/functions.rst:1747 msgid "This class has a custom representation that can be evaluated::" msgstr "" -#: ../../library/functions.rst:1743 +#: ../../library/functions.rst:1749 msgid "" "class Person:\n" " def __init__(self, name, age):\n" @@ -3045,7 +3057,7 @@ msgstr "" " def __repr__(self):\n" " return f\"Person('{self.name}', {self.age})\"" -#: ../../library/functions.rst:1754 +#: ../../library/functions.rst:1760 msgid "" "Return a reverse :term:`iterator`. *seq* must be an object which has a :" "meth:`~object.__reversed__` method or supports the sequence protocol (the :" @@ -3053,14 +3065,14 @@ msgid "" "with integer arguments starting at ``0``)." msgstr "" -#: ../../library/functions.rst:1762 +#: ../../library/functions.rst:1768 msgid "" "Return *number* rounded to *ndigits* precision after the decimal point. If " "*ndigits* is omitted or is ``None``, it returns the nearest integer to its " "input." msgstr "" -#: ../../library/functions.rst:1766 +#: ../../library/functions.rst:1772 msgid "" "For the built-in types supporting :func:`round`, values are rounded to the " "closest multiple of 10 to the power minus *ndigits*; if two multiples are " @@ -3071,13 +3083,13 @@ msgid "" "``None``. Otherwise, the return value has the same type as *number*." msgstr "" -#: ../../library/functions.rst:1775 +#: ../../library/functions.rst:1781 msgid "" "For a general Python object ``number``, ``round`` delegates to ``number." "__round__``." msgstr "" -#: ../../library/functions.rst:1780 +#: ../../library/functions.rst:1786 msgid "" "The behavior of :func:`round` for floats can be surprising: for example, " "``round(2.675, 2)`` gives ``2.67`` instead of the expected ``2.68``. This is " @@ -3086,21 +3098,21 @@ msgid "" "information." msgstr "" -#: ../../library/functions.rst:1792 +#: ../../library/functions.rst:1798 msgid "" "Return a new :class:`set` object, optionally with elements taken from " "*iterable*. ``set`` is a built-in class. See :class:`set` and :ref:`types-" "set` for documentation about this class." msgstr "" -#: ../../library/functions.rst:1796 +#: ../../library/functions.rst:1802 msgid "" "For other containers see the built-in :class:`frozenset`, :class:`list`, :" "class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` " "module." msgstr "" -#: ../../library/functions.rst:1803 +#: ../../library/functions.rst:1809 msgid "" "This is the counterpart of :func:`getattr`. The arguments are an object, a " "string, and an arbitrary value. The string may name an existing attribute " @@ -3109,7 +3121,7 @@ msgid "" "is equivalent to ``x.foobar = 123``." msgstr "" -#: ../../library/functions.rst:1809 +#: ../../library/functions.rst:1815 msgid "" "*name* need not be a Python identifier as defined in :ref:`identifiers` " "unless the object chooses to enforce that, for example in a custom :meth:" @@ -3118,21 +3130,21 @@ msgid "" "notation, but is accessible through :func:`getattr` etc.." msgstr "" -#: ../../library/functions.rst:1817 +#: ../../library/functions.rst:1823 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " "with two leading underscores) name in order to set it with :func:`setattr`." msgstr "" -#: ../../library/functions.rst:1826 +#: ../../library/functions.rst:1832 msgid "" "Return a :term:`slice` object representing the set of indices specified by " "``range(start, stop, step)``. The *start* and *step* arguments default to " "``None``." msgstr "" -#: ../../library/functions.rst:1830 +#: ../../library/functions.rst:1836 msgid "" "Slice objects have read-only data attributes :attr:`!start`, :attr:`!stop`, " "and :attr:`!step` which merely return the argument values (or their " @@ -3140,48 +3152,48 @@ msgid "" "by NumPy and other third-party packages." msgstr "" -#: ../../library/functions.rst:1839 +#: ../../library/functions.rst:1845 msgid "" "Slice objects are also generated when extended indexing syntax is used. For " "example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:" "`itertools.islice` for an alternate version that returns an :term:`iterator`." msgstr "" -#: ../../library/functions.rst:1844 +#: ../../library/functions.rst:1850 msgid "" "Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:" "`~slice.stop`, and :attr:`~slice.step` are hashable)." msgstr "" -#: ../../library/functions.rst:1850 +#: ../../library/functions.rst:1856 msgid "Return a new sorted list from the items in *iterable*." msgstr "" -#: ../../library/functions.rst:1852 +#: ../../library/functions.rst:1858 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "有兩個選擇性引數,只能使用關鍵字引數來指定。" -#: ../../library/functions.rst:1854 +#: ../../library/functions.rst:1860 msgid "" "*key* specifies a function of one argument that is used to extract a " "comparison key from each element in *iterable* (for example, ``key=str." "lower``). The default value is ``None`` (compare the elements directly)." msgstr "" -#: ../../library/functions.rst:1858 +#: ../../library/functions.rst:1864 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." msgstr "" -#: ../../library/functions.rst:1861 +#: ../../library/functions.rst:1867 msgid "" "Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a " "*key* function." msgstr "" -#: ../../library/functions.rst:1864 +#: ../../library/functions.rst:1870 msgid "" "The built-in :func:`sorted` function is guaranteed to be stable. A sort is " "stable if it guarantees not to change the relative order of elements that " @@ -3189,7 +3201,7 @@ msgid "" "example, sort by department, then by salary grade)." msgstr "" -#: ../../library/functions.rst:1869 +#: ../../library/functions.rst:1875 msgid "" "The sort algorithm uses only ``<`` comparisons between items. While " "defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` " @@ -3201,22 +3213,22 @@ msgid "" "method." msgstr "" -#: ../../library/functions.rst:1878 +#: ../../library/functions.rst:1884 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "" -#: ../../library/functions.rst:1882 +#: ../../library/functions.rst:1888 msgid "Transform a method into a static method." msgstr "" -#: ../../library/functions.rst:1884 +#: ../../library/functions.rst:1890 msgid "" "A static method does not receive an implicit first argument. To declare a " "static method, use this idiom::" msgstr "" -#: ../../library/functions.rst:1887 +#: ../../library/functions.rst:1893 msgid "" "class C:\n" " @staticmethod\n" @@ -3226,7 +3238,7 @@ msgstr "" " @staticmethod\n" " def f(arg1, arg2, argN): ..." -#: ../../library/functions.rst:1891 +#: ../../library/functions.rst:1897 msgid "" "The ``@staticmethod`` form is a function :term:`decorator` -- see :ref:" "`function` for details." @@ -3234,7 +3246,7 @@ msgstr "" "``@staticmethod`` 語法是一個函式 :term:`decorator` - 參見 :ref:`function` 中" "的詳細介紹。" -#: ../../library/functions.rst:1894 +#: ../../library/functions.rst:1900 msgid "" "A static method can be called either on the class (such as ``C.f()``) or on " "an instance (such as ``C().f()``). Moreover, the static method :term:" @@ -3242,14 +3254,14 @@ msgid "" "(such as ``f()``)." msgstr "" -#: ../../library/functions.rst:1899 +#: ../../library/functions.rst:1905 msgid "" "Static methods in Python are similar to those found in Java or C++. Also, " "see :func:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" -#: ../../library/functions.rst:1903 +#: ../../library/functions.rst:1909 msgid "" "Like all decorators, it is also possible to call ``staticmethod`` as a " "regular function and do something with its result. This is needed in some " @@ -3258,7 +3270,7 @@ msgid "" "cases, use this idiom::" msgstr "" -#: ../../library/functions.rst:1909 +#: ../../library/functions.rst:1915 msgid "" "def regular_function():\n" " ...\n" @@ -3272,11 +3284,11 @@ msgstr "" "class C:\n" " method = staticmethod(regular_function)" -#: ../../library/functions.rst:1915 +#: ../../library/functions.rst:1921 msgid "For more information on static methods, see :ref:`types`." msgstr "關於 static method 的更多資訊,請參考 :ref:`types`。" -#: ../../library/functions.rst:1917 +#: ../../library/functions.rst:1923 msgid "" "Static methods now inherit the method attributes (:attr:`~function." "__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" @@ -3288,25 +3300,25 @@ msgstr "" "__doc__` 和 :attr:`~function.__annotations__`),並擁有一個新的 " "``__wrapped__`` 屬性,且為如一般函式的可呼叫物件。" -#: ../../library/functions.rst:1933 +#: ../../library/functions.rst:1939 msgid "" "Return a :class:`str` version of *object*. See :func:`str` for details." msgstr "" -#: ../../library/functions.rst:1935 +#: ../../library/functions.rst:1941 msgid "" "``str`` is the built-in string :term:`class`. For general information about " "strings, see :ref:`textseq`." msgstr "" -#: ../../library/functions.rst:1941 +#: ../../library/functions.rst:1947 msgid "" "Sums *start* and the items of an *iterable* from left to right and returns " "the total. The *iterable*'s items are normally numbers, and the start value " "is not allowed to be a string." msgstr "" -#: ../../library/functions.rst:1945 +#: ../../library/functions.rst:1951 msgid "" "For some use cases, there are good alternatives to :func:`sum`. The " "preferred, fast way to concatenate a sequence of strings is by calling ``''." @@ -3315,37 +3327,37 @@ msgid "" "using :func:`itertools.chain`." msgstr "" -#: ../../library/functions.rst:1951 +#: ../../library/functions.rst:1957 msgid "The *start* parameter can be specified as a keyword argument." msgstr "*start* 參數可被指定為關鍵字引數。" -#: ../../library/functions.rst:1954 +#: ../../library/functions.rst:1960 msgid "" "Summation of floats switched to an algorithm that gives higher accuracy and " "better commutativity on most builds." msgstr "" -#: ../../library/functions.rst:1961 +#: ../../library/functions.rst:1967 msgid "" "Return a proxy object that delegates method calls to a parent or sibling " "class of *type*. This is useful for accessing inherited methods that have " "been overridden in a class." msgstr "" -#: ../../library/functions.rst:1965 +#: ../../library/functions.rst:1971 msgid "" "The *object_or_type* determines the :term:`method resolution order` to be " "searched. The search starts from the class right after the *type*." msgstr "" -#: ../../library/functions.rst:1969 +#: ../../library/functions.rst:1975 msgid "" "For example, if :attr:`~type.__mro__` of *object_or_type* is ``D -> B -> C -" "> A -> object`` and the value of *type* is ``B``, then :func:`super` " "searches ``C -> A -> object``." msgstr "" -#: ../../library/functions.rst:1973 +#: ../../library/functions.rst:1979 msgid "" "The :attr:`~type.__mro__` attribute of the class corresponding to " "*object_or_type* lists the method resolution search order used by both :func:" @@ -3353,7 +3365,7 @@ msgid "" "whenever the inheritance hierarchy is updated." msgstr "" -#: ../../library/functions.rst:1978 +#: ../../library/functions.rst:1984 msgid "" "If the second argument is omitted, the super object returned is unbound. If " "the second argument is an object, ``isinstance(obj, type)`` must be true. " @@ -3361,7 +3373,7 @@ msgid "" "(this is useful for classmethods)." msgstr "" -#: ../../library/functions.rst:1983 +#: ../../library/functions.rst:1989 msgid "" "When called directly within an ordinary method of a class, both arguments " "may be omitted (\"zero-argument :func:`!super`\"). In this case, *type* will " @@ -3371,7 +3383,7 @@ msgid "" "including generator expressions, which implicitly create nested functions.)" msgstr "" -#: ../../library/functions.rst:1990 +#: ../../library/functions.rst:1996 msgid "" "There are two typical use cases for *super*. In a class hierarchy with " "single inheritance, *super* can be used to refer to parent classes without " @@ -3379,7 +3391,7 @@ msgid "" "closely parallels the use of *super* in other programming languages." msgstr "" -#: ../../library/functions.rst:1995 +#: ../../library/functions.rst:2001 msgid "" "The second use case is to support cooperative multiple inheritance in a " "dynamic execution environment. This use case is unique to Python and is not " @@ -3392,11 +3404,11 @@ msgid "" "classes that are unknown prior to runtime)." msgstr "" -#: ../../library/functions.rst:2005 +#: ../../library/functions.rst:2011 msgid "For both use cases, a typical superclass call looks like this::" msgstr "" -#: ../../library/functions.rst:2007 +#: ../../library/functions.rst:2013 msgid "" "class C(B):\n" " def method(self, arg):\n" @@ -3404,14 +3416,14 @@ msgid "" " # super(C, self).method(arg)" msgstr "" -#: ../../library/functions.rst:2012 +#: ../../library/functions.rst:2018 msgid "" "In addition to method lookups, :func:`super` also works for attribute " "lookups. One possible use case for this is calling :term:`descriptors " "` in a parent or sibling class." msgstr "" -#: ../../library/functions.rst:2016 +#: ../../library/functions.rst:2022 msgid "" "Note that :func:`super` is implemented as part of the binding process for " "explicit dotted attribute lookups such as ``super().__getitem__(name)``. It " @@ -3421,7 +3433,7 @@ msgid "" "using statements or operators such as ``super()[name]``." msgstr "" -#: ../../library/functions.rst:2024 +#: ../../library/functions.rst:2030 msgid "" "Also note that, aside from the zero argument form, :func:`super` is not " "limited to use inside methods. The two argument form specifies the " @@ -3431,33 +3443,33 @@ msgid "" "accessing the current instance for ordinary methods." msgstr "" -#: ../../library/functions.rst:2031 +#: ../../library/functions.rst:2037 msgid "" "For practical suggestions on how to design cooperative classes using :func:" "`super`, see `guide to using super() `_." msgstr "" -#: ../../library/functions.rst:2041 +#: ../../library/functions.rst:2047 msgid "" "Rather than being a function, :class:`tuple` is actually an immutable " "sequence type, as documented in :ref:`typesseq-tuple` and :ref:`typesseq`." msgstr "" -#: ../../library/functions.rst:2050 +#: ../../library/functions.rst:2056 msgid "" "With one argument, return the type of an *object*. The return value is a " "type object and generally the same object as returned by :attr:`object." "__class__`." msgstr "" -#: ../../library/functions.rst:2054 +#: ../../library/functions.rst:2060 msgid "" "The :func:`isinstance` built-in function is recommended for testing the type " "of an object, because it takes subclasses into account." msgstr "" -#: ../../library/functions.rst:2057 +#: ../../library/functions.rst:2063 msgid "" "With three arguments, return a new type object. This is essentially a " "dynamic form of the :keyword:`class` statement. The *name* string is the " @@ -3470,21 +3482,21 @@ msgid "" "type` objects:" msgstr "" -#: ../../library/functions.rst:2072 +#: ../../library/functions.rst:2078 msgid "See also:" msgstr "" -#: ../../library/functions.rst:2074 +#: ../../library/functions.rst:2080 msgid "" ":ref:`Documentation on attributes and methods on classes `." msgstr "" -#: ../../library/functions.rst:2075 +#: ../../library/functions.rst:2081 msgid ":ref:`bltin-type-objects`" msgstr ":ref:`bltin-type-objects`" -#: ../../library/functions.rst:2077 +#: ../../library/functions.rst:2083 msgid "" "Keyword arguments provided to the three argument form are passed to the " "appropriate metaclass machinery (usually :meth:`~object.__init_subclass__`) " @@ -3492,23 +3504,23 @@ msgid "" "would." msgstr "" -#: ../../library/functions.rst:2082 +#: ../../library/functions.rst:2088 msgid "See also :ref:`class-customization`." msgstr "另請參閱 :ref:`class-customization`。" -#: ../../library/functions.rst:2084 +#: ../../library/functions.rst:2090 msgid "" "Subclasses of :class:`!type` which don't override ``type.__new__`` may no " "longer use the one-argument form to get the type of an object." msgstr "" -#: ../../library/functions.rst:2091 +#: ../../library/functions.rst:2097 msgid "" "Return the :attr:`~object.__dict__` attribute for a module, class, instance, " "or any other object with a :attr:`!__dict__` attribute." msgstr "" -#: ../../library/functions.rst:2094 +#: ../../library/functions.rst:2100 msgid "" "Objects such as modules and instances have an updateable :attr:`~object." "__dict__` attribute; however, other objects may have write restrictions on " @@ -3516,34 +3528,34 @@ msgid "" "MappingProxyType` to prevent direct dictionary updates)." msgstr "" -#: ../../library/functions.rst:2099 +#: ../../library/functions.rst:2105 msgid "Without an argument, :func:`vars` acts like :func:`locals`." msgstr "" -#: ../../library/functions.rst:2101 +#: ../../library/functions.rst:2107 msgid "" "A :exc:`TypeError` exception is raised if an object is specified but it " "doesn't have a :attr:`~object.__dict__` attribute (for example, if its class " "defines the :attr:`~object.__slots__` attribute)." msgstr "" -#: ../../library/functions.rst:2107 +#: ../../library/functions.rst:2113 msgid "" "The result of calling this function without an argument has been updated as " "described for the :func:`locals` builtin." msgstr "" -#: ../../library/functions.rst:2113 +#: ../../library/functions.rst:2119 msgid "" "Iterate over several iterables in parallel, producing tuples with an item " "from each one." msgstr "" -#: ../../library/functions.rst:2116 +#: ../../library/functions.rst:2122 msgid "Example::" msgstr "例如: ::" -#: ../../library/functions.rst:2118 +#: ../../library/functions.rst:2124 msgid "" ">>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):\n" "... print(item)\n" @@ -3559,27 +3571,27 @@ msgstr "" "(2, 'spice')\n" "(3, 'everything nice')" -#: ../../library/functions.rst:2125 +#: ../../library/functions.rst:2131 msgid "" "More formally: :func:`zip` returns an iterator of tuples, where the *i*-th " "tuple contains the *i*-th element from each of the argument iterables." msgstr "" -#: ../../library/functions.rst:2128 +#: ../../library/functions.rst:2134 msgid "" "Another way to think of :func:`zip` is that it turns rows into columns, and " "columns into rows. This is similar to `transposing a matrix `_." msgstr "" -#: ../../library/functions.rst:2132 +#: ../../library/functions.rst:2138 msgid "" ":func:`zip` is lazy: The elements won't be processed until the iterable is " "iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a :class:" "`list`." msgstr "" -#: ../../library/functions.rst:2136 +#: ../../library/functions.rst:2142 msgid "" "One thing to consider is that the iterables passed to :func:`zip` could have " "different lengths; sometimes by design, and sometimes because of a bug in " @@ -3587,14 +3599,14 @@ msgid "" "approaches to dealing with this issue:" msgstr "" -#: ../../library/functions.rst:2141 +#: ../../library/functions.rst:2147 msgid "" "By default, :func:`zip` stops when the shortest iterable is exhausted. It " "will ignore the remaining items in the longer iterables, cutting off the " "result to the length of the shortest iterable::" msgstr "" -#: ../../library/functions.rst:2145 +#: ../../library/functions.rst:2151 msgid "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" @@ -3602,14 +3614,14 @@ msgstr "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" -#: ../../library/functions.rst:2148 +#: ../../library/functions.rst:2154 msgid "" ":func:`zip` is often used in cases where the iterables are assumed to be of " "equal length. In such cases, it's recommended to use the ``strict=True`` " "option. Its output is the same as regular :func:`zip`::" msgstr "" -#: ../../library/functions.rst:2152 +#: ../../library/functions.rst:2158 msgid "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" @@ -3617,37 +3629,37 @@ msgstr "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" -#: ../../library/functions.rst:2155 +#: ../../library/functions.rst:2161 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is exhausted before the others:" msgstr "" -#: ../../library/functions.rst:2173 +#: ../../library/functions.rst:2179 msgid "" "Without the ``strict=True`` argument, any bug that results in iterables of " "different lengths will be silenced, possibly manifesting as a hard-to-find " "bug in another part of the program." msgstr "" -#: ../../library/functions.rst:2177 +#: ../../library/functions.rst:2183 msgid "" "Shorter iterables can be padded with a constant value to make all the " "iterables have the same length. This is done by :func:`itertools." "zip_longest`." msgstr "" -#: ../../library/functions.rst:2181 +#: ../../library/functions.rst:2187 msgid "" "Edge cases: With a single iterable argument, :func:`zip` returns an iterator " "of 1-tuples. With no arguments, it returns an empty iterator." msgstr "" -#: ../../library/functions.rst:2184 +#: ../../library/functions.rst:2190 msgid "Tips and tricks:" msgstr "" -#: ../../library/functions.rst:2186 +#: ../../library/functions.rst:2192 msgid "" "The left-to-right evaluation order of the iterables is guaranteed. This " "makes possible an idiom for clustering a data series into n-length groups " @@ -3656,13 +3668,13 @@ msgid "" "iterator. This has the effect of dividing the input into n-length chunks." msgstr "" -#: ../../library/functions.rst:2192 +#: ../../library/functions.rst:2198 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" msgstr "" -#: ../../library/functions.rst:2195 +#: ../../library/functions.rst:2201 msgid "" ">>> x = [1, 2, 3]\n" ">>> y = [4, 5, 6]\n" @@ -3680,17 +3692,17 @@ msgstr "" ">>> x == list(x2) and y == list(y2)\n" "True" -#: ../../library/functions.rst:2203 +#: ../../library/functions.rst:2209 msgid "Added the ``strict`` argument." msgstr "增加了 ``strict`` 引數。" -#: ../../library/functions.rst:2215 +#: ../../library/functions.rst:2221 msgid "" "This is an advanced function that is not needed in everyday Python " "programming, unlike :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2218 +#: ../../library/functions.rst:2224 msgid "" "This function is invoked by the :keyword:`import` statement. It can be " "replaced (by importing the :mod:`builtins` module and assigning to " @@ -3702,7 +3714,7 @@ msgid "" "discouraged in favor of :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2227 +#: ../../library/functions.rst:2233 msgid "" "The function imports the module *name*, potentially using the given " "*globals* and *locals* to determine how to interpret the name in a package " @@ -3712,7 +3724,7 @@ msgid "" "determine the package context of the :keyword:`import` statement." msgstr "" -#: ../../library/functions.rst:2234 +#: ../../library/functions.rst:2240 msgid "" "*level* specifies whether to use absolute or relative imports. ``0`` (the " "default) means only perform absolute imports. Positive values for *level* " @@ -3721,7 +3733,7 @@ msgid "" "details)." msgstr "" -#: ../../library/functions.rst:2240 +#: ../../library/functions.rst:2246 msgid "" "When the *name* variable is of the form ``package.module``, normally, the " "top-level package (the name up till the first dot) is returned, *not* the " @@ -3729,37 +3741,37 @@ msgid "" "given, the module named by *name* is returned." msgstr "" -#: ../../library/functions.rst:2245 +#: ../../library/functions.rst:2251 msgid "" "For example, the statement ``import spam`` results in bytecode resembling " "the following code::" msgstr "" -#: ../../library/functions.rst:2248 +#: ../../library/functions.rst:2254 msgid "spam = __import__('spam', globals(), locals(), [], 0)" msgstr "spam = __import__('spam', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2250 +#: ../../library/functions.rst:2256 msgid "The statement ``import spam.ham`` results in this call::" msgstr "" -#: ../../library/functions.rst:2252 +#: ../../library/functions.rst:2258 msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" msgstr "spam = __import__('spam.ham', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2254 +#: ../../library/functions.rst:2260 msgid "" "Note how :func:`__import__` returns the toplevel module here because this is " "the object that is bound to a name by the :keyword:`import` statement." msgstr "" -#: ../../library/functions.rst:2257 +#: ../../library/functions.rst:2263 msgid "" "On the other hand, the statement ``from spam.ham import eggs, sausage as " "saus`` results in ::" msgstr "" -#: ../../library/functions.rst:2260 +#: ../../library/functions.rst:2266 msgid "" "_temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0)\n" "eggs = _temp.eggs\n" @@ -3769,36 +3781,36 @@ msgstr "" "eggs = _temp.eggs\n" "saus = _temp.sausage" -#: ../../library/functions.rst:2264 +#: ../../library/functions.rst:2270 msgid "" "Here, the ``spam.ham`` module is returned from :func:`__import__`. From " "this object, the names to import are retrieved and assigned to their " "respective names." msgstr "" -#: ../../library/functions.rst:2268 +#: ../../library/functions.rst:2274 msgid "" "If you simply want to import a module (potentially within a package) by " "name, use :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2271 +#: ../../library/functions.rst:2277 msgid "" "Negative values for *level* are no longer supported (which also changes the " "default value to 0)." msgstr "" -#: ../../library/functions.rst:2275 +#: ../../library/functions.rst:2281 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." msgstr "" -#: ../../library/functions.rst:2280 +#: ../../library/functions.rst:2286 msgid "Footnotes" msgstr "註解" -#: ../../library/functions.rst:2281 +#: ../../library/functions.rst:2287 msgid "" "Note that the parser only accepts the Unix-style end of line convention. If " "you are reading the code from a file, make sure to use newline conversion " @@ -3811,7 +3823,7 @@ msgstr "" msgid "Boolean" msgstr "Boolean(布林值)" -#: ../../library/functions.rst:154 ../../library/functions.rst:2048 +#: ../../library/functions.rst:154 ../../library/functions.rst:2054 msgid "type" msgstr "type(型別)" @@ -3835,7 +3847,7 @@ msgstr "Infinity(無窮)" msgid "__format__" msgstr "__format__" -#: ../../library/functions.rst:814 ../../library/functions.rst:1925 +#: ../../library/functions.rst:814 ../../library/functions.rst:1931 msgid "string" msgstr "string(字串)" @@ -3887,7 +3899,7 @@ msgstr "buffering(緩衝)" msgid "text mode" msgstr "text mode(文字模式)" -#: ../../library/functions.rst:1507 ../../library/functions.rst:2209 +#: ../../library/functions.rst:1507 ../../library/functions.rst:2215 msgid "module" msgstr "module(模組)" @@ -3895,22 +3907,22 @@ msgstr "module(模組)" msgid "sys" msgstr "sys" -#: ../../library/functions.rst:1925 +#: ../../library/functions.rst:1931 msgid "str() (built-in function)" msgstr "str() (內建函式)" -#: ../../library/functions.rst:2048 +#: ../../library/functions.rst:2054 msgid "object" msgstr "object(物件)" -#: ../../library/functions.rst:2209 +#: ../../library/functions.rst:2215 msgid "statement" msgstr "statement(陳述式)" -#: ../../library/functions.rst:2209 +#: ../../library/functions.rst:2215 msgid "import" msgstr "import(引入)" -#: ../../library/functions.rst:2209 +#: ../../library/functions.rst:2215 msgid "builtins" msgstr "builtins(內建)" diff --git a/library/locale.po b/library/locale.po index edd5415af8..afdb048b04 100644 --- a/library/locale.po +++ b/library/locale.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-22 00:14+0000\n" +"POT-Creation-Date: 2025-08-14 00:16+0000\n" "PO-Revision-Date: 2018-05-23 16:05+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -53,27 +53,33 @@ msgstr "" msgid "" "If *locale* is given and not ``None``, :func:`setlocale` modifies the locale " "setting for the *category*. The available categories are listed in the data " -"description below. *locale* may be a string, or an iterable of two strings " -"(language code and encoding). If it's an iterable, it's converted to a " -"locale name using the locale aliasing engine. An empty string specifies the " -"user's default settings. If the modification of the locale fails, the " -"exception :exc:`Error` is raised. If successful, the new locale setting is " -"returned." +"description below. *locale* may be a :ref:`string `, or a pair, " +"language code and encoding. An empty string specifies the user's default " +"settings. If the modification of the locale fails, the exception :exc:" +"`Error` is raised. If successful, the new locale setting is returned." +msgstr "" + +#: ../../library/locale.rst:42 +msgid "" +"If *locale* is a pair, it is converted to a locale name using the locale " +"aliasing engine. The language code has the same format as a :ref:`locale " +"name `, but without encoding and ``@``-modifier. The language " +"code and encoding can be ``None``." msgstr "" -#: ../../library/locale.rst:43 +#: ../../library/locale.rst:48 msgid "" "If *locale* is omitted or ``None``, the current setting for *category* is " "returned." msgstr "" -#: ../../library/locale.rst:46 +#: ../../library/locale.rst:51 msgid "" ":func:`setlocale` is not thread-safe on most systems. Applications typically " "start with a call of ::" msgstr "" -#: ../../library/locale.rst:49 +#: ../../library/locale.rst:54 msgid "" "import locale\n" "locale.setlocale(locale.LC_ALL, '')" @@ -81,7 +87,7 @@ msgstr "" "import locale\n" "locale.setlocale(locale.LC_ALL, '')" -#: ../../library/locale.rst:52 +#: ../../library/locale.rst:57 msgid "" "This sets the locale for all categories to the user's default setting " "(typically specified in the :envvar:`LANG` environment variable). If the " @@ -89,41 +95,41 @@ msgid "" "problems." msgstr "" -#: ../../library/locale.rst:59 +#: ../../library/locale.rst:64 msgid "" "Returns the database of the local conventions as a dictionary. This " "dictionary has the following strings as keys:" msgstr "" -#: ../../library/locale.rst:65 +#: ../../library/locale.rst:70 msgid "Category" msgstr "分類" -#: ../../library/locale.rst:65 +#: ../../library/locale.rst:70 msgid "Key" msgstr "" -#: ../../library/locale.rst:65 +#: ../../library/locale.rst:70 msgid "Meaning" msgstr "含義" -#: ../../library/locale.rst:67 +#: ../../library/locale.rst:72 msgid ":const:`LC_NUMERIC`" msgstr ":const:`LC_NUMERIC`" -#: ../../library/locale.rst:67 +#: ../../library/locale.rst:72 msgid "``'decimal_point'``" msgstr "``'decimal_point'``" -#: ../../library/locale.rst:67 +#: ../../library/locale.rst:72 msgid "Decimal point character." msgstr "" -#: ../../library/locale.rst:69 +#: ../../library/locale.rst:74 msgid "``'grouping'``" msgstr "``'grouping'``" -#: ../../library/locale.rst:69 +#: ../../library/locale.rst:74 msgid "" "Sequence of numbers specifying which relative positions the " "``'thousands_sep'`` is expected. If the sequence is terminated with :const:" @@ -131,204 +137,204 @@ msgid "" "with a ``0``, the last group size is repeatedly used." msgstr "" -#: ../../library/locale.rst:80 +#: ../../library/locale.rst:85 msgid "``'thousands_sep'``" msgstr "``'thousands_sep'``" -#: ../../library/locale.rst:80 +#: ../../library/locale.rst:85 msgid "Character used between groups." msgstr "" -#: ../../library/locale.rst:82 +#: ../../library/locale.rst:87 msgid ":const:`LC_MONETARY`" msgstr ":const:`LC_MONETARY`" -#: ../../library/locale.rst:82 +#: ../../library/locale.rst:87 msgid "``'int_curr_symbol'``" msgstr "``'int_curr_symbol'``" -#: ../../library/locale.rst:82 +#: ../../library/locale.rst:87 msgid "International currency symbol." msgstr "" -#: ../../library/locale.rst:84 +#: ../../library/locale.rst:89 msgid "``'currency_symbol'``" msgstr "``'currency_symbol'``" -#: ../../library/locale.rst:84 +#: ../../library/locale.rst:89 msgid "Local currency symbol." msgstr "" -#: ../../library/locale.rst:86 +#: ../../library/locale.rst:91 msgid "``'p_cs_precedes/n_cs_precedes'``" msgstr "``'p_cs_precedes/n_cs_precedes'``" -#: ../../library/locale.rst:86 +#: ../../library/locale.rst:91 msgid "" "Whether the currency symbol precedes the value (for positive resp. negative " "values)." msgstr "" -#: ../../library/locale.rst:91 +#: ../../library/locale.rst:96 msgid "``'p_sep_by_space/n_sep_by_space'``" msgstr "``'p_sep_by_space/n_sep_by_space'``" -#: ../../library/locale.rst:91 +#: ../../library/locale.rst:96 msgid "" "Whether the currency symbol is separated from the value by a space (for " "positive resp. negative values)." msgstr "" -#: ../../library/locale.rst:96 +#: ../../library/locale.rst:101 msgid "``'mon_decimal_point'``" msgstr "``'mon_decimal_point'``" -#: ../../library/locale.rst:96 +#: ../../library/locale.rst:101 msgid "Decimal point used for monetary values." msgstr "" -#: ../../library/locale.rst:99 +#: ../../library/locale.rst:104 msgid "``'frac_digits'``" msgstr "``'frac_digits'``" -#: ../../library/locale.rst:99 +#: ../../library/locale.rst:104 msgid "" "Number of fractional digits used in local formatting of monetary values." msgstr "" -#: ../../library/locale.rst:103 +#: ../../library/locale.rst:108 msgid "``'int_frac_digits'``" msgstr "``'int_frac_digits'``" -#: ../../library/locale.rst:103 +#: ../../library/locale.rst:108 msgid "" "Number of fractional digits used in international formatting of monetary " "values." msgstr "" -#: ../../library/locale.rst:107 +#: ../../library/locale.rst:112 msgid "``'mon_thousands_sep'``" msgstr "``'mon_thousands_sep'``" -#: ../../library/locale.rst:107 +#: ../../library/locale.rst:112 msgid "Group separator used for monetary values." msgstr "" -#: ../../library/locale.rst:110 +#: ../../library/locale.rst:115 msgid "``'mon_grouping'``" msgstr "``'mon_grouping'``" -#: ../../library/locale.rst:110 +#: ../../library/locale.rst:115 msgid "Equivalent to ``'grouping'``, used for monetary values." msgstr "" -#: ../../library/locale.rst:113 +#: ../../library/locale.rst:118 msgid "``'positive_sign'``" msgstr "``'positive_sign'``" -#: ../../library/locale.rst:113 +#: ../../library/locale.rst:118 msgid "Symbol used to annotate a positive monetary value." msgstr "" -#: ../../library/locale.rst:116 +#: ../../library/locale.rst:121 msgid "``'negative_sign'``" msgstr "``'negative_sign'``" -#: ../../library/locale.rst:116 +#: ../../library/locale.rst:121 msgid "Symbol used to annotate a negative monetary value." msgstr "" -#: ../../library/locale.rst:119 +#: ../../library/locale.rst:124 msgid "``'p_sign_posn/n_sign_posn'``" msgstr "``'p_sign_posn/n_sign_posn'``" -#: ../../library/locale.rst:119 +#: ../../library/locale.rst:124 msgid "" "The position of the sign (for positive resp. negative values), see below." msgstr "" -#: ../../library/locale.rst:124 +#: ../../library/locale.rst:129 msgid "" "All numeric values can be set to :const:`CHAR_MAX` to indicate that there is " "no value specified in this locale." msgstr "" -#: ../../library/locale.rst:127 +#: ../../library/locale.rst:132 msgid "" "The possible values for ``'p_sign_posn'`` and ``'n_sign_posn'`` are given " "below." msgstr "" -#: ../../library/locale.rst:130 +#: ../../library/locale.rst:135 msgid "Value" msgstr "" -#: ../../library/locale.rst:130 +#: ../../library/locale.rst:135 msgid "Explanation" msgstr "" -#: ../../library/locale.rst:132 +#: ../../library/locale.rst:137 msgid "``0``" msgstr "``0``" -#: ../../library/locale.rst:132 +#: ../../library/locale.rst:137 msgid "Currency and value are surrounded by parentheses." msgstr "" -#: ../../library/locale.rst:135 +#: ../../library/locale.rst:140 msgid "``1``" msgstr "``1``" -#: ../../library/locale.rst:135 +#: ../../library/locale.rst:140 msgid "The sign should precede the value and currency symbol." msgstr "" -#: ../../library/locale.rst:138 +#: ../../library/locale.rst:143 msgid "``2``" msgstr "``2``" -#: ../../library/locale.rst:138 +#: ../../library/locale.rst:143 msgid "The sign should follow the value and currency symbol." msgstr "" -#: ../../library/locale.rst:141 +#: ../../library/locale.rst:146 msgid "``3``" msgstr "``3``" -#: ../../library/locale.rst:141 +#: ../../library/locale.rst:146 msgid "The sign should immediately precede the value." msgstr "" -#: ../../library/locale.rst:144 +#: ../../library/locale.rst:149 msgid "``4``" msgstr "``4``" -#: ../../library/locale.rst:144 +#: ../../library/locale.rst:149 msgid "The sign should immediately follow the value." msgstr "" -#: ../../library/locale.rst:147 +#: ../../library/locale.rst:152 msgid "``CHAR_MAX``" msgstr "``CHAR_MAX``" -#: ../../library/locale.rst:147 +#: ../../library/locale.rst:152 msgid "Nothing is specified in this locale." msgstr "" -#: ../../library/locale.rst:150 +#: ../../library/locale.rst:155 msgid "" "The function temporarily sets the ``LC_CTYPE`` locale to the ``LC_NUMERIC`` " "locale or the ``LC_MONETARY`` locale if locales are different and numeric or " "monetary strings are non-ASCII. This temporary change affects other threads." msgstr "" -#: ../../library/locale.rst:154 +#: ../../library/locale.rst:159 msgid "" "The function now temporarily sets the ``LC_CTYPE`` locale to the " "``LC_NUMERIC`` locale in some cases." msgstr "" -#: ../../library/locale.rst:161 +#: ../../library/locale.rst:166 msgid "" "Return some locale-specific information as a string. This function is not " "available on all systems, and the set of possible options might also vary " @@ -336,106 +342,106 @@ msgid "" "symbolic constants are available in the locale module." msgstr "" -#: ../../library/locale.rst:166 +#: ../../library/locale.rst:171 msgid "" "The :func:`nl_langinfo` function accepts one of the following keys. Most " "descriptions are taken from the corresponding description in the GNU C " "library." msgstr "" -#: ../../library/locale.rst:172 +#: ../../library/locale.rst:177 msgid "" "Get a string with the name of the character encoding used in the selected " "locale." msgstr "" -#: ../../library/locale.rst:177 +#: ../../library/locale.rst:182 msgid "" "Get a string that can be used as a format string for :func:`time.strftime` " "to represent date and time in a locale-specific way." msgstr "" -#: ../../library/locale.rst:182 +#: ../../library/locale.rst:187 msgid "" "Get a string that can be used as a format string for :func:`time.strftime` " "to represent a date in a locale-specific way." msgstr "" -#: ../../library/locale.rst:187 +#: ../../library/locale.rst:192 msgid "" "Get a string that can be used as a format string for :func:`time.strftime` " "to represent a time in a locale-specific way." msgstr "" -#: ../../library/locale.rst:192 +#: ../../library/locale.rst:197 msgid "" "Get a format string for :func:`time.strftime` to represent time in the am/pm " "format." msgstr "" -#: ../../library/locale.rst:203 +#: ../../library/locale.rst:208 msgid "Get the name of the n-th day of the week." msgstr "" -#: ../../library/locale.rst:207 +#: ../../library/locale.rst:212 msgid "" "This follows the US convention of :const:`DAY_1` being Sunday, not the " "international convention (ISO 8601) that Monday is the first day of the week." msgstr "" -#: ../../library/locale.rst:219 +#: ../../library/locale.rst:224 msgid "Get the abbreviated name of the n-th day of the week." msgstr "" -#: ../../library/locale.rst:234 +#: ../../library/locale.rst:239 msgid "Get the name of the n-th month." msgstr "" -#: ../../library/locale.rst:249 +#: ../../library/locale.rst:254 msgid "Get the abbreviated name of the n-th month." msgstr "" -#: ../../library/locale.rst:253 +#: ../../library/locale.rst:258 msgid "Get the radix character (decimal dot, decimal comma, etc.)." msgstr "" -#: ../../library/locale.rst:257 +#: ../../library/locale.rst:262 msgid "Get the separator character for thousands (groups of three digits)." msgstr "" -#: ../../library/locale.rst:261 +#: ../../library/locale.rst:266 msgid "" "Get a regular expression that can be used with the regex function to " "recognize a positive response to a yes/no question." msgstr "" -#: ../../library/locale.rst:266 +#: ../../library/locale.rst:271 msgid "" "Get a regular expression that can be used with the ``regex(3)`` function to " "recognize a negative response to a yes/no question." msgstr "" -#: ../../library/locale.rst:271 +#: ../../library/locale.rst:276 msgid "" "The regular expressions for :const:`YESEXPR` and :const:`NOEXPR` use syntax " "suitable for the ``regex`` function from the C library, which might differ " "from the syntax used in :mod:`re`." msgstr "" -#: ../../library/locale.rst:278 +#: ../../library/locale.rst:283 msgid "" "Get the currency symbol, preceded by \"-\" if the symbol should appear " "before the value, \"+\" if the symbol should appear after the value, or \"." "\" if the symbol should replace the radix character." msgstr "" -#: ../../library/locale.rst:284 +#: ../../library/locale.rst:289 msgid "" "Get a string which describes how years are counted and displayed for each " "era in a locale." msgstr "" -#: ../../library/locale.rst:287 +#: ../../library/locale.rst:292 msgid "" "Most locales do not define this value. An example of a locale which does " "define this value is the Japanese one. In Japan, the traditional " @@ -443,7 +449,7 @@ msgid "" "then-emperor's reign." msgstr "" -#: ../../library/locale.rst:292 +#: ../../library/locale.rst:297 msgid "" "Normally it should not be necessary to use this value directly. Specifying " "the ``E`` modifier in their format strings causes the :func:`time.strftime` " @@ -453,38 +459,38 @@ msgid "" "onlinepubs/9799919799/basedefs/V1_chap07.html#tag_07_03_05_02>`_." msgstr "" -#: ../../library/locale.rst:301 +#: ../../library/locale.rst:306 msgid "" "Get a format string for :func:`time.strftime` to represent date and time in " "a locale-specific era-based way." msgstr "" -#: ../../library/locale.rst:306 +#: ../../library/locale.rst:311 msgid "" "Get a format string for :func:`time.strftime` to represent a date in a " "locale-specific era-based way." msgstr "" -#: ../../library/locale.rst:311 +#: ../../library/locale.rst:316 msgid "" "Get a format string for :func:`time.strftime` to represent a time in a " "locale-specific era-based way." msgstr "" -#: ../../library/locale.rst:316 +#: ../../library/locale.rst:321 msgid "" "Get a string consisting of up to 100 semicolon-separated symbols used to " "represent the values 0 to 99 in a locale-specific way. In most locales this " "is an empty string." msgstr "" -#: ../../library/locale.rst:323 +#: ../../library/locale.rst:328 msgid "" "Tries to determine the default locale settings and returns them as a tuple " "of the form ``(language code, encoding)``." msgstr "" -#: ../../library/locale.rst:326 +#: ../../library/locale.rst:331 msgid "" "According to POSIX, a program which has not called ``setlocale(LC_ALL, '')`` " "runs using the portable ``'C'`` locale. Calling ``setlocale(LC_ALL, '')`` " @@ -493,7 +499,7 @@ msgid "" "emulate the behavior in the way described above." msgstr "" -#: ../../library/locale.rst:332 +#: ../../library/locale.rst:337 msgid "" "To maintain compatibility with other platforms, not only the :envvar:`LANG` " "variable is tested, but a list of variables given as envvars parameter. The " @@ -503,21 +509,23 @@ msgid "" "``'LC_CTYPE'``, ``'LANG'`` and ``'LANGUAGE'``, in that order." msgstr "" -#: ../../library/locale.rst:339 ../../library/locale.rst:352 +#: ../../library/locale.rst:344 ../../library/locale.rst:359 msgid "" -"Except for the code ``'C'``, the language code corresponds to :rfc:`1766`. " -"*language code* and *encoding* may be ``None`` if their values cannot be " -"determined." +"The language code has the same format as a :ref:`locale name `, " +"but without encoding and ``@``-modifier. The language code and encoding may " +"be ``None`` if their values cannot be determined. The \"C\" locale is " +"represented as ``(None, None)``." msgstr "" -#: ../../library/locale.rst:348 +#: ../../library/locale.rst:355 msgid "" -"Returns the current setting for the given locale category as sequence " -"containing *language code*, *encoding*. *category* may be one of the :const:" -"`!LC_\\*` values except :const:`LC_ALL`. It defaults to :const:`LC_CTYPE`." +"Returns the current setting for the given locale category as a tuple " +"containing the language code and encoding. *category* may be one of the :" +"const:`!LC_\\*` values except :const:`LC_ALL`. It defaults to :const:" +"`LC_CTYPE`." msgstr "" -#: ../../library/locale.rst:359 +#: ../../library/locale.rst:368 msgid "" "Return the :term:`locale encoding` used for text data, according to user " "preferences. User preferences are expressed differently on different " @@ -525,72 +533,72 @@ msgid "" "this function only returns a guess." msgstr "" -#: ../../library/locale.rst:364 +#: ../../library/locale.rst:373 msgid "" "On some systems, it is necessary to invoke :func:`setlocale` to obtain the " "user preferences, so this function is not thread-safe. If invoking setlocale " "is not necessary or desired, *do_setlocale* should be set to ``False``." msgstr "" -#: ../../library/locale.rst:368 +#: ../../library/locale.rst:377 msgid "" "On Android or if the :ref:`Python UTF-8 Mode ` is enabled, always " "return ``'utf-8'``, the :term:`locale encoding` and the *do_setlocale* " "argument are ignored." msgstr "" -#: ../../library/locale.rst:372 ../../library/locale.rst:390 +#: ../../library/locale.rst:381 ../../library/locale.rst:399 msgid "" "The :ref:`Python preinitialization ` configures the LC_CTYPE " "locale. See also the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../library/locale.rst:375 +#: ../../library/locale.rst:384 msgid "" "The function now always returns ``\"utf-8\"`` on Android or if the :ref:" "`Python UTF-8 Mode ` is enabled." msgstr "" -#: ../../library/locale.rst:382 +#: ../../library/locale.rst:391 msgid "Get the current :term:`locale encoding`:" msgstr "" -#: ../../library/locale.rst:384 +#: ../../library/locale.rst:393 msgid "On Android and VxWorks, return ``\"utf-8\"``." msgstr "" -#: ../../library/locale.rst:385 +#: ../../library/locale.rst:394 msgid "" "On Unix, return the encoding of the current :data:`LC_CTYPE` locale. Return " "``\"utf-8\"`` if ``nl_langinfo(CODESET)`` returns an empty string: for " "example, if the current LC_CTYPE locale is not supported." msgstr "" -#: ../../library/locale.rst:388 +#: ../../library/locale.rst:397 msgid "On Windows, return the ANSI code page." msgstr "" -#: ../../library/locale.rst:393 +#: ../../library/locale.rst:402 msgid "" "This function is similar to :func:`getpreferredencoding(False) " "` except this function ignores the :ref:`Python UTF-8 " "Mode `." msgstr "" -#: ../../library/locale.rst:402 +#: ../../library/locale.rst:411 msgid "" "Returns a normalized locale code for the given locale name. The returned " "locale code is formatted for use with :func:`setlocale`. If normalization " "fails, the original name is returned unchanged." msgstr "" -#: ../../library/locale.rst:406 +#: ../../library/locale.rst:415 msgid "" "If the given encoding is not known, the function defaults to the default " "encoding for the locale code just like :func:`setlocale`." msgstr "" -#: ../../library/locale.rst:412 +#: ../../library/locale.rst:421 msgid "" "Compares two strings according to the current :const:`LC_COLLATE` setting. " "As any other compare function, returns a negative, or a positive value, or " @@ -598,7 +606,7 @@ msgid "" "is equal to it." msgstr "" -#: ../../library/locale.rst:420 +#: ../../library/locale.rst:429 msgid "" "Transforms a string to one that can be used in locale-aware comparisons. " "For example, ``strxfrm(s1) < strxfrm(s2)`` is equivalent to ``strcoll(s1, " @@ -606,7 +614,7 @@ msgid "" "repeatedly, e.g. when collating a sequence of strings." msgstr "" -#: ../../library/locale.rst:429 +#: ../../library/locale.rst:438 msgid "" "Formats a number *val* according to the current :const:`LC_NUMERIC` setting. " "The format follows the conventions of the ``%`` operator. For floating-" @@ -614,29 +622,29 @@ msgid "" "is ``True``, also takes the grouping into account." msgstr "" -#: ../../library/locale.rst:434 +#: ../../library/locale.rst:443 msgid "" "If *monetary* is true, the conversion uses monetary thousands separator and " "grouping strings." msgstr "" -#: ../../library/locale.rst:437 +#: ../../library/locale.rst:446 msgid "" "Processes formatting specifiers as in ``format % val``, but takes the " "current locale settings into account." msgstr "" -#: ../../library/locale.rst:440 +#: ../../library/locale.rst:449 msgid "The *monetary* keyword parameter was added." msgstr "" -#: ../../library/locale.rst:446 +#: ../../library/locale.rst:455 msgid "" "Formats a number *val* according to the current :const:`LC_MONETARY` " "settings." msgstr "" -#: ../../library/locale.rst:448 +#: ../../library/locale.rst:457 msgid "" "The returned string includes the currency symbol if *symbol* is true, which " "is the default. If *grouping* is ``True`` (which is not the default), " @@ -644,43 +652,43 @@ msgid "" "not the default), the international currency symbol is used." msgstr "" -#: ../../library/locale.rst:455 +#: ../../library/locale.rst:464 msgid "" "This function will not work with the 'C' locale, so you have to set a locale " "via :func:`setlocale` first." msgstr "" -#: ../../library/locale.rst:461 +#: ../../library/locale.rst:470 msgid "" "Formats a floating-point number using the same format as the built-in " "function ``str(float)``, but takes the decimal point into account." msgstr "" -#: ../../library/locale.rst:467 +#: ../../library/locale.rst:476 msgid "" "Converts a string into a normalized number string, following the :const:" "`LC_NUMERIC` settings." msgstr "" -#: ../../library/locale.rst:475 +#: ../../library/locale.rst:484 msgid "" "Converts a normalized number string into a formatted string following the :" "const:`LC_NUMERIC` settings." msgstr "" -#: ../../library/locale.rst:483 +#: ../../library/locale.rst:492 msgid "" "Converts a string to a number, following the :const:`LC_NUMERIC` settings, " "by calling *func* on the result of calling :func:`delocalize` on *string*." msgstr "" -#: ../../library/locale.rst:489 +#: ../../library/locale.rst:498 msgid "" "Converts a string to an integer, following the :const:`LC_NUMERIC` " "conventions." msgstr "" -#: ../../library/locale.rst:494 +#: ../../library/locale.rst:503 msgid "" "Locale category for the character type functions. Most importantly, this " "category defines the text encoding, i.e. how bytes are interpreted as " @@ -690,32 +698,32 @@ msgid "" "SSH connections." msgstr "" -#: ../../library/locale.rst:501 +#: ../../library/locale.rst:510 msgid "" "Python doesn't internally use locale-dependent character transformation " "functions from ``ctype.h``. Instead, an internal ``pyctype.h`` provides " "locale-independent equivalents like :c:macro:`!Py_TOLOWER`." msgstr "" -#: ../../library/locale.rst:508 +#: ../../library/locale.rst:517 msgid "" "Locale category for sorting strings. The functions :func:`strcoll` and :" "func:`strxfrm` of the :mod:`locale` module are affected." msgstr "" -#: ../../library/locale.rst:514 +#: ../../library/locale.rst:523 msgid "" "Locale category for the formatting of time. The function :func:`time." "strftime` follows these conventions." msgstr "" -#: ../../library/locale.rst:520 +#: ../../library/locale.rst:529 msgid "" "Locale category for formatting of monetary values. The available options " "are available from the :func:`localeconv` function." msgstr "" -#: ../../library/locale.rst:526 +#: ../../library/locale.rst:535 msgid "" "Locale category for message display. Python currently does not support " "application specific locale-aware messages. Messages displayed by the " @@ -723,13 +731,13 @@ msgid "" "affected by this category." msgstr "" -#: ../../library/locale.rst:531 +#: ../../library/locale.rst:540 msgid "" "This value may not be available on operating systems not conforming to the " "POSIX standard, most notably Windows." msgstr "" -#: ../../library/locale.rst:537 +#: ../../library/locale.rst:546 msgid "" "Locale category for formatting numbers. The functions :func:" "`format_string`, :func:`atoi`, :func:`atof` and :func:`.str` of the :mod:" @@ -737,7 +745,7 @@ msgid "" "operations are not affected." msgstr "" -#: ../../library/locale.rst:545 +#: ../../library/locale.rst:554 msgid "" "Combination of all locale settings. If this flag is used when the locale is " "changed, setting the locale for all categories is attempted. If that fails " @@ -747,17 +755,17 @@ msgid "" "settings." msgstr "" -#: ../../library/locale.rst:554 +#: ../../library/locale.rst:563 msgid "" "This is a symbolic constant used for different values returned by :func:" "`localeconv`." msgstr "" -#: ../../library/locale.rst:558 +#: ../../library/locale.rst:567 msgid "Example::" msgstr "範例: ::" -#: ../../library/locale.rst:560 +#: ../../library/locale.rst:569 msgid "" ">>> import locale\n" ">>> loc = locale.getlocale() # get current locale\n" @@ -770,11 +778,11 @@ msgid "" ">>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale" msgstr "" -#: ../../library/locale.rst:571 +#: ../../library/locale.rst:580 msgid "Background, details, hints, tips and caveats" msgstr "" -#: ../../library/locale.rst:573 +#: ../../library/locale.rst:582 msgid "" "The C standard defines the locale as a program-wide property that may be " "relatively expensive to change. On top of that, some implementations are " @@ -782,7 +790,7 @@ msgid "" "This makes the locale somewhat painful to use correctly." msgstr "" -#: ../../library/locale.rst:578 +#: ../../library/locale.rst:587 msgid "" "Initially, when a program is started, the locale is the ``C`` locale, no " "matter what the user's preferred locale is. There is one exception: the :" @@ -792,7 +800,7 @@ msgid "" "categories by calling ``setlocale(LC_ALL, '')``." msgstr "" -#: ../../library/locale.rst:585 +#: ../../library/locale.rst:594 msgid "" "It is generally a bad idea to call :func:`setlocale` in some library " "routine, since as a side effect it affects the entire program. Saving and " @@ -800,7 +808,7 @@ msgid "" "that happen to run before the settings have been restored." msgstr "" -#: ../../library/locale.rst:590 +#: ../../library/locale.rst:599 msgid "" "If, when coding a module for general use, you need a locale independent " "version of an operation that is affected by the locale (such as certain " @@ -811,14 +819,14 @@ msgid "" "settings." msgstr "" -#: ../../library/locale.rst:597 +#: ../../library/locale.rst:606 msgid "" "The only way to perform numeric operations according to the locale is to use " "the special functions defined by this module: :func:`atof`, :func:`atoi`, :" "func:`format_string`, :func:`.str`." msgstr "" -#: ../../library/locale.rst:601 +#: ../../library/locale.rst:610 msgid "" "There is no way to perform case conversions and character classifications " "according to the locale. For (Unicode) text strings these are done " @@ -829,11 +837,85 @@ msgid "" "whitespace." msgstr "" -#: ../../library/locale.rst:612 +#: ../../library/locale.rst:621 +msgid "Locale names" +msgstr "" + +#: ../../library/locale.rst:623 +msgid "" +"The format of the locale name is platform dependent, and the set of " +"supported locales can depend on the system configuration." +msgstr "" + +#: ../../library/locale.rst:626 +msgid "On Posix platforms, it usually has the format [1]_:" +msgstr "" + +#: ../../library/locale.rst:631 +msgid "" +"where *language* is a two- or three-letter language code from `ISO 639`_, " +"*territory* is a two-letter country or region code from `ISO 3166`_, " +"*charset* is a locale encoding, and *modifier* is a script name, a language " +"subtag, a sort order identifier, or other locale modifier (for example, " +"\"latin\", \"valencia\", \"stroke\" and \"euro\")." +msgstr "" + +#: ../../library/locale.rst:637 +msgid "" +"On Windows, several formats are supported. [2]_ [3]_ A subset of `IETF BCP " +"47`_ tags:" +msgstr "" + +#: ../../library/locale.rst:644 +msgid "" +"where *language* and *territory* have the same meaning as in Posix, *script* " +"is a four-letter script code from `ISO 15924`_, and *modifier* is a language " +"subtag, a sort order identifier or custom modifier (for example, " +"\"valencia\", \"stroke\" or \"x-python\"). Both hyphen (``'-'``) and " +"underscore (``'_'``) separators are supported. Only UTF-8 encoding is " +"allowed for BCP 47 tags." +msgstr "" + +#: ../../library/locale.rst:651 +msgid "Windows also supports locale names in the format:" +msgstr "" + +#: ../../library/locale.rst:656 +msgid "" +"where *language* and *territory* are full names, such as \"English\" and " +"\"United States\", and *charset* is either a code page number (for example, " +"\"1252\") or UTF-8. Only the underscore separator is supported in this " +"format." +msgstr "" + +#: ../../library/locale.rst:661 +msgid "The \"C\" locale is supported on all platforms." +msgstr "" + +#: ../../library/locale.rst:668 +msgid "" +"`IEEE Std 1003.1-2024; 8.2 Internationalization Variables `_" +msgstr "" + +#: ../../library/locale.rst:669 +msgid "" +"`UCRT Locale names, Languages, and Country/Region strings `_" +msgstr "" + +#: ../../library/locale.rst:670 +msgid "" +"`Locale Names `_" +msgstr "" + +#: ../../library/locale.rst:676 msgid "For extension writers and programs that embed Python" msgstr "" -#: ../../library/locale.rst:614 +#: ../../library/locale.rst:678 msgid "" "Extension modules should never call :func:`setlocale`, except to find out " "what the current locale is. But since the return value can only be used " @@ -841,7 +923,7 @@ msgid "" "whether or not the locale is ``C``)." msgstr "" -#: ../../library/locale.rst:619 +#: ../../library/locale.rst:683 msgid "" "When Python code uses the :mod:`locale` module to change the locale, this " "also affects the embedding application. If the embedding application " @@ -851,11 +933,11 @@ msgid "" "accessible as a shared library." msgstr "" -#: ../../library/locale.rst:630 +#: ../../library/locale.rst:694 msgid "Access to message catalogs" msgstr "" -#: ../../library/locale.rst:639 +#: ../../library/locale.rst:703 msgid "" "The locale module exposes the C library's gettext interface on systems that " "provide this interface. It consists of the functions :func:`gettext`, :func:" @@ -866,7 +948,7 @@ msgid "" "locating message catalogs." msgstr "" -#: ../../library/locale.rst:646 +#: ../../library/locale.rst:710 msgid "" "Python applications should normally find no need to invoke these functions, " "and should use :mod:`gettext` instead. A known exception to this rule are " From 692b4a267ce0e58ea399328ff85c1523ec2501ec Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 15 Aug 2025 00:19:11 +0000 Subject: [PATCH 14/23] sync with cpython 785b3967 --- tutorial/appendix.po | 59 ++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/tutorial/appendix.po b/tutorial/appendix.po index 7c12f8650b..6ffe2d7d8a 100644 --- a/tutorial/appendix.po +++ b/tutorial/appendix.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-17 00:13+0000\n" +"POT-Creation-Date: 2025-08-15 00:17+0000\n" "PO-Revision-Date: 2025-07-13 14:05+0800\n" "Last-Translator: Weilin Du <1372449351@qq.com>\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -39,12 +39,13 @@ msgstr "" "限度的行控制能力(line control capabilities)。" #: ../../tutorial/appendix.rst:17 +#, fuzzy msgid "" "On Windows, or Unix-like systems with :mod:`curses` support, a new " -"interactive shell is used by default. This one supports color, multiline " -"editing, history browsing, and paste mode. To disable color, " -"see :ref:`using-on-controlling-color` for details. Function keys provide " -"some additional functionality. :kbd:`F1` enters the interactive help " +"interactive shell is used by default since Python 3.13. This one supports " +"color, multiline editing, history browsing, and paste mode. To disable " +"color, see :ref:`using-on-controlling-color` for details. Function keys " +"provide some additional functionality. :kbd:`F1` enters the interactive help " "browser :mod:`pydoc`. :kbd:`F2` allows for browsing command-line history " "with neither output nor the :term:`>>>` and :term:`...` prompts. :kbd:`F3` " "enters \"paste mode\", which makes pasting larger blocks of code easier. " @@ -67,8 +68,8 @@ msgstr "" #: ../../tutorial/appendix.rst:32 msgid "" -"If the new interactive shell is not desired, it can be disabled via " -"the :envvar:`PYTHON_BASIC_REPL` environment variable." +"If the new interactive shell is not desired, it can be disabled via the :" +"envvar:`PYTHON_BASIC_REPL` environment variable." msgstr "" "如果不需要新的互動式 shell, 可以透過 :envvar:`PYTHON_BASIC_REPL` 環境變數來" "停用它。" @@ -82,8 +83,8 @@ msgid "" "When an error occurs, the interpreter prints an error message and a stack " "trace. In interactive mode, it then returns to the primary prompt; when " "input came from a file, it exits with a nonzero exit status after printing " -"the stack trace. (Exceptions handled by an :keyword:`except` clause in " -"a :keyword:`try` statement are not errors in this context.) Some errors are " +"the stack trace. (Exceptions handled by an :keyword:`except` clause in a :" +"keyword:`try` statement are not errors in this context.) Some errors are " "unconditionally fatal and cause an exit with a nonzero exit status; this " "applies to internal inconsistencies and some cases of running out of " "memory. All error messages are written to the standard error stream; normal " @@ -101,13 +102,13 @@ msgid "" "Typing the interrupt character (usually :kbd:`Control-C` or :kbd:`Delete`) " "to the primary or secondary prompt cancels the input and returns to the " "primary prompt. [#]_ Typing an interrupt while a command is executing raises " -"the :exc:`KeyboardInterrupt` exception, which may be handled by " -"a :keyword:`try` statement." +"the :exc:`KeyboardInterrupt` exception, which may be handled by a :keyword:" +"`try` statement." msgstr "" -"向主提示字元或次提示字元輸入中斷字元(通常是 :kbd:`Control-C` " -"或 :kbd:`Delete` )會取消輸入並返回到主提示字元。[#]_ 在指令執行過程中輸入一" -"個中斷,會引發 :exc:`KeyboardInterrupt` 例外,但可以通過 :keyword:`try` 陳述" -"式來處理。" +"向主提示字元或次提示字元輸入中斷字元(通常是 :kbd:`Control-C` 或 :kbd:" +"`Delete` )會取消輸入並返回到主提示字元。[#]_ 在指令執行過程中輸入一個中斷," +"會引發 :exc:`KeyboardInterrupt` 例外,但可以通過 :keyword:`try` 陳述式來處" +"理。" #: ../../tutorial/appendix.rst:60 msgid "Executable Python Scripts" @@ -136,13 +137,13 @@ msgid "" msgstr "" "(假設直譯器在用戶的 :envvar:`PATH` 上)在腳本的開頭並給檔案一個可執行模式。" "``#!`` 必須是檔案的前兩個字元。在某些平台上,第一行必須以 Unix 樣式的換行 " -"(``'\\n'``) 結尾,而不是 Windows (``'\\r\\n'``) 換行。請注意,井號 ``'#'`` " -"用於在 Python 中開始註解。" +"(``'\\n'``) 結尾,而不是 Windows (``'\\r\\n'``) 換行。請注意,井號 ``'#'`` 用" +"於在 Python 中開始註解。" #: ../../tutorial/appendix.rst:74 msgid "" -"The script can be given an executable mode, or permission, using " -"the :program:`chmod` command." +"The script can be given an executable mode, or permission, using the :" +"program:`chmod` command." msgstr "可以使用 :program:`chmod` 指令為腳本賦予可執行模式或權限。" #: ../../tutorial/appendix.rst:77 @@ -157,9 +158,9 @@ msgid "" "extension can also be ``.pyw``, in that case, the console window that " "normally appears is suppressed." msgstr "" -"在 Windows 系統上,沒有「可執行模式」的概念。Python 安裝程式會自動將 " -"``.py`` 檔案與 ``python.exe`` 聯繫起來,這樣雙擊 Python 檔案就會作為腳本運" -"行。副檔名也可以是 ``.pyw``,在這種情況下,通常會出現的控制台視窗會被隱藏。" +"在 Windows 系統上,沒有「可執行模式」的概念。Python 安裝程式會自動將 ``.py`` " +"檔案與 ``python.exe`` 聯繫起來,這樣雙擊 Python 檔案就會作為腳本運行。副檔名" +"也可以是 ``.pyw``,在這種情況下,通常會出現的控制台視窗會被隱藏。" #: ../../tutorial/appendix.rst:91 msgid "The Interactive Startup File" @@ -196,8 +197,8 @@ msgstr "" #: ../../tutorial/appendix.rst:107 msgid "" "If you want to read an additional start-up file from the current directory, " -"you can program this in the global start-up file using code like ``if " -"os.path.isfile('.pythonrc.py'): exec(open('.pythonrc.py').read())``. If you " +"you can program this in the global start-up file using code like ``if os." +"path.isfile('.pythonrc.py'): exec(open('.pythonrc.py').read())``. If you " "want to use the startup file in a script, you must do this explicitly in the " "script::" msgstr "" @@ -233,9 +234,9 @@ msgid "" "location of your user site-packages directory. Start Python and run this " "code::" msgstr "" -"Python 提供了兩個鉤子 (hook) 讓你可以將它客製化: :index:`sitecustomize` " -"和 :index:`usercustomize` 。要看它是如何運作的,你首先需要找到你的 site-" -"packages 的位置。啟動 Python 並運行這段程式碼: ::" +"Python 提供了兩個鉤子 (hook) 讓你可以將它客製化: :index:`sitecustomize` 和 :" +"index:`usercustomize` 。要看它是如何運作的,你首先需要找到你的 site-packages " +"的位置。啟動 Python 並運行這段程式碼: ::" #: ../../tutorial/appendix.rst:130 msgid "" @@ -262,8 +263,8 @@ msgstr "" msgid "" ":index:`sitecustomize` works in the same way, but is typically created by an " "administrator of the computer in the global site-packages directory, and is " -"imported before :index:`usercustomize`. See the documentation of " -"the :mod:`site` module for more details." +"imported before :index:`usercustomize`. See the documentation of the :mod:" +"`site` module for more details." msgstr "" ":index:`sitecustomize` 的運作方式相同,但通常是由電腦的管理員在全域 site-" "packages 目錄下建立,並在 :index:`usercustomize` 之前 import 。更多細節請參" From 3798cdc8da3234e9914298d9480abf223973254d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 16 Aug 2025 00:17:23 +0000 Subject: [PATCH 15/23] sync with cpython 8d6e1075 --- library/cmdlinelibs.po | 5 ++- library/concurrent.futures.po | 10 +++-- library/constants.po | 76 ++++++++++++++++++----------------- library/frameworks.po | 39 +++++++++++++----- library/tk.po | 29 ++++++------- library/unix.po | 5 ++- 6 files changed, 94 insertions(+), 70 deletions(-) diff --git a/library/cmdlinelibs.po b/library/cmdlinelibs.po index 74afa150da..c5711318fd 100644 --- a/library/cmdlinelibs.po +++ b/library/cmdlinelibs.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-29 11:18+0000\n" +"POT-Creation-Date: 2025-08-16 00:16+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -18,7 +18,8 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../library/cmdlinelibs.rst:5 -msgid "Command Line Interface Libraries" +#, fuzzy +msgid "Command-line interface libraries" msgstr "命令列介面函式庫" #: ../../library/cmdlinelibs.rst:7 diff --git a/library/concurrent.futures.po b/library/concurrent.futures.po index 37d9b928e7..8d810cc18c 100644 --- a/library/concurrent.futures.po +++ b/library/concurrent.futures.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-28 00:20+0000\n" +"POT-Creation-Date: 2025-08-16 00:16+0000\n" "PO-Revision-Date: 2023-01-24 03:33+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -192,10 +192,12 @@ msgstr "" "future 將在此方法回傳之前完成。剩餘的 future 被取消。" #: ../../library/concurrent.futures.rst:95 +#, fuzzy msgid "" -"You can avoid having to call this method explicitly if you use the :keyword:" -"`with` statement, which will shutdown the :class:`Executor` (waiting as if :" -"meth:`Executor.shutdown` were called with *wait* set to ``True``)::" +"You can avoid having to call this method explicitly if you use the executor " +"as a :term:`context manager` via the :keyword:`with` statement, which will " +"shutdown the :class:`Executor` (waiting as if :meth:`Executor.shutdown` were " +"called with *wait* set to ``True``)::" msgstr "" "如果使用 :keyword:`with` 陳述句,你就可以不用明確地呼叫此方法,這將會自己關" "閉 :class:`Executor`\\(如同呼叫 :meth:`Executor.shutdown` 時 *wait* 被設定" diff --git a/library/constants.po b/library/constants.po index 1d80e5ff7c..8cd75e1292 100644 --- a/library/constants.po +++ b/library/constants.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-04 00:14+0000\n" +"POT-Creation-Date: 2025-08-16 00:16+0000\n" "PO-Revision-Date: 2021-11-19 23:36+0800\n" "Last-Translator: Jordan Su \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -59,22 +59,21 @@ msgstr "" #: ../../library/constants.rst:30 msgid "" -"A special value which should be returned by the binary special methods " -"(e.g. :meth:`~object.__eq__`, :meth:`~object.__lt__`, :meth:`~object.__add__`, :meth:`~object.__rsub__`, " -"etc.) to indicate that the operation is not implemented with respect to the " -"other type; may be returned by the in-place binary special methods " -"(e.g. :meth:`~object.__imul__`, :meth:`~object.__iand__`, etc.) for the same " -"purpose. It should not be evaluated in a boolean context. :data:`!" -"NotImplemented` is the sole instance of the :data:`types.NotImplementedType` " -"type." +"A special value which should be returned by the binary special methods (e." +"g. :meth:`~object.__eq__`, :meth:`~object.__lt__`, :meth:`~object.__add__`, :" +"meth:`~object.__rsub__`, etc.) to indicate that the operation is not " +"implemented with respect to the other type; may be returned by the in-place " +"binary special methods (e.g. :meth:`~object.__imul__`, :meth:`~object." +"__iand__`, etc.) for the same purpose. It should not be evaluated in a " +"boolean context. :data:`!NotImplemented` is the sole instance of the :data:" +"`types.NotImplementedType` type." msgstr "" -"會被二元特殊方法 (binary special methods)" -"(如::meth:`~object.__eq__`、:meth:`~object.__lt__`、:meth:`~object.__add__`、:meth:`~object.__rsub__` " -"等)所回傳的特殊值,代表著該運算沒有針對其他型別的實作。同理也可以被原地二元" -"特殊方法 (in-place binary special methods) " -"(如::meth:`~object.__imul__`、:meth:`~object.__iand__` 等)回傳。它不應該被" -"作為 boolean(布林)來解讀。:data:`!NotImplemented` 是型" -"別 :data:`types.NotImplementedType` 的唯一實例。" +"會被二元特殊方法 (binary special methods)(如::meth:`~object.__eq__`、:meth:" +"`~object.__lt__`、:meth:`~object.__add__`、:meth:`~object.__rsub__` 等)所回" +"傳的特殊值,代表著該運算沒有針對其他型別的實作。同理也可以被原地二元特殊方法 " +"(in-place binary special methods) (如::meth:`~object.__imul__`、:meth:" +"`~object.__iand__` 等)回傳。它不應該被作為 boolean(布林)來解讀。:data:`!" +"NotImplemented` 是型別 :data:`types.NotImplementedType` 的唯一實例。" #: ../../library/constants.rst:40 msgid "" @@ -99,12 +98,12 @@ msgstr "請參見 :ref:`implementing-the-arithmetic-operations` 以找到更多 #: ../../library/constants.rst:51 msgid "" ":data:`!NotImplemented` and :exc:`!NotImplementedError` are not " -"interchangeable. This constant should only be used as described above; " -"see :exc:`NotImplementedError` for details on correct usage of the exception." +"interchangeable. This constant should only be used as described above; see :" +"exc:`NotImplementedError` for details on correct usage of the exception." msgstr "" ":data:`!NotImplemented` 與 :exc:`!NotImplementedError` 並不一樣且不可互換。這" -"個常數只能用於上述的情況;欲知更多如何正確使用它們的細節,請參" -"見 :exc:`NotImplementedError`。" +"個常數只能用於上述的情況;欲知更多如何正確使用它們的細節,請參見 :exc:" +"`NotImplementedError`。" #: ../../library/constants.rst:56 msgid "" @@ -124,26 +123,26 @@ msgid "" "type." msgstr "" "與刪節號 \"``...``\" 字面相同。為一特殊值,大多用於結合使用者定義資料型別的延" -"伸切片語法 (extended slicing syntax)。``Ellipsis`` 是型" -"別 :data:`types.EllipsisType` 的唯一實例。" +"伸切片語法 (extended slicing syntax)。``Ellipsis`` 是型別 :data:`types." +"EllipsisType` 的唯一實例。" #: ../../library/constants.rst:72 msgid "" "This constant is true if Python was not started with an :option:`-O` option. " "See also the :keyword:`assert` statement." msgstr "" -"如果 Python 沒有被以 :option:`-O` 選項啟動,則此常數為 true。請參" -"見 :keyword:`assert` 陳述式。" +"如果 Python 沒有被以 :option:`-O` 選項啟動,則此常數為 true。請參見 :keyword:" +"`assert` 陳述式。" #: ../../library/constants.rst:78 msgid "" "The names :data:`None`, :data:`False`, :data:`True` and :data:`__debug__` " -"cannot be reassigned (assignments to them, even as an attribute name, " -"raise :exc:`SyntaxError`), so they can be considered \"true\" constants." +"cannot be reassigned (assignments to them, even as an attribute name, raise :" +"exc:`SyntaxError`), so they can be considered \"true\" constants." msgstr "" ":data:`None`,:data:`False`,:data:`True`,以及 :data:`__debug__` 都是不能被" -"重新賦值的(任何對它們的賦值,即使是屬性的名稱,也會拋" -"出 :exc:`SyntaxError`)。因此,它們可以被視為”真正的”常數。" +"重新賦值的(任何對它們的賦值,即使是屬性的名稱,也會拋出 :exc:" +"`SyntaxError`)。因此,它們可以被視為”真正的”常數。" #: ../../library/constants.rst:86 msgid "Constants added by the :mod:`site` module" @@ -161,31 +160,34 @@ msgstr "" "式直譯器中是很有幫助的,但不應該在程式 (programs) 中被使用。" #: ../../library/constants.rst:96 +#, fuzzy msgid "" "Objects that when printed, print a message like \"Use quit() or Ctrl-D (i.e. " -"EOF) to exit\", and when called, raise :exc:`SystemExit` with the specified " -"exit code." +"EOF) to exit\", and when accessed directly in the interactive interpreter or " +"called as functions, raise :exc:`SystemExit` with the specified exit code." msgstr "" "當印出物件時,會印出一個訊息: \"Use quit() or Ctrl-D (i.e. EOF) to exit\" 。" "當被呼叫時,則會拋出 :exc:`SystemExit` 並帶有指定的返回碼(exit code)。" -#: ../../library/constants.rst:103 +#: ../../library/constants.rst:104 +#, fuzzy msgid "" "Object that when printed, prints the message \"Type help() for interactive " -"help, or help(object) for help about object.\", and when called, acts as " -"described :func:`elsewhere `." +"help, or help(object) for help about object.\", and when accessed directly " +"in the interactive interpreter, invokes the built-in help system (see :func:" +"`help`)." msgstr "" "當印出此物件時,會印出訊息 \"Type help() for interactive help, or " -"help(object) for help about object.\",並在呼叫時按所述的方式操" -"作 :func:`elsewhere `。" +"help(object) for help about object.\",並在呼叫時按所述的方式操作 :func:" +"`elsewhere `。" -#: ../../library/constants.rst:110 +#: ../../library/constants.rst:112 msgid "" "Objects that when printed or called, print the text of copyright or credits, " "respectively." msgstr "當印出或是呼叫此物件時,分別會印出版權與致謝的文字。" -#: ../../library/constants.rst:115 +#: ../../library/constants.rst:117 msgid "" "Object that when printed, prints the message \"Type license() to see the " "full license text\", and when called, displays the full license text in a " diff --git a/library/frameworks.po b/library/frameworks.po index 3362ffdf1f..6d2fac470a 100644 --- a/library/frameworks.po +++ b/library/frameworks.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-06-26 18:54+0800\n" +"POT-Creation-Date: 2025-08-16 00:16+0000\n" "PO-Revision-Date: 2025-06-27 13:41+0800\n" "Last-Translator: Leon H.\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,19 +20,36 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/frameworks.rst:5 -msgid "Program Frameworks" +#: ../../library/frameworks.rst:7 +#, fuzzy +msgid "Program frameworks" msgstr "程式框架" -#: ../../library/frameworks.rst:7 +#: ../../library/frameworks.rst:9 msgid "" -"The modules described in this chapter are frameworks that will largely " -"dictate the structure of your program. Currently the modules described " -"here are all oriented toward writing command-line interfaces." +"This chapter is no longer maintained, and the modules it contained have been " +"moved to their respective topical documentation." msgstr "" -"本章所描述的模組屬於框架性質,它們將在很大程度上決定程式的結構。目前本章介" -"紹的所有模組皆專注於撰寫命令列介面。" #: ../../library/frameworks.rst:11 -msgid "The full list of modules described in this chapter is:" -msgstr "完整的模組列表為:" +msgid ":mod:`cmd` — :doc:`Command Line Interface Libraries <./cmdlinelibs>`" +msgstr "" + +#: ../../library/frameworks.rst:12 +msgid ":mod:`shlex` — :doc:`Unix Specific Services <./unix>`" +msgstr "" + +#: ../../library/frameworks.rst:13 +msgid ":mod:`turtle` — :doc:`Graphical User Interfaces with Tk <./tk>`" +msgstr "" + +#~ msgid "" +#~ "The modules described in this chapter are frameworks that will largely " +#~ "dictate the structure of your program. Currently the modules described " +#~ "here are all oriented toward writing command-line interfaces." +#~ msgstr "" +#~ "本章所描述的模組屬於框架性質,它們將在很大程度上決定程式的結構。目前本章介" +#~ "紹的所有模組皆專注於撰寫命令列介面。" + +#~ msgid "The full list of modules described in this chapter is:" +#~ msgstr "完整的模組列表為:" diff --git a/library/tk.po b/library/tk.po index 5a3fc9a8d8..6d1785bf11 100644 --- a/library/tk.po +++ b/library/tk.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-08-16 00:16+0000\n" "PO-Revision-Date: 2023-06-24 17:09+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,15 +21,16 @@ msgstr "" "X-Generator: Poedit 3.3.1\n" #: ../../library/tk.rst:5 -msgid "Graphical User Interfaces with Tk" +#, fuzzy +msgid "Graphical user interfaces with Tk" msgstr "以 Tk 打造圖形使用者介面 (Graphical User Interfaces)" #: ../../library/tk.rst:13 msgid "" "Tk/Tcl has long been an integral part of Python. It provides a robust and " "platform independent windowing toolkit, that is available to Python " -"programmers using the :mod:`tkinter` package, and its extension, " -"the :mod:`tkinter.ttk` module." +"programmers using the :mod:`tkinter` package, and its extension, the :mod:" +"`tkinter.ttk` module." msgstr "" "Tk/Tcl 長期以來一直是 Python 不可或缺的一部分。它提供了一個強大且獨立於平台的" "視窗工具包,可供使用 :mod:`tkinter` 套件及其擴充套件 :mod:`tkinter.ttk` 模組" @@ -39,13 +40,13 @@ msgstr "" msgid "" "The :mod:`tkinter` package is a thin object-oriented layer on top of Tcl/Tk. " "To use :mod:`tkinter`, you don't need to write Tcl code, but you will need " -"to consult the Tk documentation, and occasionally the Tcl " -"documentation. :mod:`tkinter` is a set of wrappers that implement the Tk " -"widgets as Python classes." +"to consult the Tk documentation, and occasionally the Tcl documentation. :" +"mod:`tkinter` is a set of wrappers that implement the Tk widgets as Python " +"classes." msgstr "" -":mod:`tkinter` 套件是 Tcl/Tk 之上的一個輕薄物件導向層。要使" -"用 :mod:`tkinter`,你不需要編寫 Tcl 程式,但會需要查閱 Tk 文件和部份 Tcl 文" -"件。:mod:`tkinter` 是一組將 Tk 小工具 (widget) 實作為 Python 類別的包裝器。" +":mod:`tkinter` 套件是 Tcl/Tk 之上的一個輕薄物件導向層。要使用 :mod:" +"`tkinter`,你不需要編寫 Tcl 程式,但會需要查閱 Tk 文件和部份 Tcl 文件。:mod:" +"`tkinter` 是一組將 Tk 小工具 (widget) 實作為 Python 類別的包裝器。" #: ../../library/tk.rst:23 msgid "" @@ -59,10 +60,10 @@ msgid "" "GuiProgramming>`_." msgstr "" ":mod:`tkinter` 的主要優點是速度快,而且通常與 Python 捆綁 (bundle) 在一起。儘" -"管其標準文件不是很完整,但還是有些不錯的材料,包括:參考資料、教學、書籍" -"等。:mod:`tkinter` 曾因其過時的外觀而眾所皆知,但這在 Tk 8.5 中得到了極大的改" -"進。此外,還有許多其他你可能會感興趣的 GUI 函式庫。Python wiki 列出了幾個替代" -"的 `GUI 框架和工具 `_。" +"管其標準文件不是很完整,但還是有些不錯的材料,包括:參考資料、教學、書籍等。:" +"mod:`tkinter` 曾因其過時的外觀而眾所皆知,但這在 Tk 8.5 中得到了極大的改進。" +"此外,還有許多其他你可能會感興趣的 GUI 函式庫。Python wiki 列出了幾個替代的 " +"`GUI 框架和工具 `_。" #: ../../library/tk.rst:7 msgid "GUI" diff --git a/library/unix.po b/library/unix.po index be71ea3e66..65090953a2 100644 --- a/library/unix.po +++ b/library/unix.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-06-26 18:54+0800\n" +"POT-Creation-Date: 2025-08-16 00:16+0000\n" "PO-Revision-Date: 2022-02-15 18:42+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,7 +20,8 @@ msgstr "" "X-Generator: Poedit 3.0.1\n" #: ../../library/unix.rst:5 -msgid "Unix Specific Services" +#, fuzzy +msgid "Unix-specific services" msgstr "Unix 特有服務" #: ../../library/unix.rst:7 From e540d58fa21bee6bdded729f2b70ae5dcf2c6407 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 17 Aug 2025 00:19:46 +0000 Subject: [PATCH 16/23] sync with cpython 133f7bd2 --- library/asyncio-protocol.po | 8 ++--- library/asyncio-sync.po | 7 +++-- library/profile.po | 63 ++++++++++++++++++------------------- 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/library/asyncio-protocol.po b/library/asyncio-protocol.po index 9b58685f3e..9b98f921a4 100644 --- a/library/asyncio-protocol.po +++ b/library/asyncio-protocol.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-08-17 00:18+0000\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -532,19 +532,19 @@ msgstr "" #: ../../library/asyncio-protocol.rst:393 msgid "" -"``0``: readable streaming transport of the standard input (*stdin*), or :" +"``0``: writable streaming transport of the standard input (*stdin*), or :" "const:`None` if the subprocess was not created with ``stdin=PIPE``" msgstr "" #: ../../library/asyncio-protocol.rst:395 msgid "" -"``1``: writable streaming transport of the standard output (*stdout*), or :" +"``1``: readable streaming transport of the standard output (*stdout*), or :" "const:`None` if the subprocess was not created with ``stdout=PIPE``" msgstr "" #: ../../library/asyncio-protocol.rst:397 msgid "" -"``2``: writable streaming transport of the standard error (*stderr*), or :" +"``2``: readable streaming transport of the standard error (*stderr*), or :" "const:`None` if the subprocess was not created with ``stderr=PIPE``" msgstr "" diff --git a/library/asyncio-sync.po b/library/asyncio-sync.po index a539db9b6e..c9efe21b78 100644 --- a/library/asyncio-sync.po +++ b/library/asyncio-sync.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-23 00:15+0000\n" +"POT-Creation-Date: 2025-08-17 00:18+0000\n" "PO-Revision-Date: 2022-02-09 19:27+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -253,9 +253,10 @@ msgid "Clear (unset) the event." msgstr "清除(還原)事件。" #: ../../library/asyncio-sync.rst:160 +#, fuzzy msgid "" -"Tasks awaiting on :meth:`~Event.wait` will now block until the :meth:`~Event." -"set` method is called again." +"Subsequent tasks awaiting on :meth:`~Event.wait` will now block until the :" +"meth:`~Event.set` method is called again." msgstr "" "正透過 :meth:`~Event.wait` 等待的 Tasks 現在會持續阻塞直到 :meth:`~Event." "set` 方法再次被呼叫。" diff --git a/library/profile.po b/library/profile.po index 5babd398ac..4d84edf423 100644 --- a/library/profile.po +++ b/library/profile.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-02 00:15+0000\n" +"POT-Creation-Date: 2025-08-17 00:18+0000\n" "PO-Revision-Date: 2018-05-23 16:08+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -53,21 +53,20 @@ msgstr "" #: ../../library/profile.rst:33 msgid "" -":mod:`profile`, a pure Python module whose interface is imitated " -"by :mod:`cProfile`, but which adds significant overhead to profiled " -"programs. If you're trying to extend the profiler in some way, the task " -"might be easier with this module. Originally designed and written by Jim " -"Roskind." +":mod:`profile`, a pure Python module whose interface is imitated by :mod:" +"`cProfile`, but which adds significant overhead to profiled programs. If " +"you're trying to extend the profiler in some way, the task might be easier " +"with this module. Originally designed and written by Jim Roskind." msgstr "" #: ../../library/profile.rst:40 msgid "" "The profiler modules are designed to provide an execution profile for a " -"given program, not for benchmarking purposes (for that, there " -"is :mod:`timeit` for reasonably accurate results). This particularly " -"applies to benchmarking Python code against C code: the profilers introduce " -"overhead for Python code, but not for C-level functions, and so the C code " -"would seem faster than any Python one." +"given program, not for benchmarking purposes (for that, there is :mod:" +"`timeit` for reasonably accurate results). This particularly applies to " +"benchmarking Python code against C code: the profilers introduce overhead " +"for Python code, but not for C-level functions, and so the C code would seem " +"faster than any Python one." msgstr "" #: ../../library/profile.rst:51 @@ -613,21 +612,20 @@ msgid "" "printout to fit within (close to) 80 columns. This method modifies the " "object, and the stripped information is lost. After performing a strip " "operation, the object is considered to have its entries in a \"random\" " -"order, as it was just after object initialization and loading. " -"If :meth:`~pstats.Stats.strip_dirs` causes two function names to be " -"indistinguishable (they are on the same line of the same filename, and have " -"the same function name), then the statistics for these two entries are " -"accumulated into a single entry." +"order, as it was just after object initialization and loading. If :meth:" +"`~pstats.Stats.strip_dirs` causes two function names to be indistinguishable " +"(they are on the same line of the same filename, and have the same function " +"name), then the statistics for these two entries are accumulated into a " +"single entry." msgstr "" #: ../../library/profile.rst:388 msgid "" "This method of the :class:`Stats` class accumulates additional profiling " "information into the current profiling object. Its arguments should refer " -"to filenames created by the corresponding version of :func:`profile.run` " -"or :func:`cProfile.run`. Statistics for identically named (re: file, line, " -"name) functions are automatically accumulated into single function " -"statistics." +"to filenames created by the corresponding version of :func:`profile.run` or :" +"func:`cProfile.run`. Statistics for identically named (re: file, line, name) " +"functions are automatically accumulated into single function statistics." msgstr "" #: ../../library/profile.rst:398 @@ -818,12 +816,12 @@ msgstr "``'tottime'``" msgid "" "Note that all sorts on statistics are in descending order (placing most time " "consuming items first), where as name, file, and line number searches are in " -"ascending order (alphabetical). The subtle distinction between " -"``SortKey.NFL`` and ``SortKey.STDNAME`` is that the standard name is a sort " -"of the name as printed, which means that the embedded line numbers get " -"compared in an odd way. For example, lines 3, 20, and 40 would (if the file " -"names were the same) appear in the string order 20, 3 and 40. In contrast, " -"``SortKey.NFL`` does a numeric compare of the line numbers. In fact, " +"ascending order (alphabetical). The subtle distinction between ``SortKey." +"NFL`` and ``SortKey.STDNAME`` is that the standard name is a sort of the " +"name as printed, which means that the embedded line numbers get compared in " +"an odd way. For example, lines 3, 20, and 40 would (if the file names were " +"the same) appear in the string order 20, 3 and 40. In contrast, ``SortKey." +"NFL`` does a numeric compare of the line numbers. In fact, " "``sort_stats(SortKey.NFL)`` is the same as ``sort_stats(SortKey.NAME, " "SortKey.FILENAME, SortKey.LINE)``." msgstr "" @@ -856,10 +854,9 @@ msgstr "" #: ../../library/profile.rst:493 msgid "" -"The order of the printing is based on the " -"last :meth:`~pstats.Stats.sort_stats` operation done on the object (subject " -"to caveats in :meth:`~pstats.Stats.add` " -"and :meth:`~pstats.Stats.strip_dirs`)." +"The order of the printing is based on the last :meth:`~pstats.Stats." +"sort_stats` operation done on the object (subject to caveats in :meth:" +"`~pstats.Stats.add` and :meth:`~pstats.Stats.strip_dirs`)." msgstr "" #: ../../library/profile.rst:498 @@ -868,7 +865,7 @@ msgid "" "significant entries. Initially, the list is taken to be the complete set of " "profiled functions. Each restriction is either an integer (to select a " "count of lines), or a decimal fraction between 0.0 and 1.0 inclusive (to " -"select a percentage of lines), or a string that will interpreted as a " +"select a percentage of lines), or a string that will be interpreted as a " "regular expression (to pattern match the standard name that is printed). If " "several restrictions are provided, then they are applied sequentially. For " "example::" @@ -1169,8 +1166,8 @@ msgstr "" #: ../../library/profile.rst:713 msgid "" "Python 3.3 adds several new functions in :mod:`time` that can be used to " -"make precise measurements of process or wall-clock time. For example, " -"see :func:`time.perf_counter`." +"make precise measurements of process or wall-clock time. For example, see :" +"func:`time.perf_counter`." msgstr "" #: ../../library/profile.rst:16 From 8852a864d3990b534c7e4d3455bb4fffe3a5b322 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 18 Aug 2025 00:19:28 +0000 Subject: [PATCH 17/23] sync with cpython 9face218 --- c-api/init.po | 813 ++++++++++++++++++++++++++------------------------ 1 file changed, 431 insertions(+), 382 deletions(-) diff --git a/c-api/init.po b/c-api/init.po index e003fd46a4..9b1b2d581b 100644 --- a/c-api/init.po +++ b/c-api/init.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-18 00:18+0000\n" "PO-Revision-Date: 2023-04-24 20:49+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -666,10 +666,14 @@ msgid "" "extension modules may not be freed. Some extensions may not work properly " "if their initialization routine is called more than once; this can happen if " "an application calls :c:func:`Py_Initialize` and :c:func:`Py_FinalizeEx` " -"more than once." +"more than once. :c:func:`Py_FinalizeEx` must not be called recursively from " +"within itself. Therefore, it must not be called by any code that may be run " +"as part of the interpreter shutdown process, such as :py:mod:`atexit` " +"handlers, object finalizers, or any code that may be run while flushing the " +"stdout and stderr files." msgstr "" -#: ../../c-api/init.rst:452 +#: ../../c-api/init.rst:456 msgid "" "Raises an :ref:`auditing event ` ``cpython." "_PySys_ClearAuditHooks`` with no arguments." @@ -677,20 +681,20 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "_PySys_ClearAuditHooks``。" -#: ../../c-api/init.rst:459 +#: ../../c-api/init.rst:463 msgid "" "This is a backwards-compatible version of :c:func:`Py_FinalizeEx` that " "disregards the return value." msgstr "" -#: ../../c-api/init.rst:465 +#: ../../c-api/init.rst:469 msgid "" "Similar to :c:func:`Py_Main` but *argv* is an array of bytes strings, " "allowing the calling application to delegate the text decoding step to the " "CPython runtime." msgstr "" -#: ../../c-api/init.rst:474 +#: ../../c-api/init.rst:478 msgid "" "The main program for the standard interpreter, encapsulating a full " "initialization/finalization cycle, as well as additional behaviour to " @@ -699,14 +703,14 @@ msgid "" "cmdline`." msgstr "" -#: ../../c-api/init.rst:480 +#: ../../c-api/init.rst:484 msgid "" "This is made available for programs which wish to support the full CPython " "command line interface, rather than just embedding a Python runtime in a " "larger application." msgstr "" -#: ../../c-api/init.rst:484 +#: ../../c-api/init.rst:488 msgid "" "The *argc* and *argv* parameters are similar to those which are passed to a " "C program's :c:func:`main` function, except that the *argv* entries are " @@ -716,20 +720,20 @@ msgid "" "pointed to by the argument list are not modified)." msgstr "" -#: ../../c-api/init.rst:491 +#: ../../c-api/init.rst:495 msgid "" "The return value is ``2`` if the argument list does not represent a valid " "Python command line, and otherwise the same as :c:func:`Py_RunMain`." msgstr "" -#: ../../c-api/init.rst:494 +#: ../../c-api/init.rst:498 msgid "" "In terms of the CPython runtime configuration APIs documented in the :ref:" "`runtime configuration ` section (and without accounting for " "error handling), ``Py_Main`` is approximately equivalent to::" msgstr "" -#: ../../c-api/init.rst:498 +#: ../../c-api/init.rst:502 msgid "" "PyConfig config;\n" "PyConfig_InitPythonConfig(&config);\n" @@ -740,7 +744,7 @@ msgid "" "Py_RunMain();" msgstr "" -#: ../../c-api/init.rst:506 +#: ../../c-api/init.rst:510 msgid "" "In normal usage, an embedding application will call this function *instead* " "of calling :c:func:`Py_Initialize`, :c:func:`Py_InitializeEx` or :c:func:" @@ -753,11 +757,11 @@ msgid "" "first initialized)." msgstr "" -#: ../../c-api/init.rst:519 +#: ../../c-api/init.rst:523 msgid "Executes the main module in a fully configured CPython runtime." msgstr "" -#: ../../c-api/init.rst:521 +#: ../../c-api/init.rst:525 msgid "" "Executes the command (:c:member:`PyConfig.run_command`), the script (:c:" "member:`PyConfig.run_filename`) or the module (:c:member:`PyConfig." @@ -766,7 +770,7 @@ msgid "" "``__main__`` module's global namespace." msgstr "" -#: ../../c-api/init.rst:527 +#: ../../c-api/init.rst:531 msgid "" "If :c:member:`PyConfig.inspect` is not set (the default), the return value " "will be ``0`` if the interpreter exits normally (that is, without raising an " @@ -774,7 +778,7 @@ msgid "" "any other unhandled exception." msgstr "" -#: ../../c-api/init.rst:532 +#: ../../c-api/init.rst:536 msgid "" "If :c:member:`PyConfig.inspect` is set (such as when the :option:`-i` option " "is used), rather than returning when the interpreter exits, execution will " @@ -785,41 +789,41 @@ msgid "" "status of a :exc:`SystemExit`, as specified above." msgstr "" -#: ../../c-api/init.rst:540 +#: ../../c-api/init.rst:544 msgid "" "This function always finalizes the Python interpreter before it returns." msgstr "" -#: ../../c-api/init.rst:542 +#: ../../c-api/init.rst:546 msgid "" "See :ref:`Python Configuration ` for an example of a " "customized Python that always runs in isolated mode using :c:func:" "`Py_RunMain`." msgstr "" -#: ../../c-api/init.rst:548 +#: ../../c-api/init.rst:552 msgid "" "Register an :mod:`atexit` callback for the target interpreter *interp*. This " "is similar to :c:func:`Py_AtExit`, but takes an explicit interpreter and " "data pointer for the callback." msgstr "" -#: ../../c-api/init.rst:552 +#: ../../c-api/init.rst:556 msgid "The :term:`GIL` must be held for *interp*." msgstr "" -#: ../../c-api/init.rst:557 +#: ../../c-api/init.rst:561 msgid "Process-wide parameters" msgstr "" -#: ../../c-api/init.rst:567 +#: ../../c-api/init.rst:571 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "program_name` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:571 +#: ../../c-api/init.rst:575 msgid "" "This function should be called before :c:func:`Py_Initialize` is called for " "the first time, if it is called at all. It tells the interpreter the value " @@ -833,37 +837,37 @@ msgid "" "this storage." msgstr "" -#: ../../c-api/init.rst:582 ../../c-api/init.rst:824 ../../c-api/init.rst:860 -#: ../../c-api/init.rst:886 +#: ../../c-api/init.rst:586 ../../c-api/init.rst:828 ../../c-api/init.rst:864 +#: ../../c-api/init.rst:890 msgid "" "Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:" "`wchar_t*` string." msgstr "" -#: ../../c-api/init.rst:590 +#: ../../c-api/init.rst:594 msgid "" "Return the program name set with :c:member:`PyConfig.program_name`, or the " "default. The returned string points into static storage; the caller should " "not modify its value." msgstr "" -#: ../../c-api/init.rst:594 ../../c-api/init.rst:616 ../../c-api/init.rst:662 -#: ../../c-api/init.rst:684 ../../c-api/init.rst:710 ../../c-api/init.rst:898 +#: ../../c-api/init.rst:598 ../../c-api/init.rst:620 ../../c-api/init.rst:666 +#: ../../c-api/init.rst:688 ../../c-api/init.rst:714 ../../c-api/init.rst:902 msgid "" "This function should not be called before :c:func:`Py_Initialize`, otherwise " "it returns ``NULL``." msgstr "此函式不應該在 :c:func:`Py_Initialize` 之前呼叫,否則會回傳 ``NULL``。" -#: ../../c-api/init.rst:597 ../../c-api/init.rst:619 ../../c-api/init.rst:665 -#: ../../c-api/init.rst:687 ../../c-api/init.rst:715 ../../c-api/init.rst:901 +#: ../../c-api/init.rst:601 ../../c-api/init.rst:623 ../../c-api/init.rst:669 +#: ../../c-api/init.rst:691 ../../c-api/init.rst:719 ../../c-api/init.rst:905 msgid "It now returns ``NULL`` if called before :c:func:`Py_Initialize`." msgstr "如果在 :c:func:`Py_Initialize` 之前呼叫,現在會回傳 ``NULL``。" -#: ../../c-api/init.rst:600 ../../c-api/init.rst:690 +#: ../../c-api/init.rst:604 ../../c-api/init.rst:694 msgid "Get :data:`sys.executable` instead." msgstr "" -#: ../../c-api/init.rst:606 +#: ../../c-api/init.rst:610 msgid "" "Return the *prefix* for installed platform-independent files. This is " "derived through a number of complicated rules from the program name set " @@ -877,13 +881,13 @@ msgid "" "See also the next function." msgstr "" -#: ../../c-api/init.rst:622 +#: ../../c-api/init.rst:626 msgid "" "Get :data:`sys.base_prefix` instead, or :data:`sys.prefix` if :ref:`virtual " "environments ` need to be handled." msgstr "" -#: ../../c-api/init.rst:629 +#: ../../c-api/init.rst:633 msgid "" "Return the *exec-prefix* for installed platform-*dependent* files. This is " "derived through a number of complicated rules from the program name set " @@ -897,7 +901,7 @@ msgid "" "useful on Unix." msgstr "" -#: ../../c-api/init.rst:640 +#: ../../c-api/init.rst:644 msgid "" "Background: The exec-prefix differs from the prefix when platform dependent " "files (such as executables and shared libraries) are installed in a " @@ -906,7 +910,7 @@ msgid "" "independent may be installed in :file:`/usr/local`." msgstr "" -#: ../../c-api/init.rst:646 +#: ../../c-api/init.rst:650 msgid "" "Generally speaking, a platform is a combination of hardware and software " "families, e.g. Sparc machines running the Solaris 2.x operating system are " @@ -920,7 +924,7 @@ msgid "" "independent from the Python version by which they were compiled!)." msgstr "" -#: ../../c-api/init.rst:657 +#: ../../c-api/init.rst:661 msgid "" "System administrators will know how to configure the :program:`mount` or :" "program:`automount` programs to share :file:`/usr/local` between platforms " @@ -928,13 +932,13 @@ msgid "" "platform." msgstr "" -#: ../../c-api/init.rst:668 +#: ../../c-api/init.rst:672 msgid "" "Get :data:`sys.base_exec_prefix` instead, or :data:`sys.exec_prefix` if :ref:" "`virtual environments ` need to be handled." msgstr "" -#: ../../c-api/init.rst:678 +#: ../../c-api/init.rst:682 msgid "" "Return the full program name of the Python executable; this is computed as " "a side-effect of deriving the default module search path from the program " @@ -943,7 +947,7 @@ msgid "" "available to Python code as ``sys.executable``." msgstr "" -#: ../../c-api/init.rst:700 +#: ../../c-api/init.rst:704 msgid "" "Return the default module search path; this is computed from the program " "name (set by :c:member:`PyConfig.program_name`) and some environment " @@ -956,21 +960,21 @@ msgid "" "for loading modules." msgstr "" -#: ../../c-api/init.rst:718 +#: ../../c-api/init.rst:722 msgid "Get :data:`sys.path` instead." msgstr "" -#: ../../c-api/init.rst:724 +#: ../../c-api/init.rst:728 msgid "" "Return the version of this Python interpreter. This is a string that looks " "something like ::" msgstr "" -#: ../../c-api/init.rst:727 +#: ../../c-api/init.rst:731 msgid "\"3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \\n[GCC 4.2.3]\"" msgstr "\"3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \\n[GCC 4.2.3]\"" -#: ../../c-api/init.rst:731 +#: ../../c-api/init.rst:735 msgid "" "The first word (up to the first space character) is the current Python " "version; the first characters are the major and minor version separated by a " @@ -979,11 +983,11 @@ msgid "" "version`." msgstr "" -#: ../../c-api/init.rst:736 +#: ../../c-api/init.rst:740 msgid "See also the :c:var:`Py_Version` constant." msgstr "另請參閱 :c:var:`Py_Version` 常數。" -#: ../../c-api/init.rst:743 +#: ../../c-api/init.rst:747 msgid "" "Return the platform identifier for the current platform. On Unix, this is " "formed from the \"official\" name of the operating system, converted to " @@ -994,50 +998,50 @@ msgid "" "available to Python code as ``sys.platform``." msgstr "" -#: ../../c-api/init.rst:754 +#: ../../c-api/init.rst:758 msgid "" "Return the official copyright string for the current Python version, for " "example" msgstr "" -#: ../../c-api/init.rst:756 +#: ../../c-api/init.rst:760 msgid "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" msgstr "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" -#: ../../c-api/init.rst:760 +#: ../../c-api/init.rst:764 msgid "" "The returned string points into static storage; the caller should not modify " "its value. The value is available to Python code as ``sys.copyright``." msgstr "" -#: ../../c-api/init.rst:766 +#: ../../c-api/init.rst:770 msgid "" "Return an indication of the compiler used to build the current Python " "version, in square brackets, for example::" msgstr "" -#: ../../c-api/init.rst:769 +#: ../../c-api/init.rst:773 msgid "\"[GCC 2.7.2.2]\"" msgstr "\"[GCC 2.7.2.2]\"" -#: ../../c-api/init.rst:773 ../../c-api/init.rst:787 +#: ../../c-api/init.rst:777 ../../c-api/init.rst:791 msgid "" "The returned string points into static storage; the caller should not modify " "its value. The value is available to Python code as part of the variable " "``sys.version``." msgstr "" -#: ../../c-api/init.rst:780 +#: ../../c-api/init.rst:784 msgid "" "Return information about the sequence number and build date and time of the " "current Python interpreter instance, for example ::" msgstr "" -#: ../../c-api/init.rst:783 +#: ../../c-api/init.rst:787 msgid "\"#67, Aug 1 1997, 22:34:28\"" msgstr "\"#67, Aug 1 1997, 22:34:28\"" -#: ../../c-api/init.rst:799 +#: ../../c-api/init.rst:803 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "argv`, :c:member:`PyConfig.parse_argv` and :c:member:`PyConfig.safe_path` " @@ -1045,7 +1049,7 @@ msgid "" "config>`." msgstr "" -#: ../../c-api/init.rst:804 +#: ../../c-api/init.rst:808 msgid "" "Set :data:`sys.argv` based on *argc* and *argv*. These parameters are " "similar to those passed to the program's :c:func:`main` function with the " @@ -1056,84 +1060,84 @@ msgid "" "fatal condition is signalled using :c:func:`Py_FatalError`." msgstr "" -#: ../../c-api/init.rst:812 +#: ../../c-api/init.rst:816 msgid "" "If *updatepath* is zero, this is all the function does. If *updatepath* is " "non-zero, the function also modifies :data:`sys.path` according to the " "following algorithm:" msgstr "" -#: ../../c-api/init.rst:816 +#: ../../c-api/init.rst:820 msgid "" "If the name of an existing script is passed in ``argv[0]``, the absolute " "path of the directory where the script is located is prepended to :data:`sys." "path`." msgstr "" -#: ../../c-api/init.rst:819 +#: ../../c-api/init.rst:823 msgid "" "Otherwise (that is, if *argc* is ``0`` or ``argv[0]`` doesn't point to an " "existing file name), an empty string is prepended to :data:`sys.path`, which " "is the same as prepending the current working directory (``\".\"``)." msgstr "" -#: ../../c-api/init.rst:827 ../../c-api/init.rst:863 +#: ../../c-api/init.rst:831 ../../c-api/init.rst:867 msgid "" "See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv` " "members of the :ref:`Python Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:831 +#: ../../c-api/init.rst:835 msgid "" "It is recommended that applications embedding the Python interpreter for " "purposes other than executing a single script pass ``0`` as *updatepath*, " "and update :data:`sys.path` themselves if desired. See :cve:`2008-5983`." msgstr "" -#: ../../c-api/init.rst:836 +#: ../../c-api/init.rst:840 msgid "" "On versions before 3.1.3, you can achieve the same effect by manually " "popping the first :data:`sys.path` element after having called :c:func:" "`PySys_SetArgv`, for example using::" msgstr "" -#: ../../c-api/init.rst:840 +#: ../../c-api/init.rst:844 msgid "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" msgstr "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" -#: ../../c-api/init.rst:852 +#: ../../c-api/init.rst:856 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "argv` and :c:member:`PyConfig.parse_argv` should be used instead, see :ref:" "`Python Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:856 +#: ../../c-api/init.rst:860 msgid "" "This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set to " "``1`` unless the :program:`python` interpreter was started with the :option:" "`-I`." msgstr "" -#: ../../c-api/init.rst:866 +#: ../../c-api/init.rst:870 msgid "The *updatepath* value depends on :option:`-I`." msgstr "" -#: ../../c-api/init.rst:873 +#: ../../c-api/init.rst:877 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "home` should be used instead, see :ref:`Python Initialization Configuration " "`." msgstr "" -#: ../../c-api/init.rst:877 +#: ../../c-api/init.rst:881 msgid "" "Set the default \"home\" directory, that is, the location of the standard " "Python libraries. See :envvar:`PYTHONHOME` for the meaning of the argument " "string." msgstr "" -#: ../../c-api/init.rst:881 +#: ../../c-api/init.rst:885 msgid "" "The argument should point to a zero-terminated character string in static " "storage whose contents will not change for the duration of the program's " @@ -1141,24 +1145,24 @@ msgid "" "this storage." msgstr "" -#: ../../c-api/init.rst:894 +#: ../../c-api/init.rst:898 msgid "" "Return the default \"home\", that is, the value set by :c:member:`PyConfig." "home`, or the value of the :envvar:`PYTHONHOME` environment variable if it " "is set." msgstr "" -#: ../../c-api/init.rst:904 +#: ../../c-api/init.rst:908 msgid "" "Get :c:member:`PyConfig.home` or :envvar:`PYTHONHOME` environment variable " "instead." msgstr "改為取得 :c:member:`PyConfig.home` 或 :envvar:`PYTHONHOME` 環境變數。" -#: ../../c-api/init.rst:912 +#: ../../c-api/init.rst:916 msgid "Thread State and the Global Interpreter Lock" msgstr "" -#: ../../c-api/init.rst:919 +#: ../../c-api/init.rst:923 msgid "" "The Python interpreter is not fully thread-safe. In order to support multi-" "threaded Python programs, there's a global lock, called the :term:`global " @@ -1170,7 +1174,7 @@ msgid "" "once instead of twice." msgstr "" -#: ../../c-api/init.rst:929 +#: ../../c-api/init.rst:933 msgid "" "Therefore, the rule exists that only the thread that has acquired the :term:" "`GIL` may operate on Python objects or call Python/C API functions. In order " @@ -1180,7 +1184,7 @@ msgid "" "a file, so that other Python threads can run in the meantime." msgstr "" -#: ../../c-api/init.rst:939 +#: ../../c-api/init.rst:943 msgid "" "The Python interpreter keeps some thread-specific bookkeeping information " "inside a data structure called :c:type:`PyThreadState`. There's also one " @@ -1188,17 +1192,17 @@ msgid "" "retrieved using :c:func:`PyThreadState_Get`." msgstr "" -#: ../../c-api/init.rst:945 +#: ../../c-api/init.rst:949 msgid "Releasing the GIL from extension code" msgstr "" -#: ../../c-api/init.rst:947 +#: ../../c-api/init.rst:951 msgid "" "Most extension code manipulating the :term:`GIL` has the following simple " "structure::" msgstr "" -#: ../../c-api/init.rst:950 +#: ../../c-api/init.rst:954 msgid "" "Save the thread state in a local variable.\n" "Release the global interpreter lock.\n" @@ -1207,29 +1211,29 @@ msgid "" "Restore the thread state from the local variable." msgstr "" -#: ../../c-api/init.rst:956 +#: ../../c-api/init.rst:960 msgid "This is so common that a pair of macros exists to simplify it::" msgstr "" -#: ../../c-api/init.rst:958 +#: ../../c-api/init.rst:962 msgid "" "Py_BEGIN_ALLOW_THREADS\n" "... Do some blocking I/O operation ...\n" "Py_END_ALLOW_THREADS" msgstr "" -#: ../../c-api/init.rst:966 +#: ../../c-api/init.rst:970 msgid "" "The :c:macro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a " "hidden local variable; the :c:macro:`Py_END_ALLOW_THREADS` macro closes the " "block." msgstr "" -#: ../../c-api/init.rst:970 +#: ../../c-api/init.rst:974 msgid "The block above expands to the following code::" msgstr "" -#: ../../c-api/init.rst:972 +#: ../../c-api/init.rst:976 msgid "" "PyThreadState *_save;\n" "\n" @@ -1238,7 +1242,7 @@ msgid "" "PyEval_RestoreThread(_save);" msgstr "" -#: ../../c-api/init.rst:982 +#: ../../c-api/init.rst:986 msgid "" "Here is how these functions work: the global interpreter lock is used to " "protect the pointer to the current thread state. When releasing the lock " @@ -1249,7 +1253,7 @@ msgid "" "state, the lock must be acquired before storing the thread state pointer." msgstr "" -#: ../../c-api/init.rst:991 +#: ../../c-api/init.rst:995 msgid "" "Calling system I/O functions is the most common use case for releasing the " "GIL, but it can also be useful before calling long-running computations " @@ -1259,11 +1263,11 @@ msgid "" "compressing or hashing data." msgstr "" -#: ../../c-api/init.rst:1002 +#: ../../c-api/init.rst:1006 msgid "Non-Python created threads" msgstr "" -#: ../../c-api/init.rst:1004 +#: ../../c-api/init.rst:1008 msgid "" "When threads are created using the dedicated Python APIs (such as the :mod:" "`threading` module), a thread state is automatically associated to them and " @@ -1273,7 +1277,7 @@ msgid "" "for them." msgstr "" -#: ../../c-api/init.rst:1011 +#: ../../c-api/init.rst:1015 msgid "" "If you need to call Python code from these threads (often this will be part " "of a callback API provided by the aforementioned third-party library), you " @@ -1284,14 +1288,14 @@ msgid "" "finally free the thread state data structure." msgstr "" -#: ../../c-api/init.rst:1019 +#: ../../c-api/init.rst:1023 msgid "" "The :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` functions " "do all of the above automatically. The typical idiom for calling into " "Python from a C thread is::" msgstr "" -#: ../../c-api/init.rst:1023 +#: ../../c-api/init.rst:1027 msgid "" "PyGILState_STATE gstate;\n" "gstate = PyGILState_Ensure();\n" @@ -1304,7 +1308,7 @@ msgid "" "PyGILState_Release(gstate);" msgstr "" -#: ../../c-api/init.rst:1033 +#: ../../c-api/init.rst:1037 msgid "" "Note that the ``PyGILState_*`` functions assume there is only one global " "interpreter (created automatically by :c:func:`Py_Initialize`). Python " @@ -1313,11 +1317,11 @@ msgid "" "``PyGILState_*`` API is unsupported." msgstr "" -#: ../../c-api/init.rst:1043 +#: ../../c-api/init.rst:1047 msgid "Cautions about fork()" msgstr "" -#: ../../c-api/init.rst:1045 +#: ../../c-api/init.rst:1049 msgid "" "Another important thing to note about threads is their behaviour in the face " "of the C :c:func:`fork` call. On most systems with :c:func:`fork`, after a " @@ -1326,7 +1330,7 @@ msgid "" "CPython's runtime." msgstr "" -#: ../../c-api/init.rst:1051 +#: ../../c-api/init.rst:1055 msgid "" "The fact that only the \"current\" thread remains means any locks held by " "other threads will never be released. Python solves this for :func:`os.fork` " @@ -1343,7 +1347,7 @@ msgid "" "locks, but is not always able to." msgstr "" -#: ../../c-api/init.rst:1066 +#: ../../c-api/init.rst:1070 msgid "" "The fact that all other threads go away also means that CPython's runtime " "state there must be cleaned up properly, which :func:`os.fork` does. This " @@ -1356,17 +1360,56 @@ msgid "" "called immediately after." msgstr "" -#: ../../c-api/init.rst:1079 +#: ../../c-api/init.rst:1084 +msgid "Cautions regarding runtime finalization" +msgstr "" + +#: ../../c-api/init.rst:1086 +msgid "" +"In the late stage of :term:`interpreter shutdown`, after attempting to wait " +"for non-daemon threads to exit (though this can be interrupted by :class:" +"`KeyboardInterrupt`) and running the :mod:`atexit` functions, the runtime is " +"marked as *finalizing*: :c:func:`Py_IsFinalizing` and :func:`sys." +"is_finalizing` return true. At this point, only the *finalization thread* " +"that initiated finalization (typically the main thread) is allowed to " +"acquire the :term:`GIL`." +msgstr "" + +#: ../../c-api/init.rst:1094 +msgid "" +"If any thread, other than the finalization thread, attempts to acquire the " +"GIL during finalization, either explicitly via :c:func:`PyGILState_Ensure`, :" +"c:macro:`Py_END_ALLOW_THREADS`, :c:func:`PyEval_AcquireThread`, or :c:func:" +"`PyEval_AcquireLock`, or implicitly when the interpreter attempts to " +"reacquire it after having yielded it, the thread enters **a permanently " +"blocked state** where it remains until the program exits. In most cases " +"this is harmless, but this can result in deadlock if a later stage of " +"finalization attempts to acquire a lock owned by the blocked thread, or " +"otherwise waits on the blocked thread." +msgstr "" + +#: ../../c-api/init.rst:1104 +msgid "" +"Gross? Yes. This prevents random crashes and/or unexpectedly skipped C++ " +"finalizations further up the call stack when such threads were forcibly " +"exited here in CPython 3.13.7 and earlier. The CPython runtime GIL acquiring " +"C APIs have never had any error reporting or handling expectations at GIL " +"acquisition time that would've allowed for graceful exit from this " +"situation. Changing that would require new stable C APIs and rewriting the " +"majority of C code in the CPython ecosystem to use those with error handling." +msgstr "" + +#: ../../c-api/init.rst:1114 msgid "High-level API" msgstr "高階 API" -#: ../../c-api/init.rst:1081 +#: ../../c-api/init.rst:1116 msgid "" "These are the most commonly used types and functions when writing C " "extension code, or when embedding the Python interpreter:" msgstr "" -#: ../../c-api/init.rst:1086 +#: ../../c-api/init.rst:1121 msgid "" "This data structure represents the state shared by a number of cooperating " "threads. Threads belonging to the same interpreter share their module " @@ -1374,7 +1417,7 @@ msgid "" "in this structure." msgstr "" -#: ../../c-api/init.rst:1091 +#: ../../c-api/init.rst:1126 msgid "" "Threads belonging to different interpreters initially share nothing, except " "process state like available memory, open file descriptors and such. The " @@ -1382,41 +1425,41 @@ msgid "" "which interpreter they belong." msgstr "" -#: ../../c-api/init.rst:1099 +#: ../../c-api/init.rst:1134 msgid "" "This data structure represents the state of a single thread. The only " "public data member is:" msgstr "" -#: ../../c-api/init.rst:1104 +#: ../../c-api/init.rst:1139 msgid "This thread's interpreter state." msgstr "" -#: ../../c-api/init.rst:1115 +#: ../../c-api/init.rst:1150 msgid "Deprecated function which does nothing." msgstr "" -#: ../../c-api/init.rst:1117 +#: ../../c-api/init.rst:1152 msgid "" "In Python 3.6 and older, this function created the GIL if it didn't exist." msgstr "" -#: ../../c-api/init.rst:1119 +#: ../../c-api/init.rst:1154 msgid "The function now does nothing." msgstr "此函式現在不會做任何事情。" -#: ../../c-api/init.rst:1122 +#: ../../c-api/init.rst:1157 msgid "" "This function is now called by :c:func:`Py_Initialize()`, so you don't have " "to call it yourself anymore." msgstr "" -#: ../../c-api/init.rst:1126 +#: ../../c-api/init.rst:1161 msgid "" "This function cannot be called before :c:func:`Py_Initialize()` anymore." msgstr "" -#: ../../c-api/init.rst:1136 +#: ../../c-api/init.rst:1171 msgid "" "Release the global interpreter lock (if it has been created) and reset the " "thread state to ``NULL``, returning the previous thread state (which is not " @@ -1424,7 +1467,7 @@ msgid "" "acquired it." msgstr "" -#: ../../c-api/init.rst:1144 +#: ../../c-api/init.rst:1179 msgid "" "Acquire the global interpreter lock (if it has been created) and set the " "thread state to *tstate*, which must not be ``NULL``. If the lock has been " @@ -1432,59 +1475,65 @@ msgid "" "ensues." msgstr "" -#: ../../c-api/init.rst:1150 ../../c-api/init.rst:1210 -#: ../../c-api/init.rst:1506 +#: ../../c-api/init.rst:1185 ../../c-api/init.rst:1248 +#: ../../c-api/init.rst:1547 msgid "" -"Calling this function from a thread when the runtime is finalizing will " -"terminate the thread, even if the thread was not created by Python. You can " -"use :c:func:`Py_IsFinalizing` or :func:`sys.is_finalizing` to check if the " -"interpreter is in process of being finalized before calling this function to " -"avoid unwanted termination." +"Calling this function from a thread when the runtime is finalizing will hang " +"the thread until the program exits, even if the thread was not created by " +"Python. Refer to :ref:`cautions-regarding-runtime-finalization` for more " +"details." msgstr "" -#: ../../c-api/init.rst:1158 +#: ../../c-api/init.rst:1190 ../../c-api/init.rst:1253 +#: ../../c-api/init.rst:1557 +msgid "" +"Hangs the current thread, rather than terminating it, if called while the " +"interpreter is finalizing." +msgstr "" + +#: ../../c-api/init.rst:1196 msgid "" "Return the current thread state. The global interpreter lock must be held. " "When the current thread state is ``NULL``, this issues a fatal error (so " "that the caller needn't check for ``NULL``)." msgstr "" -#: ../../c-api/init.rst:1162 +#: ../../c-api/init.rst:1200 msgid "See also :c:func:`PyThreadState_GetUnchecked`." msgstr "也請見 :c:func:`PyThreadState_GetUnchecked`。" -#: ../../c-api/init.rst:1167 +#: ../../c-api/init.rst:1205 msgid "" "Similar to :c:func:`PyThreadState_Get`, but don't kill the process with a " "fatal error if it is NULL. The caller is responsible to check if the result " "is NULL." msgstr "" -#: ../../c-api/init.rst:1171 +#: ../../c-api/init.rst:1209 msgid "" "In Python 3.5 to 3.12, the function was private and known as " "``_PyThreadState_UncheckedGet()``." msgstr "" -#: ../../c-api/init.rst:1178 +#: ../../c-api/init.rst:1216 msgid "" "Swap the current thread state with the thread state given by the argument " "*tstate*, which may be ``NULL``." msgstr "" -#: ../../c-api/init.rst:1181 +#: ../../c-api/init.rst:1219 msgid "" "The :term:`GIL` does not need to be held, but will be held upon returning if " "*tstate* is non-``NULL``." msgstr "" -#: ../../c-api/init.rst:1184 +#: ../../c-api/init.rst:1222 msgid "" "The following functions use thread-local storage, and are not compatible " "with sub-interpreters:" msgstr "" -#: ../../c-api/init.rst:1189 +#: ../../c-api/init.rst:1227 msgid "" "Ensure that the current thread is ready to call the Python C API regardless " "of the current state of Python, or of the global interpreter lock. This may " @@ -1497,7 +1546,7 @@ msgid "" "is acceptable." msgstr "" -#: ../../c-api/init.rst:1199 +#: ../../c-api/init.rst:1237 msgid "" "The return value is an opaque \"handle\" to the thread state when :c:func:" "`PyGILState_Ensure` was called, and must be passed to :c:func:" @@ -1507,13 +1556,13 @@ msgid "" "func:`PyGILState_Release`." msgstr "" -#: ../../c-api/init.rst:1206 +#: ../../c-api/init.rst:1244 msgid "" "When the function returns, the current thread will hold the GIL and be able " "to call arbitrary Python code. Failure is a fatal error." msgstr "" -#: ../../c-api/init.rst:1218 +#: ../../c-api/init.rst:1259 msgid "" "Release any resources previously acquired. After this call, Python's state " "will be the same as it was prior to the corresponding :c:func:" @@ -1521,13 +1570,13 @@ msgid "" "caller, hence the use of the GILState API)." msgstr "" -#: ../../c-api/init.rst:1223 +#: ../../c-api/init.rst:1264 msgid "" "Every call to :c:func:`PyGILState_Ensure` must be matched by a call to :c:" "func:`PyGILState_Release` on the same thread." msgstr "" -#: ../../c-api/init.rst:1229 +#: ../../c-api/init.rst:1270 msgid "" "Get the current thread state for this thread. May return ``NULL`` if no " "GILState API has been used on the current thread. Note that the main thread " @@ -1535,7 +1584,7 @@ msgid "" "made on the main thread. This is mainly a helper/diagnostic function." msgstr "" -#: ../../c-api/init.rst:1237 +#: ../../c-api/init.rst:1278 msgid "" "Return ``1`` if the current thread is holding the GIL and ``0`` otherwise. " "This function can be called from any thread at any time. Only if it has had " @@ -1546,13 +1595,13 @@ msgid "" "otherwise behave differently." msgstr "" -#: ../../c-api/init.rst:1249 +#: ../../c-api/init.rst:1290 msgid "" "The following macros are normally used without a trailing semicolon; look " "for example usage in the Python source distribution." msgstr "" -#: ../../c-api/init.rst:1255 +#: ../../c-api/init.rst:1296 msgid "" "This macro expands to ``{ PyThreadState *_save; _save = PyEval_SaveThread();" "``. Note that it contains an opening brace; it must be matched with a " @@ -1560,7 +1609,7 @@ msgid "" "discussion of this macro." msgstr "" -#: ../../c-api/init.rst:1263 +#: ../../c-api/init.rst:1304 msgid "" "This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it " "contains a closing brace; it must be matched with an earlier :c:macro:" @@ -1568,40 +1617,40 @@ msgid "" "macro." msgstr "" -#: ../../c-api/init.rst:1271 +#: ../../c-api/init.rst:1312 msgid "" "This macro expands to ``PyEval_RestoreThread(_save);``: it is equivalent to :" "c:macro:`Py_END_ALLOW_THREADS` without the closing brace." msgstr "" -#: ../../c-api/init.rst:1277 +#: ../../c-api/init.rst:1318 msgid "" "This macro expands to ``_save = PyEval_SaveThread();``: it is equivalent to :" "c:macro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable " "declaration." msgstr "" -#: ../../c-api/init.rst:1283 +#: ../../c-api/init.rst:1324 msgid "Low-level API" msgstr "低階 API" -#: ../../c-api/init.rst:1285 +#: ../../c-api/init.rst:1326 msgid "" "All of the following functions must be called after :c:func:`Py_Initialize`." msgstr "" -#: ../../c-api/init.rst:1287 +#: ../../c-api/init.rst:1328 msgid ":c:func:`Py_Initialize()` now initializes the :term:`GIL`." msgstr "" -#: ../../c-api/init.rst:1293 +#: ../../c-api/init.rst:1334 msgid "" "Create a new interpreter state object. The global interpreter lock need not " "be held, but may be held if it is necessary to serialize calls to this " "function." msgstr "" -#: ../../c-api/init.rst:1297 +#: ../../c-api/init.rst:1338 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_New`` with no arguments." @@ -1609,13 +1658,13 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "PyInterpreterState_New``。" -#: ../../c-api/init.rst:1302 +#: ../../c-api/init.rst:1343 msgid "" "Reset all information in an interpreter state object. The global " "interpreter lock must be held." msgstr "" -#: ../../c-api/init.rst:1305 +#: ../../c-api/init.rst:1346 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_Clear`` with no arguments." @@ -1623,44 +1672,44 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "PyInterpreterState_Clear``。" -#: ../../c-api/init.rst:1310 +#: ../../c-api/init.rst:1351 msgid "" "Destroy an interpreter state object. The global interpreter lock need not " "be held. The interpreter state must have been reset with a previous call " "to :c:func:`PyInterpreterState_Clear`." msgstr "" -#: ../../c-api/init.rst:1317 +#: ../../c-api/init.rst:1358 msgid "" "Create a new thread state object belonging to the given interpreter object. " "The global interpreter lock need not be held, but may be held if it is " "necessary to serialize calls to this function." msgstr "" -#: ../../c-api/init.rst:1324 +#: ../../c-api/init.rst:1365 msgid "" "Reset all information in a thread state object. The global interpreter lock " "must be held." msgstr "" -#: ../../c-api/init.rst:1327 +#: ../../c-api/init.rst:1368 msgid "" "This function now calls the :c:member:`PyThreadState.on_delete` callback. " "Previously, that happened in :c:func:`PyThreadState_Delete`." msgstr "" -#: ../../c-api/init.rst:1331 +#: ../../c-api/init.rst:1372 msgid "The :c:member:`PyThreadState.on_delete` callback was removed." msgstr ":c:member:`PyThreadState.on_delete` 回呼已被移除。" -#: ../../c-api/init.rst:1337 +#: ../../c-api/init.rst:1378 msgid "" "Destroy a thread state object. The global interpreter lock need not be " "held. The thread state must have been reset with a previous call to :c:func:" "`PyThreadState_Clear`." msgstr "" -#: ../../c-api/init.rst:1344 +#: ../../c-api/init.rst:1385 msgid "" "Destroy the current thread state and release the global interpreter lock. " "Like :c:func:`PyThreadState_Delete`, the global interpreter lock must be " @@ -1668,126 +1717,126 @@ msgid "" "`PyThreadState_Clear`." msgstr "" -#: ../../c-api/init.rst:1352 +#: ../../c-api/init.rst:1393 msgid "Get the current frame of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1354 +#: ../../c-api/init.rst:1395 msgid "" "Return a :term:`strong reference`. Return ``NULL`` if no frame is currently " "executing." msgstr "" -#: ../../c-api/init.rst:1357 +#: ../../c-api/init.rst:1398 msgid "See also :c:func:`PyEval_GetFrame`." msgstr "也請見 :c:func:`PyEval_GetFrame`。" -#: ../../c-api/init.rst:1359 ../../c-api/init.rst:1368 -#: ../../c-api/init.rst:1377 +#: ../../c-api/init.rst:1400 ../../c-api/init.rst:1409 +#: ../../c-api/init.rst:1418 msgid "*tstate* must not be ``NULL``." msgstr "*tstate* 不可為 ``NULL``。" -#: ../../c-api/init.rst:1366 +#: ../../c-api/init.rst:1407 msgid "" "Get the unique thread state identifier of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1375 +#: ../../c-api/init.rst:1416 msgid "Get the interpreter of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1384 +#: ../../c-api/init.rst:1425 msgid "Suspend tracing and profiling in the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1386 +#: ../../c-api/init.rst:1427 msgid "Resume them using the :c:func:`PyThreadState_LeaveTracing` function." msgstr "" -#: ../../c-api/init.rst:1393 +#: ../../c-api/init.rst:1434 msgid "" "Resume tracing and profiling in the Python thread state *tstate* suspended " "by the :c:func:`PyThreadState_EnterTracing` function." msgstr "" -#: ../../c-api/init.rst:1396 +#: ../../c-api/init.rst:1437 msgid "" "See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile` functions." msgstr "" -#: ../../c-api/init.rst:1404 +#: ../../c-api/init.rst:1445 msgid "Get the current interpreter." msgstr "" -#: ../../c-api/init.rst:1406 +#: ../../c-api/init.rst:1447 msgid "" "Issue a fatal error if there no current Python thread state or no current " "interpreter. It cannot return NULL." msgstr "" -#: ../../c-api/init.rst:1409 ../../c-api/init.rst:1419 -#: ../../c-api/init.rst:1441 +#: ../../c-api/init.rst:1450 ../../c-api/init.rst:1460 +#: ../../c-api/init.rst:1482 msgid "The caller must hold the GIL." msgstr "" -#: ../../c-api/init.rst:1416 +#: ../../c-api/init.rst:1457 msgid "" "Return the interpreter's unique ID. If there was any error in doing so then " "``-1`` is returned and an error is set." msgstr "" -#: ../../c-api/init.rst:1426 +#: ../../c-api/init.rst:1467 msgid "" "Return a dictionary in which interpreter-specific data may be stored. If " "this function returns ``NULL`` then no exception has been raised and the " "caller should assume no interpreter-specific dict is available." msgstr "" -#: ../../c-api/init.rst:1430 +#: ../../c-api/init.rst:1471 msgid "" "This is not a replacement for :c:func:`PyModule_GetState()`, which " "extensions should use to store interpreter-specific state information." msgstr "" -#: ../../c-api/init.rst:1438 +#: ../../c-api/init.rst:1479 msgid "" "Return a :term:`strong reference` to the ``__main__`` :ref:`module object " "` for the given interpreter." msgstr "" -#: ../../c-api/init.rst:1448 +#: ../../c-api/init.rst:1489 msgid "Type of a frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1450 +#: ../../c-api/init.rst:1491 msgid "" "The *throwflag* parameter is used by the ``throw()`` method of generators: " "if non-zero, handle the current exception." msgstr "" -#: ../../c-api/init.rst:1453 +#: ../../c-api/init.rst:1494 msgid "The function now takes a *tstate* parameter." msgstr "" -#: ../../c-api/init.rst:1456 +#: ../../c-api/init.rst:1497 msgid "" "The *frame* parameter changed from ``PyFrameObject*`` to " "``_PyInterpreterFrame*``." msgstr "" -#: ../../c-api/init.rst:1461 +#: ../../c-api/init.rst:1502 msgid "Get the frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1463 ../../c-api/init.rst:1471 +#: ../../c-api/init.rst:1504 ../../c-api/init.rst:1512 msgid "See the :pep:`523` \"Adding a frame evaluation API to CPython\"." msgstr "" -#: ../../c-api/init.rst:1469 +#: ../../c-api/init.rst:1510 msgid "Set the frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1478 +#: ../../c-api/init.rst:1519 msgid "" "Return a dictionary in which extensions can store thread-specific state " "information. Each extension should use a unique key to use to store state " @@ -1796,7 +1845,7 @@ msgid "" "raised and the caller should assume no current thread state is available." msgstr "" -#: ../../c-api/init.rst:1487 +#: ../../c-api/init.rst:1528 msgid "" "Asynchronously raise an exception in a thread. The *id* argument is the " "thread id of the target thread; *exc* is the exception object to be raised. " @@ -1808,33 +1857,33 @@ msgid "" "raises no exceptions." msgstr "" -#: ../../c-api/init.rst:1495 +#: ../../c-api/init.rst:1536 msgid "" "The type of the *id* parameter changed from :c:expr:`long` to :c:expr:" "`unsigned long`." msgstr "" -#: ../../c-api/init.rst:1501 +#: ../../c-api/init.rst:1542 msgid "" "Acquire the global interpreter lock and set the current thread state to " "*tstate*, which must not be ``NULL``. The lock must have been created " "earlier. If this thread already has the lock, deadlock ensues." msgstr "" -#: ../../c-api/init.rst:1512 +#: ../../c-api/init.rst:1552 msgid "" "Updated to be consistent with :c:func:`PyEval_RestoreThread`, :c:func:" "`Py_END_ALLOW_THREADS`, and :c:func:`PyGILState_Ensure`, and terminate the " "current thread if called while the interpreter is finalizing." msgstr "" -#: ../../c-api/init.rst:1517 +#: ../../c-api/init.rst:1561 msgid "" ":c:func:`PyEval_RestoreThread` is a higher-level function which is always " "available (even when threads have not been initialized)." msgstr "" -#: ../../c-api/init.rst:1523 +#: ../../c-api/init.rst:1567 msgid "" "Reset the current thread state to ``NULL`` and release the global " "interpreter lock. The lock must have been created earlier and must be held " @@ -1843,17 +1892,17 @@ msgid "" "isn't, a fatal error is reported." msgstr "" -#: ../../c-api/init.rst:1529 +#: ../../c-api/init.rst:1573 msgid "" ":c:func:`PyEval_SaveThread` is a higher-level function which is always " "available (even when threads have not been initialized)." msgstr "" -#: ../../c-api/init.rst:1536 +#: ../../c-api/init.rst:1580 msgid "Sub-interpreter support" msgstr "" -#: ../../c-api/init.rst:1538 +#: ../../c-api/init.rst:1582 msgid "" "While in most uses, you will only embed a single Python interpreter, there " "are cases where you need to create several independent interpreters in the " @@ -1861,7 +1910,7 @@ msgid "" "to do that." msgstr "" -#: ../../c-api/init.rst:1543 +#: ../../c-api/init.rst:1587 msgid "" "The \"main\" interpreter is the first one created when the runtime " "initializes. It is usually the only Python interpreter in a process. Unlike " @@ -1872,31 +1921,31 @@ msgid "" "returns a pointer to its state." msgstr "" -#: ../../c-api/init.rst:1550 +#: ../../c-api/init.rst:1594 msgid "" "You can switch between sub-interpreters using the :c:func:" "`PyThreadState_Swap` function. You can create and destroy them using the " "following functions:" msgstr "" -#: ../../c-api/init.rst:1556 +#: ../../c-api/init.rst:1600 msgid "" "Structure containing most parameters to configure a sub-interpreter. Its " "values are used only in :c:func:`Py_NewInterpreterFromConfig` and never " "modified by the runtime." msgstr "" -#: ../../c-api/init.rst:1562 +#: ../../c-api/init.rst:1606 msgid "Structure fields:" msgstr "" -#: ../../c-api/init.rst:1566 +#: ../../c-api/init.rst:1610 msgid "" "If this is ``0`` then the sub-interpreter will use its own \"object\" " "allocator state. Otherwise it will use (share) the main interpreter's." msgstr "" -#: ../../c-api/init.rst:1570 +#: ../../c-api/init.rst:1614 msgid "" "If this is ``0`` then :c:member:`~PyInterpreterConfig." "check_multi_interp_extensions` must be ``1`` (non-zero). If this is ``1`` " @@ -1904,44 +1953,44 @@ msgid "" "`PyInterpreterConfig_OWN_GIL`." msgstr "" -#: ../../c-api/init.rst:1578 +#: ../../c-api/init.rst:1622 msgid "" "If this is ``0`` then the runtime will not support forking the process in " "any thread where the sub-interpreter is currently active. Otherwise fork is " "unrestricted." msgstr "" -#: ../../c-api/init.rst:1582 +#: ../../c-api/init.rst:1626 msgid "" "Note that the :mod:`subprocess` module still works when fork is disallowed." msgstr "" -#: ../../c-api/init.rst:1587 +#: ../../c-api/init.rst:1631 msgid "" "If this is ``0`` then the runtime will not support replacing the current " "process via exec (e.g. :func:`os.execv`) in any thread where the sub-" "interpreter is currently active. Otherwise exec is unrestricted." msgstr "" -#: ../../c-api/init.rst:1592 +#: ../../c-api/init.rst:1636 msgid "" "Note that the :mod:`subprocess` module still works when exec is disallowed." msgstr "" -#: ../../c-api/init.rst:1597 +#: ../../c-api/init.rst:1641 msgid "" "If this is ``0`` then the sub-interpreter's :mod:`threading` module won't " "create threads. Otherwise threads are allowed." msgstr "" -#: ../../c-api/init.rst:1603 +#: ../../c-api/init.rst:1647 msgid "" "If this is ``0`` then the sub-interpreter's :mod:`threading` module won't " "create daemon threads. Otherwise daemon threads are allowed (as long as :c:" "member:`~PyInterpreterConfig.allow_threads` is non-zero)." msgstr "" -#: ../../c-api/init.rst:1610 +#: ../../c-api/init.rst:1654 msgid "" "If this is ``0`` then all extension modules may be imported, including " "legacy (single-phase init) modules, in any thread where the sub-interpreter " @@ -1950,37 +1999,37 @@ msgid "" "`Py_mod_multiple_interpreters`.)" msgstr "" -#: ../../c-api/init.rst:1617 +#: ../../c-api/init.rst:1661 msgid "" "This must be ``1`` (non-zero) if :c:member:`~PyInterpreterConfig." "use_main_obmalloc` is ``0``." msgstr "" -#: ../../c-api/init.rst:1622 +#: ../../c-api/init.rst:1666 msgid "" "This determines the operation of the GIL for the sub-interpreter. It may be " "one of the following:" msgstr "" -#: ../../c-api/init.rst:1629 +#: ../../c-api/init.rst:1673 msgid "Use the default selection (:c:macro:`PyInterpreterConfig_SHARED_GIL`)." msgstr "" -#: ../../c-api/init.rst:1633 +#: ../../c-api/init.rst:1677 msgid "Use (share) the main interpreter's GIL." msgstr "" -#: ../../c-api/init.rst:1637 +#: ../../c-api/init.rst:1681 msgid "Use the sub-interpreter's own GIL." msgstr "" -#: ../../c-api/init.rst:1639 +#: ../../c-api/init.rst:1683 msgid "" "If this is :c:macro:`PyInterpreterConfig_OWN_GIL` then :c:member:" "`PyInterpreterConfig.use_main_obmalloc` must be ``0``." msgstr "" -#: ../../c-api/init.rst:1653 +#: ../../c-api/init.rst:1697 msgid "" "Create a new sub-interpreter. This is an (almost) totally separate " "environment for the execution of Python code. In particular, the new " @@ -1993,13 +2042,13 @@ msgid "" "underlying file descriptors)." msgstr "" -#: ../../c-api/init.rst:1663 +#: ../../c-api/init.rst:1707 msgid "" "The given *config* controls the options with which the interpreter is " "initialized." msgstr "" -#: ../../c-api/init.rst:1666 +#: ../../c-api/init.rst:1710 msgid "" "Upon success, *tstate_p* will be set to the first thread state created in " "the new sub-interpreter. This thread state is made in the current thread " @@ -2010,7 +2059,7 @@ msgid "" "state." msgstr "" -#: ../../c-api/init.rst:1675 +#: ../../c-api/init.rst:1719 msgid "" "Like all other Python/C API functions, the global interpreter lock must be " "held before calling this function and is still held when it returns. " @@ -2022,13 +2071,13 @@ msgid "" "released here." msgstr "" -#: ../../c-api/init.rst:1686 +#: ../../c-api/init.rst:1730 msgid "" "Sub-interpreters are most effective when isolated from each other, with " "certain functionality restricted::" msgstr "" -#: ../../c-api/init.rst:1689 +#: ../../c-api/init.rst:1733 msgid "" "PyInterpreterConfig config = {\n" " .use_main_obmalloc = 0,\n" @@ -2060,7 +2109,7 @@ msgstr "" " Py_ExitStatusException(status);\n" "}" -#: ../../c-api/init.rst:1704 +#: ../../c-api/init.rst:1748 msgid "" "Note that the config is used only briefly and does not get modified. During " "initialization the config's values are converted into various :c:type:" @@ -2068,11 +2117,11 @@ msgid "" "internally on the :c:type:`PyInterpreterState`." msgstr "" -#: ../../c-api/init.rst:1713 +#: ../../c-api/init.rst:1757 msgid "Extension modules are shared between (sub-)interpreters as follows:" msgstr "" -#: ../../c-api/init.rst:1715 +#: ../../c-api/init.rst:1759 msgid "" "For modules using multi-phase initialization, e.g. :c:func:" "`PyModule_FromDefAndSpec`, a separate module object is created and " @@ -2080,7 +2129,7 @@ msgid "" "are shared between these module objects." msgstr "" -#: ../../c-api/init.rst:1721 +#: ../../c-api/init.rst:1765 msgid "" "For modules using single-phase initialization, e.g. :c:func:" "`PyModule_Create`, the first time a particular extension is imported, it is " @@ -2092,7 +2141,7 @@ msgid "" "might cause unwanted behavior (see `Bugs and caveats`_ below)." msgstr "" -#: ../../c-api/init.rst:1732 +#: ../../c-api/init.rst:1776 msgid "" "Note that this is different from what happens when an extension is imported " "after the interpreter has been completely re-initialized by calling :c:func:" @@ -2102,7 +2151,7 @@ msgid "" "shared between these modules." msgstr "" -#: ../../c-api/init.rst:1752 +#: ../../c-api/init.rst:1796 msgid "" "Create a new sub-interpreter. This is essentially just a wrapper around :c:" "func:`Py_NewInterpreterFromConfig` with a config that preserves the existing " @@ -2111,7 +2160,7 @@ msgid "" "single-phase init modules." msgstr "" -#: ../../c-api/init.rst:1764 +#: ../../c-api/init.rst:1808 msgid "" "Destroy the (sub-)interpreter represented by the given thread state. The " "given thread state must be the current thread state. See the discussion of " @@ -2121,17 +2170,17 @@ msgid "" "be held before calling this function. No GIL is held when it returns." msgstr "" -#: ../../c-api/init.rst:1772 +#: ../../c-api/init.rst:1816 msgid "" ":c:func:`Py_FinalizeEx` will destroy all sub-interpreters that haven't been " "explicitly destroyed at that point." msgstr "" -#: ../../c-api/init.rst:1777 +#: ../../c-api/init.rst:1821 msgid "A Per-Interpreter GIL" msgstr "直譯器各別持有的 GIL" -#: ../../c-api/init.rst:1779 +#: ../../c-api/init.rst:1823 msgid "" "Using :c:func:`Py_NewInterpreterFromConfig` you can create a sub-interpreter " "that is completely isolated from other interpreters, including having its " @@ -2143,7 +2192,7 @@ msgid "" "just using threads. (See :pep:`554`.)" msgstr "" -#: ../../c-api/init.rst:1789 +#: ../../c-api/init.rst:1833 msgid "" "Using an isolated interpreter requires vigilance in preserving that " "isolation. That especially means not sharing any objects or mutable state " @@ -2157,7 +2206,7 @@ msgid "" "builtin objects." msgstr "" -#: ../../c-api/init.rst:1800 +#: ../../c-api/init.rst:1844 msgid "" "If you preserve isolation then you will have access to proper multi-core " "computing without the complications that come with free-threading. Failure " @@ -2165,7 +2214,7 @@ msgid "" "threading, including races and hard-to-debug crashes." msgstr "" -#: ../../c-api/init.rst:1805 +#: ../../c-api/init.rst:1849 msgid "" "Aside from that, one of the main challenges of using multiple isolated " "interpreters is how to communicate between them safely (not break isolation) " @@ -2175,11 +2224,11 @@ msgid "" "sharing) data between interpreters." msgstr "" -#: ../../c-api/init.rst:1816 +#: ../../c-api/init.rst:1860 msgid "Bugs and caveats" msgstr "" -#: ../../c-api/init.rst:1818 +#: ../../c-api/init.rst:1862 msgid "" "Because sub-interpreters (and the main interpreter) are part of the same " "process, the insulation between them isn't perfect --- for example, using " @@ -2192,7 +2241,7 @@ msgid "" "should be avoided if possible." msgstr "" -#: ../../c-api/init.rst:1828 +#: ../../c-api/init.rst:1872 msgid "" "Special care should be taken to avoid sharing user-defined functions, " "methods, instances or classes between sub-interpreters, since import " @@ -2201,7 +2250,7 @@ msgid "" "objects from which the above are reachable." msgstr "" -#: ../../c-api/init.rst:1834 +#: ../../c-api/init.rst:1878 msgid "" "Also note that combining this functionality with ``PyGILState_*`` APIs is " "delicate, because these APIs assume a bijection between Python thread states " @@ -2213,25 +2262,25 @@ msgid "" "created threads will probably be broken when using sub-interpreters." msgstr "" -#: ../../c-api/init.rst:1845 +#: ../../c-api/init.rst:1889 msgid "Asynchronous Notifications" msgstr "" -#: ../../c-api/init.rst:1847 +#: ../../c-api/init.rst:1891 msgid "" "A mechanism is provided to make asynchronous notifications to the main " "interpreter thread. These notifications take the form of a function pointer " "and a void pointer argument." msgstr "" -#: ../../c-api/init.rst:1854 +#: ../../c-api/init.rst:1898 msgid "" "Schedule a function to be called from the main interpreter thread. On " "success, ``0`` is returned and *func* is queued for being called in the main " "thread. On failure, ``-1`` is returned without setting any exception." msgstr "" -#: ../../c-api/init.rst:1858 +#: ../../c-api/init.rst:1902 msgid "" "When successfully queued, *func* will be *eventually* called from the main " "interpreter thread with the argument *arg*. It will be called " @@ -2239,17 +2288,17 @@ msgid "" "these conditions met:" msgstr "" -#: ../../c-api/init.rst:1863 +#: ../../c-api/init.rst:1907 msgid "on a :term:`bytecode` boundary;" msgstr "" -#: ../../c-api/init.rst:1864 +#: ../../c-api/init.rst:1908 msgid "" "with the main thread holding the :term:`global interpreter lock` (*func* can " "therefore use the full C API)." msgstr "" -#: ../../c-api/init.rst:1867 +#: ../../c-api/init.rst:1911 msgid "" "*func* must return ``0`` on success, or ``-1`` on failure with an exception " "set. *func* won't be interrupted to perform another asynchronous " @@ -2257,20 +2306,20 @@ msgid "" "if the global interpreter lock is released." msgstr "" -#: ../../c-api/init.rst:1872 +#: ../../c-api/init.rst:1916 msgid "" "This function doesn't need a current thread state to run, and it doesn't " "need the global interpreter lock." msgstr "" -#: ../../c-api/init.rst:1875 +#: ../../c-api/init.rst:1919 msgid "" "To call this function in a subinterpreter, the caller must hold the GIL. " "Otherwise, the function *func* can be scheduled to be called from the wrong " "interpreter." msgstr "" -#: ../../c-api/init.rst:1880 +#: ../../c-api/init.rst:1924 msgid "" "This is a low-level function, only useful for very special cases. There is " "no guarantee that *func* will be called as quick as possible. If the main " @@ -2280,7 +2329,7 @@ msgid "" "`PyGILState API`." msgstr "" -#: ../../c-api/init.rst:1889 +#: ../../c-api/init.rst:1933 msgid "" "If this function is called in a subinterpreter, the function *func* is now " "scheduled to be called from the subinterpreter, rather than being called " @@ -2288,18 +2337,18 @@ msgid "" "scheduled calls." msgstr "" -#: ../../c-api/init.rst:1898 +#: ../../c-api/init.rst:1942 msgid "Profiling and Tracing" msgstr "" -#: ../../c-api/init.rst:1903 +#: ../../c-api/init.rst:1947 msgid "" "The Python interpreter provides some low-level support for attaching " "profiling and execution tracing facilities. These are used for profiling, " "debugging, and coverage analysis tools." msgstr "" -#: ../../c-api/init.rst:1907 +#: ../../c-api/init.rst:1951 msgid "" "This C interface allows the profiling or tracing code to avoid the overhead " "of calling through Python-level callable objects, making a direct C function " @@ -2309,7 +2358,7 @@ msgid "" "reported to the Python-level trace functions in previous versions." msgstr "" -#: ../../c-api/init.rst:1917 +#: ../../c-api/init.rst:1961 msgid "" "The type of the trace function registered using :c:func:`PyEval_SetProfile` " "and :c:func:`PyEval_SetTrace`. The first parameter is the object passed to " @@ -2321,66 +2370,66 @@ msgid "" "value of *what*:" msgstr "" -#: ../../c-api/init.rst:1926 +#: ../../c-api/init.rst:1970 msgid "Value of *what*" msgstr "" -#: ../../c-api/init.rst:1926 +#: ../../c-api/init.rst:1970 msgid "Meaning of *arg*" msgstr "*arg* 的含義" -#: ../../c-api/init.rst:1928 +#: ../../c-api/init.rst:1972 msgid ":c:data:`PyTrace_CALL`" msgstr ":c:data:`PyTrace_CALL`" -#: ../../c-api/init.rst:1928 ../../c-api/init.rst:1933 -#: ../../c-api/init.rst:1944 +#: ../../c-api/init.rst:1972 ../../c-api/init.rst:1977 +#: ../../c-api/init.rst:1988 msgid "Always :c:data:`Py_None`." msgstr "" -#: ../../c-api/init.rst:1930 +#: ../../c-api/init.rst:1974 msgid ":c:data:`PyTrace_EXCEPTION`" msgstr ":c:data:`PyTrace_EXCEPTION`" -#: ../../c-api/init.rst:1930 +#: ../../c-api/init.rst:1974 msgid "Exception information as returned by :func:`sys.exc_info`." msgstr "" -#: ../../c-api/init.rst:1933 +#: ../../c-api/init.rst:1977 msgid ":c:data:`PyTrace_LINE`" msgstr ":c:data:`PyTrace_LINE`" -#: ../../c-api/init.rst:1935 +#: ../../c-api/init.rst:1979 msgid ":c:data:`PyTrace_RETURN`" msgstr ":c:data:`PyTrace_RETURN`" -#: ../../c-api/init.rst:1935 +#: ../../c-api/init.rst:1979 msgid "" "Value being returned to the caller, or ``NULL`` if caused by an exception." msgstr "" -#: ../../c-api/init.rst:1938 +#: ../../c-api/init.rst:1982 msgid ":c:data:`PyTrace_C_CALL`" msgstr ":c:data:`PyTrace_C_CALL`" -#: ../../c-api/init.rst:1938 ../../c-api/init.rst:1940 -#: ../../c-api/init.rst:1942 +#: ../../c-api/init.rst:1982 ../../c-api/init.rst:1984 +#: ../../c-api/init.rst:1986 msgid "Function object being called." msgstr "被呼叫的函式物件。" -#: ../../c-api/init.rst:1940 +#: ../../c-api/init.rst:1984 msgid ":c:data:`PyTrace_C_EXCEPTION`" msgstr ":c:data:`PyTrace_C_EXCEPTION`" -#: ../../c-api/init.rst:1942 +#: ../../c-api/init.rst:1986 msgid ":c:data:`PyTrace_C_RETURN`" msgstr ":c:data:`PyTrace_C_RETURN`" -#: ../../c-api/init.rst:1944 +#: ../../c-api/init.rst:1988 msgid ":c:data:`PyTrace_OPCODE`" msgstr ":c:data:`PyTrace_OPCODE`" -#: ../../c-api/init.rst:1949 +#: ../../c-api/init.rst:1993 msgid "" "The value of the *what* parameter to a :c:type:`Py_tracefunc` function when " "a new call to a function or method is being reported, or a new entry into a " @@ -2389,7 +2438,7 @@ msgid "" "the corresponding frame." msgstr "" -#: ../../c-api/init.rst:1958 +#: ../../c-api/init.rst:2002 msgid "" "The value of the *what* parameter to a :c:type:`Py_tracefunc` function when " "an exception has been raised. The callback function is called with this " @@ -2401,7 +2450,7 @@ msgid "" "profiler." msgstr "" -#: ../../c-api/init.rst:1969 +#: ../../c-api/init.rst:2013 msgid "" "The value passed as the *what* parameter to a :c:type:`Py_tracefunc` " "function (but not a profiling function) when a line-number event is being " @@ -2409,31 +2458,31 @@ msgid "" "f_trace_lines` to *0* on that frame." msgstr "" -#: ../../c-api/init.rst:1977 +#: ../../c-api/init.rst:2021 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a call is about to return." msgstr "" -#: ../../c-api/init.rst:1983 +#: ../../c-api/init.rst:2027 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function is about to be called." msgstr "" -#: ../../c-api/init.rst:1989 +#: ../../c-api/init.rst:2033 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function has raised an exception." msgstr "" -#: ../../c-api/init.rst:1995 +#: ../../c-api/init.rst:2039 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function has returned." msgstr "" -#: ../../c-api/init.rst:2001 +#: ../../c-api/init.rst:2045 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions (but " "not profiling functions) when a new opcode is about to be executed. This " @@ -2441,7 +2490,7 @@ msgid "" "attr:`~frame.f_trace_opcodes` to *1* on the frame." msgstr "" -#: ../../c-api/init.rst:2009 +#: ../../c-api/init.rst:2053 msgid "" "Set the profiler function to *func*. The *obj* parameter is passed to the " "function as its first parameter, and may be any Python object, or ``NULL``. " @@ -2451,29 +2500,29 @@ msgid "" "`PyTrace_LINE` :c:data:`PyTrace_OPCODE` and :c:data:`PyTrace_EXCEPTION`." msgstr "" -#: ../../c-api/init.rst:2016 +#: ../../c-api/init.rst:2060 msgid "See also the :func:`sys.setprofile` function." msgstr "另請參閱 :func:`sys.setprofile` 函式。" -#: ../../c-api/init.rst:2018 ../../c-api/init.rst:2025 -#: ../../c-api/init.rst:2044 ../../c-api/init.rst:2051 +#: ../../c-api/init.rst:2062 ../../c-api/init.rst:2069 +#: ../../c-api/init.rst:2088 ../../c-api/init.rst:2095 msgid "The caller must hold the :term:`GIL`." msgstr "呼叫者必須持有 :term:`GIL`。" -#: ../../c-api/init.rst:2022 +#: ../../c-api/init.rst:2066 msgid "" "Like :c:func:`PyEval_SetProfile` but sets the profile function in all " "running threads belonging to the current interpreter instead of the setting " "it only on the current thread." msgstr "" -#: ../../c-api/init.rst:2027 +#: ../../c-api/init.rst:2071 msgid "" "As :c:func:`PyEval_SetProfile`, this function ignores any exceptions raised " "while setting the profile functions in all threads." msgstr "" -#: ../../c-api/init.rst:2035 +#: ../../c-api/init.rst:2079 msgid "" "Set the tracing function to *func*. This is similar to :c:func:" "`PyEval_SetProfile`, except the tracing function does receive line-number " @@ -2484,28 +2533,28 @@ msgid "" "*what* parameter." msgstr "" -#: ../../c-api/init.rst:2042 +#: ../../c-api/init.rst:2086 msgid "See also the :func:`sys.settrace` function." msgstr "也請見 :func:`sys.settrace` 函式。" -#: ../../c-api/init.rst:2048 +#: ../../c-api/init.rst:2092 msgid "" "Like :c:func:`PyEval_SetTrace` but sets the tracing function in all running " "threads belonging to the current interpreter instead of the setting it only " "on the current thread." msgstr "" -#: ../../c-api/init.rst:2053 +#: ../../c-api/init.rst:2097 msgid "" "As :c:func:`PyEval_SetTrace`, this function ignores any exceptions raised " "while setting the trace functions in all threads." msgstr "" -#: ../../c-api/init.rst:2059 +#: ../../c-api/init.rst:2103 msgid "Reference tracing" msgstr "" -#: ../../c-api/init.rst:2065 +#: ../../c-api/init.rst:2109 msgid "" "The type of the trace function registered using :c:func:" "`PyRefTracer_SetTracer`. The first parameter is a Python object that has " @@ -2515,19 +2564,19 @@ msgid "" "provided when :c:func:`PyRefTracer_SetTracer` was called." msgstr "" -#: ../../c-api/init.rst:2075 +#: ../../c-api/init.rst:2119 msgid "" "The value for the *event* parameter to :c:type:`PyRefTracer` functions when " "a Python object has been created." msgstr "" -#: ../../c-api/init.rst:2080 +#: ../../c-api/init.rst:2124 msgid "" "The value for the *event* parameter to :c:type:`PyRefTracer` functions when " "a Python object has been destroyed." msgstr "" -#: ../../c-api/init.rst:2085 +#: ../../c-api/init.rst:2129 msgid "" "Register a reference tracer function. The function will be called when a new " "Python has been created or when an object is going to be destroyed. If " @@ -2536,7 +2585,7 @@ msgid "" "return ``-1`` on error." msgstr "" -#: ../../c-api/init.rst:2091 +#: ../../c-api/init.rst:2135 msgid "" "Not that tracer functions **must not** create Python objects inside or " "otherwise the call will be re-entrant. The tracer also **must not** clear " @@ -2544,11 +2593,11 @@ msgid "" "the tracer function is called." msgstr "" -#: ../../c-api/init.rst:2096 ../../c-api/init.rst:2107 +#: ../../c-api/init.rst:2140 ../../c-api/init.rst:2151 msgid "The GIL must be held when calling this function." msgstr "" -#: ../../c-api/init.rst:2102 +#: ../../c-api/init.rst:2146 msgid "" "Get the registered reference tracer function and the value of the opaque " "data pointer that was registered when :c:func:`PyRefTracer_SetTracer` was " @@ -2556,48 +2605,48 @@ msgid "" "set the **data** pointer to NULL." msgstr "" -#: ../../c-api/init.rst:2114 +#: ../../c-api/init.rst:2158 msgid "Advanced Debugger Support" msgstr "" -#: ../../c-api/init.rst:2119 +#: ../../c-api/init.rst:2163 msgid "" "These functions are only intended to be used by advanced debugging tools." msgstr "" -#: ../../c-api/init.rst:2124 +#: ../../c-api/init.rst:2168 msgid "" "Return the interpreter state object at the head of the list of all such " "objects." msgstr "" -#: ../../c-api/init.rst:2129 +#: ../../c-api/init.rst:2173 msgid "Return the main interpreter state object." msgstr "" -#: ../../c-api/init.rst:2134 +#: ../../c-api/init.rst:2178 msgid "" "Return the next interpreter state object after *interp* from the list of all " "such objects." msgstr "" -#: ../../c-api/init.rst:2140 +#: ../../c-api/init.rst:2184 msgid "" "Return the pointer to the first :c:type:`PyThreadState` object in the list " "of threads associated with the interpreter *interp*." msgstr "" -#: ../../c-api/init.rst:2146 +#: ../../c-api/init.rst:2190 msgid "" "Return the next thread state object after *tstate* from the list of all such " "objects belonging to the same :c:type:`PyInterpreterState` object." msgstr "" -#: ../../c-api/init.rst:2153 +#: ../../c-api/init.rst:2197 msgid "Thread Local Storage Support" msgstr "" -#: ../../c-api/init.rst:2157 +#: ../../c-api/init.rst:2201 msgid "" "The Python interpreter provides low-level support for thread-local storage " "(TLS) which wraps the underlying native TLS implementation to support the " @@ -2607,19 +2656,19 @@ msgid "" "thread." msgstr "" -#: ../../c-api/init.rst:2164 +#: ../../c-api/init.rst:2208 msgid "" "The GIL does *not* need to be held when calling these functions; they supply " "their own locking." msgstr "" -#: ../../c-api/init.rst:2167 +#: ../../c-api/init.rst:2211 msgid "" "Note that :file:`Python.h` does not include the declaration of the TLS APIs, " "you need to include :file:`pythread.h` to use thread-local storage." msgstr "" -#: ../../c-api/init.rst:2171 +#: ../../c-api/init.rst:2215 msgid "" "None of these API functions handle memory management on behalf of the :c:" "expr:`void*` values. You need to allocate and deallocate them yourself. If " @@ -2627,22 +2676,22 @@ msgid "" "don't do refcount operations on them either." msgstr "" -#: ../../c-api/init.rst:2179 +#: ../../c-api/init.rst:2223 msgid "Thread Specific Storage (TSS) API" msgstr "" -#: ../../c-api/init.rst:2181 +#: ../../c-api/init.rst:2225 msgid "" "TSS API is introduced to supersede the use of the existing TLS API within " "the CPython interpreter. This API uses a new type :c:type:`Py_tss_t` " "instead of :c:expr:`int` to represent thread keys." msgstr "" -#: ../../c-api/init.rst:2187 +#: ../../c-api/init.rst:2231 msgid "\"A New C-API for Thread-Local Storage in CPython\" (:pep:`539`)" msgstr "" -#: ../../c-api/init.rst:2192 +#: ../../c-api/init.rst:2236 msgid "" "This data structure represents the state of a thread key, the definition of " "which may depend on the underlying TLS implementation, and it has an " @@ -2650,52 +2699,52 @@ msgid "" "public members in this structure." msgstr "" -#: ../../c-api/init.rst:2197 +#: ../../c-api/init.rst:2241 msgid "" "When :ref:`Py_LIMITED_API ` is not defined, static allocation of " "this type by :c:macro:`Py_tss_NEEDS_INIT` is allowed." msgstr "" -#: ../../c-api/init.rst:2203 +#: ../../c-api/init.rst:2247 msgid "" "This macro expands to the initializer for :c:type:`Py_tss_t` variables. Note " "that this macro won't be defined with :ref:`Py_LIMITED_API `." msgstr "" -#: ../../c-api/init.rst:2208 +#: ../../c-api/init.rst:2252 msgid "Dynamic Allocation" msgstr "" -#: ../../c-api/init.rst:2210 +#: ../../c-api/init.rst:2254 msgid "" "Dynamic allocation of the :c:type:`Py_tss_t`, required in extension modules " "built with :ref:`Py_LIMITED_API `, where static allocation of this " "type is not possible due to its implementation being opaque at build time." msgstr "" -#: ../../c-api/init.rst:2217 +#: ../../c-api/init.rst:2261 msgid "" "Return a value which is the same state as a value initialized with :c:macro:" "`Py_tss_NEEDS_INIT`, or ``NULL`` in the case of dynamic allocation failure." msgstr "" -#: ../../c-api/init.rst:2224 +#: ../../c-api/init.rst:2268 msgid "" "Free the given *key* allocated by :c:func:`PyThread_tss_alloc`, after first " "calling :c:func:`PyThread_tss_delete` to ensure any associated thread locals " "have been unassigned. This is a no-op if the *key* argument is ``NULL``." msgstr "" -#: ../../c-api/init.rst:2230 +#: ../../c-api/init.rst:2274 msgid "" "A freed key becomes a dangling pointer. You should reset the key to ``NULL``." msgstr "" -#: ../../c-api/init.rst:2235 +#: ../../c-api/init.rst:2279 msgid "Methods" msgstr "方法" -#: ../../c-api/init.rst:2237 +#: ../../c-api/init.rst:2281 msgid "" "The parameter *key* of these functions must not be ``NULL``. Moreover, the " "behaviors of :c:func:`PyThread_tss_set` and :c:func:`PyThread_tss_get` are " @@ -2703,13 +2752,13 @@ msgid "" "func:`PyThread_tss_create`." msgstr "" -#: ../../c-api/init.rst:2245 +#: ../../c-api/init.rst:2289 msgid "" "Return a non-zero value if the given :c:type:`Py_tss_t` has been initialized " "by :c:func:`PyThread_tss_create`." msgstr "" -#: ../../c-api/init.rst:2251 +#: ../../c-api/init.rst:2295 msgid "" "Return a zero value on successful initialization of a TSS key. The behavior " "is undefined if the value pointed to by the *key* argument is not " @@ -2718,7 +2767,7 @@ msgid "" "no-op and immediately returns success." msgstr "" -#: ../../c-api/init.rst:2260 +#: ../../c-api/init.rst:2304 msgid "" "Destroy a TSS key to forget the values associated with the key across all " "threads, and change the key's initialization state to uninitialized. A " @@ -2727,31 +2776,31 @@ msgid "" "key -- calling it on an already destroyed key is a no-op." msgstr "" -#: ../../c-api/init.rst:2269 +#: ../../c-api/init.rst:2313 msgid "" "Return a zero value to indicate successfully associating a :c:expr:`void*` " "value with a TSS key in the current thread. Each thread has a distinct " "mapping of the key to a :c:expr:`void*` value." msgstr "" -#: ../../c-api/init.rst:2276 +#: ../../c-api/init.rst:2320 msgid "" "Return the :c:expr:`void*` value associated with a TSS key in the current " "thread. This returns ``NULL`` if no value is associated with the key in the " "current thread." msgstr "" -#: ../../c-api/init.rst:2284 +#: ../../c-api/init.rst:2328 msgid "Thread Local Storage (TLS) API" msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" -#: ../../c-api/init.rst:2286 +#: ../../c-api/init.rst:2330 msgid "" "This API is superseded by :ref:`Thread Specific Storage (TSS) API `." msgstr "" -#: ../../c-api/init.rst:2291 +#: ../../c-api/init.rst:2335 msgid "" "This version of the API does not support platforms where the native TLS key " "is defined in a way that cannot be safely cast to ``int``. On such " @@ -2760,62 +2809,62 @@ msgid "" "platforms." msgstr "" -#: ../../c-api/init.rst:2296 +#: ../../c-api/init.rst:2340 msgid "" "Due to the compatibility problem noted above, this version of the API should " "not be used in new code." msgstr "" -#: ../../c-api/init.rst:2307 +#: ../../c-api/init.rst:2351 msgid "Synchronization Primitives" msgstr "" -#: ../../c-api/init.rst:2309 +#: ../../c-api/init.rst:2353 msgid "The C-API provides a basic mutual exclusion lock." msgstr "" -#: ../../c-api/init.rst:2313 +#: ../../c-api/init.rst:2357 msgid "" "A mutual exclusion lock. The :c:type:`!PyMutex` should be initialized to " "zero to represent the unlocked state. For example::" msgstr "" -#: ../../c-api/init.rst:2316 +#: ../../c-api/init.rst:2360 msgid "PyMutex mutex = {0};" msgstr "" -#: ../../c-api/init.rst:2318 +#: ../../c-api/init.rst:2362 msgid "" "Instances of :c:type:`!PyMutex` should not be copied or moved. Both the " "contents and address of a :c:type:`!PyMutex` are meaningful, and it must " "remain at a fixed, writable location in memory." msgstr "" -#: ../../c-api/init.rst:2324 +#: ../../c-api/init.rst:2368 msgid "" "A :c:type:`!PyMutex` currently occupies one byte, but the size should be " "considered unstable. The size may change in future Python releases without " "a deprecation period." msgstr "" -#: ../../c-api/init.rst:2332 +#: ../../c-api/init.rst:2376 msgid "" "Lock mutex *m*. If another thread has already locked it, the calling thread " "will block until the mutex is unlocked. While blocked, the thread will " "temporarily release the :term:`GIL` if it is held." msgstr "" -#: ../../c-api/init.rst:2340 +#: ../../c-api/init.rst:2384 msgid "" "Unlock mutex *m*. The mutex must be locked --- otherwise, the function will " "issue a fatal error." msgstr "" -#: ../../c-api/init.rst:2348 +#: ../../c-api/init.rst:2392 msgid "Python Critical Section API" msgstr "" -#: ../../c-api/init.rst:2350 +#: ../../c-api/init.rst:2394 msgid "" "The critical section API provides a deadlock avoidance layer on top of per-" "object locks for :term:`free-threaded ` CPython. They are " @@ -2823,7 +2872,7 @@ msgid "" "no-ops in versions of Python with the global interpreter lock." msgstr "" -#: ../../c-api/init.rst:2355 +#: ../../c-api/init.rst:2399 msgid "" "Critical sections avoid deadlocks by implicitly suspending active critical " "sections and releasing the locks during calls to :c:func:" @@ -2833,7 +2882,7 @@ msgid "" "-- they are useful because their behavior is similar to the :term:`GIL`." msgstr "" -#: ../../c-api/init.rst:2362 +#: ../../c-api/init.rst:2406 msgid "" "The functions and structs used by the macros are exposed for cases where C " "macros are not available. They should only be used as in the given macro " @@ -2841,7 +2890,7 @@ msgid "" "future Python versions." msgstr "" -#: ../../c-api/init.rst:2369 +#: ../../c-api/init.rst:2413 msgid "" "Operations that need to lock two objects at once must use :c:macro:" "`Py_BEGIN_CRITICAL_SECTION2`. You *cannot* use nested critical sections to " @@ -2850,11 +2899,11 @@ msgid "" "lock more than two objects at once." msgstr "" -#: ../../c-api/init.rst:2375 +#: ../../c-api/init.rst:2419 msgid "Example usage::" msgstr "" -#: ../../c-api/init.rst:2377 +#: ../../c-api/init.rst:2421 msgid "" "static PyObject *\n" "set_field(MyObject *self, PyObject *value)\n" @@ -2866,7 +2915,7 @@ msgid "" "}" msgstr "" -#: ../../c-api/init.rst:2386 +#: ../../c-api/init.rst:2430 msgid "" "In the above example, :c:macro:`Py_SETREF` calls :c:macro:`Py_DECREF`, which " "can call arbitrary code through an object's deallocation function. The " @@ -2876,61 +2925,61 @@ msgid "" "`PyEval_SaveThread`." msgstr "" -#: ../../c-api/init.rst:2394 +#: ../../c-api/init.rst:2438 msgid "" "Acquires the per-object lock for the object *op* and begins a critical " "section." msgstr "" -#: ../../c-api/init.rst:2397 ../../c-api/init.rst:2411 -#: ../../c-api/init.rst:2426 ../../c-api/init.rst:2440 +#: ../../c-api/init.rst:2441 ../../c-api/init.rst:2455 +#: ../../c-api/init.rst:2470 ../../c-api/init.rst:2484 msgid "In the free-threaded build, this macro expands to::" msgstr "" -#: ../../c-api/init.rst:2399 +#: ../../c-api/init.rst:2443 msgid "" "{\n" " PyCriticalSection _py_cs;\n" " PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))" msgstr "" -#: ../../c-api/init.rst:2403 ../../c-api/init.rst:2432 +#: ../../c-api/init.rst:2447 ../../c-api/init.rst:2476 msgid "In the default build, this macro expands to ``{``." msgstr "" -#: ../../c-api/init.rst:2409 +#: ../../c-api/init.rst:2453 msgid "Ends the critical section and releases the per-object lock." msgstr "" -#: ../../c-api/init.rst:2413 +#: ../../c-api/init.rst:2457 msgid "" " PyCriticalSection_End(&_py_cs);\n" "}" msgstr "" -#: ../../c-api/init.rst:2416 ../../c-api/init.rst:2445 +#: ../../c-api/init.rst:2460 ../../c-api/init.rst:2489 msgid "In the default build, this macro expands to ``}``." msgstr "" -#: ../../c-api/init.rst:2422 +#: ../../c-api/init.rst:2466 msgid "" "Acquires the per-objects locks for the objects *a* and *b* and begins a " "critical section. The locks are acquired in a consistent order (lowest " "address first) to avoid lock ordering deadlocks." msgstr "" -#: ../../c-api/init.rst:2428 +#: ../../c-api/init.rst:2472 msgid "" "{\n" " PyCriticalSection2 _py_cs2;\n" " PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))" msgstr "" -#: ../../c-api/init.rst:2438 +#: ../../c-api/init.rst:2482 msgid "Ends the critical section and releases the per-object locks." msgstr "" -#: ../../c-api/init.rst:2442 +#: ../../c-api/init.rst:2486 msgid "" " PyCriticalSection2_End(&_py_cs2);\n" "}" @@ -2944,147 +2993,147 @@ msgstr "PyEval_InitThreads()" msgid "modules (in module sys)" msgstr "modules(sys 模組中)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:700 msgid "path (in module sys)" msgstr "path(sys 模組中)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 ../../c-api/init.rst:1131 -#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:700 ../../c-api/init.rst:1166 +#: ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 msgid "module" msgstr "模組" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 msgid "builtins" msgstr "builtins(內建)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 msgid "__main__" msgstr "__main__" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 msgid "sys" msgstr "sys" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:700 msgid "search" msgstr "search(搜尋)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:700 msgid "path" msgstr "path(路徑)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1709 ../../c-api/init.rst:1762 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1753 ../../c-api/init.rst:1806 msgid "Py_FinalizeEx (C function)" msgstr "Py_FinalizeEx(C 函式)" -#: ../../c-api/init.rst:562 +#: ../../c-api/init.rst:566 msgid "Py_Initialize()" msgstr "Py_Initialize()" -#: ../../c-api/init.rst:562 ../../c-api/init.rst:794 +#: ../../c-api/init.rst:566 ../../c-api/init.rst:798 msgid "main()" msgstr "main()" -#: ../../c-api/init.rst:562 +#: ../../c-api/init.rst:566 msgid "Py_GetPath()" msgstr "Py_GetPath()" -#: ../../c-api/init.rst:675 +#: ../../c-api/init.rst:679 msgid "executable (in module sys)" msgstr "executable(sys 模組中)" -#: ../../c-api/init.rst:729 ../../c-api/init.rst:771 ../../c-api/init.rst:785 +#: ../../c-api/init.rst:733 ../../c-api/init.rst:775 ../../c-api/init.rst:789 msgid "version (in module sys)" msgstr "version(sys 模組中)" -#: ../../c-api/init.rst:741 +#: ../../c-api/init.rst:745 msgid "platform (in module sys)" msgstr "platform(sys 模組中)" -#: ../../c-api/init.rst:758 +#: ../../c-api/init.rst:762 msgid "copyright (in module sys)" msgstr "copyright(sys 模組中)" -#: ../../c-api/init.rst:794 +#: ../../c-api/init.rst:798 msgid "Py_FatalError()" msgstr "Py_FatalError()" -#: ../../c-api/init.rst:794 +#: ../../c-api/init.rst:798 msgid "argv (in module sys)" msgstr "argv(sys 模組中)" -#: ../../c-api/init.rst:914 +#: ../../c-api/init.rst:918 msgid "global interpreter lock" msgstr "global interpreter lock(全域直譯器鎖)" -#: ../../c-api/init.rst:914 +#: ../../c-api/init.rst:918 msgid "interpreter lock" msgstr "interpreter lock(直譯器鎖)" -#: ../../c-api/init.rst:914 +#: ../../c-api/init.rst:918 msgid "lock, interpreter" msgstr "lock, interpreter(鎖、直譯器)" -#: ../../c-api/init.rst:927 +#: ../../c-api/init.rst:931 msgid "setswitchinterval (in module sys)" msgstr "setswitchinterval (sys 模組中)" -#: ../../c-api/init.rst:936 +#: ../../c-api/init.rst:940 msgid "PyThreadState (C type)" msgstr "PyThreadState(C 型別)" -#: ../../c-api/init.rst:962 +#: ../../c-api/init.rst:966 msgid "Py_BEGIN_ALLOW_THREADS (C macro)" msgstr "Py_BEGIN_ALLOW_THREADS(C 巨集)" -#: ../../c-api/init.rst:962 +#: ../../c-api/init.rst:966 msgid "Py_END_ALLOW_THREADS (C macro)" msgstr "Py_END_ALLOW_THREADS(C 巨集)" -#: ../../c-api/init.rst:978 +#: ../../c-api/init.rst:982 msgid "PyEval_RestoreThread (C function)" msgstr "PyEval_RestoreThread(C 函式)" -#: ../../c-api/init.rst:978 +#: ../../c-api/init.rst:982 msgid "PyEval_SaveThread (C function)" msgstr "PyEval_SaveThread(C 函式)" -#: ../../c-api/init.rst:1109 +#: ../../c-api/init.rst:1144 msgid "PyEval_AcquireThread()" msgstr "PyEval_AcquireThread()" -#: ../../c-api/init.rst:1109 +#: ../../c-api/init.rst:1144 msgid "PyEval_ReleaseThread()" msgstr "PyEval_ReleaseThread()" -#: ../../c-api/init.rst:1109 +#: ../../c-api/init.rst:1144 msgid "PyEval_SaveThread()" msgstr "PyEval_SaveThread()" -#: ../../c-api/init.rst:1109 +#: ../../c-api/init.rst:1144 msgid "PyEval_RestoreThread()" msgstr "PyEval_RestoreThread()" -#: ../../c-api/init.rst:1131 +#: ../../c-api/init.rst:1166 msgid "_thread" msgstr "_thread" -#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 +#: ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 msgid "stdout (in module sys)" msgstr "stdout(sys 模組中)" -#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 +#: ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 msgid "stderr (in module sys)" msgstr "stderr(sys 模組中)" -#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 +#: ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 msgid "stdin (in module sys)" msgstr "stdin(sys 模組中)" -#: ../../c-api/init.rst:1709 +#: ../../c-api/init.rst:1753 msgid "Py_Initialize (C function)" msgstr "Py_Initialize(C 函式)" -#: ../../c-api/init.rst:1739 +#: ../../c-api/init.rst:1783 msgid "close (in module os)" msgstr "close(os 模組中)" From 50fa12469b2377e56e288a692ffc8ebf0590ecd1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Aug 2025 00:17:50 +0000 Subject: [PATCH 18/23] sync with cpython b3725651 --- library/asyncio-stream.po | 96 +++--- library/doctest.po | 648 +++++++++++++++++++------------------- 2 files changed, 381 insertions(+), 363 deletions(-) diff --git a/library/asyncio-stream.po b/library/asyncio-stream.po index e3597d945a..07e98be812 100644 --- a/library/asyncio-stream.po +++ b/library/asyncio-stream.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-19 00:16+0000\n" "PO-Revision-Date: 2022-10-31 16:28+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -42,7 +42,7 @@ msgstr "" msgid "Here is an example of a TCP echo client written using asyncio streams::" msgstr "這是一個使用 asyncio 串流編寫的 TCP echo 用戶端範例: ::" -#: ../../library/asyncio-stream.rst:22 ../../library/asyncio-stream.rst:437 +#: ../../library/asyncio-stream.rst:22 ../../library/asyncio-stream.rst:440 msgid "" "import asyncio\n" "\n" @@ -146,7 +146,7 @@ msgstr "移除 *loop* 參數。" #: ../../library/asyncio-stream.rst:87 ../../library/asyncio-stream.rst:131 #: ../../library/asyncio-stream.rst:167 ../../library/asyncio-stream.rst:202 -#: ../../library/asyncio-stream.rst:404 +#: ../../library/asyncio-stream.rst:407 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "新增 *ssl_shutdown_timeout* 參數。" @@ -409,7 +409,7 @@ msgstr "" "此方法會嘗試立即將 *data* 寫入到底層的 socket。如果失敗,資料會被放到內部寫入" "緩衝中排隊等待 (queue),直到它可被發送。" -#: ../../library/asyncio-stream.rst:319 ../../library/asyncio-stream.rst:331 +#: ../../library/asyncio-stream.rst:319 ../../library/asyncio-stream.rst:334 msgid "The method should be used along with the ``drain()`` method::" msgstr "此方法應當與 ``drain()`` 方法一起使用: ::" @@ -421,7 +421,13 @@ msgstr "" "stream.write(data)\n" "await stream.drain()" -#: ../../library/asyncio-stream.rst:326 +#: ../../library/asyncio-stream.rst:325 +msgid "" +"The *data* buffer should be a C contiguous one-dimensional :term:`bytes-like " +"object `." +msgstr "" + +#: ../../library/asyncio-stream.rst:329 msgid "" "The method writes a list (or any iterable) of bytes to the underlying socket " "immediately. If that fails, the data is queued in an internal write buffer " @@ -430,7 +436,7 @@ msgstr "" "此方法會立即嘗試將一個位元組 list(或任何可疊代物件 (iterable))寫入到底層的 " "socket。如果失敗,資料會被放到內部寫入緩衝中排隊等待,直到它可被發送。" -#: ../../library/asyncio-stream.rst:333 +#: ../../library/asyncio-stream.rst:336 msgid "" "stream.writelines(lines)\n" "await stream.drain()" @@ -438,17 +444,17 @@ msgstr "" "stream.writelines(lines)\n" "await stream.drain()" -#: ../../library/asyncio-stream.rst:338 +#: ../../library/asyncio-stream.rst:341 msgid "The method closes the stream and the underlying socket." msgstr "此方法會關閉串流以及底層的 socket。" -#: ../../library/asyncio-stream.rst:340 +#: ../../library/asyncio-stream.rst:343 msgid "" "The method should be used, though not mandatory, along with the " "``wait_closed()`` method::" msgstr "此方法應與 ``wait_closed()`` 方法一起使用,但並非強制: ::" -#: ../../library/asyncio-stream.rst:343 +#: ../../library/asyncio-stream.rst:346 msgid "" "stream.close()\n" "await stream.wait_closed()" @@ -456,7 +462,7 @@ msgstr "" "stream.close()\n" "await stream.wait_closed()" -#: ../../library/asyncio-stream.rst:348 +#: ../../library/asyncio-stream.rst:351 msgid "" "Return ``True`` if the underlying transport supports the :meth:`write_eof` " "method, ``False`` otherwise." @@ -464,26 +470,26 @@ msgstr "" "如果底層的傳輸支援 :meth:`write_eof` 方法就回傳 ``True``,否則回傳 " "``False``。" -#: ../../library/asyncio-stream.rst:353 +#: ../../library/asyncio-stream.rst:356 msgid "" "Close the write end of the stream after the buffered write data is flushed." msgstr "在已緩衝的寫入資料被清理 (flush) 後關閉串流的寫入端。" -#: ../../library/asyncio-stream.rst:358 +#: ../../library/asyncio-stream.rst:361 msgid "Return the underlying asyncio transport." msgstr "回傳底層的 asyncio 傳輸。" -#: ../../library/asyncio-stream.rst:362 +#: ../../library/asyncio-stream.rst:365 msgid "" "Access optional transport information; see :meth:`BaseTransport." "get_extra_info` for details." msgstr "存取可選的傳輸資訊;詳情請見 :meth:`BaseTransport.get_extra_info`。" -#: ../../library/asyncio-stream.rst:368 +#: ../../library/asyncio-stream.rst:371 msgid "Wait until it is appropriate to resume writing to the stream. Example::" msgstr "等待直到可以繼續寫入到串流。範例: ::" -#: ../../library/asyncio-stream.rst:371 +#: ../../library/asyncio-stream.rst:374 msgid "" "writer.write(data)\n" "await writer.drain()" @@ -491,7 +497,7 @@ msgstr "" "writer.write(data)\n" "await writer.drain()" -#: ../../library/asyncio-stream.rst:374 +#: ../../library/asyncio-stream.rst:377 msgid "" "This is a flow control method that interacts with the underlying IO write " "buffer. When the size of the buffer reaches the high watermark, *drain()* " @@ -503,48 +509,48 @@ msgstr "" "(high watermark) 時,*drain()* 會阻塞直到緩衝區大小減少至最低標記位 (low " "watermark) 以便繼續寫入。當沒有要等待的資料時,:meth:`drain` 會立即回傳。" -#: ../../library/asyncio-stream.rst:385 +#: ../../library/asyncio-stream.rst:388 msgid "Upgrade an existing stream-based connection to TLS." msgstr "將現有的基於串流的連線升級到 TLS。" -#: ../../library/asyncio-stream.rst:387 +#: ../../library/asyncio-stream.rst:390 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-stream.rst:389 +#: ../../library/asyncio-stream.rst:392 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "*sslcontext*:一個 :class:`~ssl.SSLContext` 的已配置實例。" -#: ../../library/asyncio-stream.rst:391 +#: ../../library/asyncio-stream.rst:394 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." msgstr "*server_hostname*:設定或覆寫將會被目標伺服器憑證比對的主機名稱。" -#: ../../library/asyncio-stream.rst:394 +#: ../../library/asyncio-stream.rst:397 msgid "" "*ssl_handshake_timeout* is the time in seconds to wait for the TLS handshake " "to complete before aborting the connection. ``60.0`` seconds if ``None`` " "(default)." msgstr "" -#: ../../library/asyncio-stream.rst:398 +#: ../../library/asyncio-stream.rst:401 msgid "" "*ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown " "to complete before aborting the connection. ``30.0`` seconds if ``None`` " "(default)." msgstr "" -#: ../../library/asyncio-stream.rst:410 +#: ../../library/asyncio-stream.rst:413 msgid "" "Return ``True`` if the stream is closed or in the process of being closed." msgstr "如果串流已被關閉或正在被關閉則回傳 ``True``。" -#: ../../library/asyncio-stream.rst:418 +#: ../../library/asyncio-stream.rst:421 msgid "Wait until the stream is closed." msgstr "等待直到串流被關閉。" -#: ../../library/asyncio-stream.rst:420 +#: ../../library/asyncio-stream.rst:423 msgid "" "Should be called after :meth:`close` to wait until the underlying connection " "is closed, ensuring that all data has been flushed before e.g. exiting the " @@ -553,19 +559,19 @@ msgstr "" "應當在 :meth:`close` 之後才被呼叫,這會持續等待直到底層的連線被關閉,以確保在" "這之前(例如在程式退出前)所有資料都已經被清空" -#: ../../library/asyncio-stream.rst:428 +#: ../../library/asyncio-stream.rst:431 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-stream.rst:433 +#: ../../library/asyncio-stream.rst:436 msgid "TCP echo client using streams" msgstr "使用串流的 TCP echo 用戶端" -#: ../../library/asyncio-stream.rst:435 +#: ../../library/asyncio-stream.rst:438 msgid "TCP echo client using the :func:`asyncio.open_connection` function::" msgstr "使用 :func:`asyncio.open_connection` 函式的 TCP echo 用戶端: ::" -#: ../../library/asyncio-stream.rst:459 +#: ../../library/asyncio-stream.rst:462 msgid "" "The :ref:`TCP echo client protocol " "` example uses the low-level :meth:" @@ -574,15 +580,15 @@ msgstr "" "使用低階 :meth:`loop.create_connection` 方法的 :ref:`TCP echo 用戶端協定 " "`\\ 範例。" -#: ../../library/asyncio-stream.rst:466 +#: ../../library/asyncio-stream.rst:469 msgid "TCP echo server using streams" msgstr "使用串流的 TCP echo 伺服器" -#: ../../library/asyncio-stream.rst:468 +#: ../../library/asyncio-stream.rst:471 msgid "TCP echo server using the :func:`asyncio.start_server` function::" msgstr "TCP echo 伺服器使用 :func:`asyncio.start_server` 函式: ::" -#: ../../library/asyncio-stream.rst:470 +#: ../../library/asyncio-stream.rst:473 msgid "" "import asyncio\n" "\n" @@ -642,7 +648,7 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../library/asyncio-stream.rst:502 +#: ../../library/asyncio-stream.rst:505 msgid "" "The :ref:`TCP echo server protocol " "` example uses the :meth:`loop." @@ -651,16 +657,16 @@ msgstr "" "使用 :meth:`loop.create_server` 方法的 :ref:`TCP echo 伺服器協定 " "` 範例。" -#: ../../library/asyncio-stream.rst:507 +#: ../../library/asyncio-stream.rst:510 msgid "Get HTTP headers" msgstr "取得 HTTP 標頭" -#: ../../library/asyncio-stream.rst:509 +#: ../../library/asyncio-stream.rst:512 msgid "" "Simple example querying HTTP headers of the URL passed on the command line::" msgstr "查詢自命令列傳入之 URL 所帶有 HTTP 標頭的簡單範例: ::" -#: ../../library/asyncio-stream.rst:511 +#: ../../library/asyncio-stream.rst:514 msgid "" "import asyncio\n" "import urllib.parse\n" @@ -699,34 +705,34 @@ msgid "" "asyncio.run(print_http_headers(url))" msgstr "" -#: ../../library/asyncio-stream.rst:548 +#: ../../library/asyncio-stream.rst:551 msgid "Usage::" msgstr "用法: ::" -#: ../../library/asyncio-stream.rst:550 +#: ../../library/asyncio-stream.rst:553 msgid "python example.py http://example.com/path/page.html" msgstr "python example.py http://example.com/path/page.html" -#: ../../library/asyncio-stream.rst:552 +#: ../../library/asyncio-stream.rst:555 msgid "or with HTTPS::" msgstr "或使用 HTTPS: ::" -#: ../../library/asyncio-stream.rst:554 +#: ../../library/asyncio-stream.rst:557 msgid "python example.py https://example.com/path/page.html" msgstr "python example.py https://example.com/path/page.html" -#: ../../library/asyncio-stream.rst:560 +#: ../../library/asyncio-stream.rst:563 msgid "Register an open socket to wait for data using streams" msgstr "註冊一個使用串流來等待資料的開放 socket" -#: ../../library/asyncio-stream.rst:562 +#: ../../library/asyncio-stream.rst:565 msgid "" "Coroutine waiting until a socket receives data using the :func:" "`open_connection` function::" msgstr "" "等待直到 socket 透過使用 :func:`open_connection` 函式接收到資料的協程: ::" -#: ../../library/asyncio-stream.rst:565 +#: ../../library/asyncio-stream.rst:568 msgid "" "import asyncio\n" "import socket\n" @@ -759,7 +765,7 @@ msgid "" "asyncio.run(wait_for_data())" msgstr "" -#: ../../library/asyncio-stream.rst:597 +#: ../../library/asyncio-stream.rst:600 msgid "" "The :ref:`register an open socket to wait for data using a protocol " "` example uses a low-level protocol and " @@ -769,7 +775,7 @@ msgstr "" "`\\ 範例中,有使用了低階協定以及 :meth:" "`loop.create_connection` 方法。" -#: ../../library/asyncio-stream.rst:601 +#: ../../library/asyncio-stream.rst:604 msgid "" "The :ref:`watch a file descriptor for read events " "` example uses the low-level :meth:`loop." diff --git a/library/doctest.po b/library/doctest.po index 19e05a3df7..1f3152e43c 100644 --- a/library/doctest.po +++ b/library/doctest.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-16 00:16+0000\n" +"POT-Creation-Date: 2025-08-19 00:16+0000\n" "PO-Revision-Date: 2018-05-23 14:43+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -528,18 +528,30 @@ msgid "" "their contained methods and nested classes." msgstr "" -#: ../../library/doctest.rst:353 +#: ../../library/doctest.rst:351 +msgid "" +"``doctest`` can only automatically discover classes and functions that are " +"defined at the module level or inside other classes." +msgstr "" + +#: ../../library/doctest.rst:354 +msgid "" +"Since nested classes and functions only exist when an outer function is " +"called, they cannot be discovered. Define them outside to make them visible." +msgstr "" + +#: ../../library/doctest.rst:360 msgid "How are Docstring Examples Recognized?" msgstr "" -#: ../../library/doctest.rst:355 +#: ../../library/doctest.rst:362 msgid "" "In most cases a copy-and-paste of an interactive console session works fine, " "but doctest isn't trying to do an exact emulation of any specific Python " "shell." msgstr "" -#: ../../library/doctest.rst:360 +#: ../../library/doctest.rst:367 msgid "" ">>> # comments are ignored\n" ">>> x = 12\n" @@ -573,18 +585,18 @@ msgstr "" "NO!!!\n" ">>>" -#: ../../library/doctest.rst:380 +#: ../../library/doctest.rst:387 msgid "" "Any expected output must immediately follow the final ``'>>> '`` or ``'... " "'`` line containing the code, and the expected output (if any) extends to " "the next ``'>>> '`` or all-whitespace line." msgstr "" -#: ../../library/doctest.rst:384 +#: ../../library/doctest.rst:391 msgid "The fine print:" msgstr "" -#: ../../library/doctest.rst:386 +#: ../../library/doctest.rst:393 msgid "" "Expected output cannot contain an all-whitespace line, since such a line is " "taken to signal the end of expected output. If expected output does contain " @@ -592,7 +604,7 @@ msgid "" "line is expected." msgstr "" -#: ../../library/doctest.rst:391 +#: ../../library/doctest.rst:398 msgid "" "All hard tab characters are expanded to spaces, using 8-column tab stops. " "Tabs in output generated by the tested code are not modified. Because any " @@ -607,20 +619,20 @@ msgid "" "`DocTestParser` class." msgstr "" -#: ../../library/doctest.rst:403 +#: ../../library/doctest.rst:410 msgid "" "Output to stdout is captured, but not output to stderr (exception tracebacks " "are captured via a different means)." msgstr "" -#: ../../library/doctest.rst:406 +#: ../../library/doctest.rst:413 msgid "" "If you continue a line via backslashing in an interactive session, or for " "any other reason use a backslash, you should use a raw docstring, which will " "preserve your backslashes exactly as you type them::" msgstr "" -#: ../../library/doctest.rst:410 +#: ../../library/doctest.rst:417 msgid "" ">>> def f(x):\n" "... r'''Backslashes in a raw docstring: m\\n'''\n" @@ -629,7 +641,7 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:416 +#: ../../library/doctest.rst:423 msgid "" "Otherwise, the backslash will be interpreted as part of the string. For " "example, the ``\\n`` above would be interpreted as a newline character. " @@ -637,7 +649,7 @@ msgid "" "use a raw string)::" msgstr "" -#: ../../library/doctest.rst:420 +#: ../../library/doctest.rst:427 msgid "" ">>> def f(x):\n" "... '''Backslashes in a raw docstring: m\\\\n'''\n" @@ -646,11 +658,11 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:426 +#: ../../library/doctest.rst:433 msgid "The starting column doesn't matter::" msgstr "" -#: ../../library/doctest.rst:428 +#: ../../library/doctest.rst:435 msgid "" ">>> assert \"Easy!\"\n" " >>> import math\n" @@ -662,17 +674,17 @@ msgstr "" " >>> math.floor(1.9)\n" " 1" -#: ../../library/doctest.rst:433 +#: ../../library/doctest.rst:440 msgid "" "and as many leading whitespace characters are stripped from the expected " "output as appeared in the initial ``'>>> '`` line that started the example." msgstr "" -#: ../../library/doctest.rst:440 +#: ../../library/doctest.rst:447 msgid "What's the Execution Context?" msgstr "" -#: ../../library/doctest.rst:442 +#: ../../library/doctest.rst:449 msgid "" "By default, each time :mod:`doctest` finds a docstring to test, it uses a " "*shallow copy* of :mod:`!M`'s globals, so that running tests doesn't change " @@ -683,17 +695,17 @@ msgid "" "defined in other docstrings." msgstr "" -#: ../../library/doctest.rst:450 +#: ../../library/doctest.rst:457 msgid "" "You can force use of your own dict as the execution context by passing " "``globs=your_dict`` to :func:`testmod` or :func:`testfile` instead." msgstr "" -#: ../../library/doctest.rst:457 +#: ../../library/doctest.rst:464 msgid "What About Exceptions?" msgstr "" -#: ../../library/doctest.rst:459 +#: ../../library/doctest.rst:466 msgid "" "No problem, provided that the traceback is the only output produced by the " "example: just paste in the traceback. [#]_ Since tracebacks contain details " @@ -702,11 +714,11 @@ msgid "" "it accepts." msgstr "" -#: ../../library/doctest.rst:465 +#: ../../library/doctest.rst:472 msgid "Simple example::" msgstr "簡單範例: ::" -#: ../../library/doctest.rst:467 +#: ../../library/doctest.rst:474 msgid "" ">>> [1, 2, 3].remove(42)\n" "Traceback (most recent call last):\n" @@ -718,20 +730,20 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: list.remove(x): x not in list" -#: ../../library/doctest.rst:472 +#: ../../library/doctest.rst:479 msgid "" "That doctest succeeds if :exc:`ValueError` is raised, with the ``list." "remove(x): x not in list`` detail as shown." msgstr "" -#: ../../library/doctest.rst:475 +#: ../../library/doctest.rst:482 msgid "" "The expected output for an exception must start with a traceback header, " "which may be either of the following two lines, indented the same as the " "first line of the example::" msgstr "" -#: ../../library/doctest.rst:479 +#: ../../library/doctest.rst:486 msgid "" "Traceback (most recent call last):\n" "Traceback (innermost last):" @@ -739,14 +751,14 @@ msgstr "" "Traceback (most recent call last):\n" "Traceback (innermost last):" -#: ../../library/doctest.rst:482 +#: ../../library/doctest.rst:489 msgid "" "The traceback header is followed by an optional traceback stack, whose " "contents are ignored by doctest. The traceback stack is typically omitted, " "or copied verbatim from an interactive session." msgstr "" -#: ../../library/doctest.rst:486 +#: ../../library/doctest.rst:493 msgid "" "The traceback stack is followed by the most interesting part: the line(s) " "containing the exception type and detail. This is usually the last line of " @@ -754,7 +766,7 @@ msgid "" "multi-line detail::" msgstr "" -#: ../../library/doctest.rst:491 +#: ../../library/doctest.rst:498 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -770,20 +782,20 @@ msgstr "" " line\n" "detail" -#: ../../library/doctest.rst:498 +#: ../../library/doctest.rst:505 msgid "" "The last three lines (starting with :exc:`ValueError`) are compared against " "the exception's type and detail, and the rest are ignored." msgstr "" -#: ../../library/doctest.rst:501 +#: ../../library/doctest.rst:508 msgid "" "Best practice is to omit the traceback stack, unless it adds significant " "documentation value to the example. So the last example is probably better " "as::" msgstr "" -#: ../../library/doctest.rst:504 +#: ../../library/doctest.rst:511 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -799,7 +811,7 @@ msgstr "" " line\n" "detail" -#: ../../library/doctest.rst:511 +#: ../../library/doctest.rst:518 msgid "" "Note that tracebacks are treated very specially. In particular, in the " "rewritten example, the use of ``...`` is independent of doctest's :const:" @@ -808,11 +820,11 @@ msgid "" "transcript of a Monty Python skit." msgstr "" -#: ../../library/doctest.rst:517 +#: ../../library/doctest.rst:524 msgid "Some details you should read once, but won't need to remember:" msgstr "" -#: ../../library/doctest.rst:519 +#: ../../library/doctest.rst:526 msgid "" "Doctest can't guess whether your expected output came from an exception " "traceback or from ordinary printing. So, e.g., an example that expects " @@ -822,7 +834,7 @@ msgid "" "create real problems." msgstr "" -#: ../../library/doctest.rst:526 +#: ../../library/doctest.rst:533 msgid "" "Each line of the traceback stack (if present) must be indented further than " "the first line of the example, *or* start with a non-alphanumeric character. " @@ -831,14 +843,14 @@ msgid "" "course this does the right thing for genuine tracebacks." msgstr "" -#: ../../library/doctest.rst:532 +#: ../../library/doctest.rst:539 msgid "" "When the :const:`IGNORE_EXCEPTION_DETAIL` doctest option is specified, " "everything following the leftmost colon and any module information in the " "exception name is ignored." msgstr "" -#: ../../library/doctest.rst:536 +#: ../../library/doctest.rst:543 msgid "" "The interactive shell omits the traceback header line for some :exc:" "`SyntaxError`\\ s. But doctest uses the traceback header line to " @@ -847,13 +859,13 @@ msgid "" "need to manually add the traceback header line to your test example." msgstr "" -#: ../../library/doctest.rst:544 +#: ../../library/doctest.rst:551 msgid "" "For some exceptions, Python displays the position of the error using ``^`` " "markers and tildes::" msgstr "" -#: ../../library/doctest.rst:547 +#: ../../library/doctest.rst:554 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -867,7 +879,7 @@ msgstr "" " ~~^~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:553 +#: ../../library/doctest.rst:560 msgid "" "Since the lines showing the position of the error come before the exception " "type and detail, they are not checked by doctest. For example, the " @@ -875,7 +887,7 @@ msgid "" "location::" msgstr "" -#: ../../library/doctest.rst:557 +#: ../../library/doctest.rst:564 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -889,11 +901,11 @@ msgstr "" " ^~~~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:568 +#: ../../library/doctest.rst:575 msgid "Option Flags" msgstr "可選旗標" -#: ../../library/doctest.rst:570 +#: ../../library/doctest.rst:577 msgid "" "A number of option flags control various aspects of doctest's behavior. " "Symbolic names for the flags are supplied as module constants, which can be :" @@ -903,13 +915,13 @@ msgid "" "option." msgstr "" -#: ../../library/doctest.rst:576 +#: ../../library/doctest.rst:583 msgid "" "The first group of options define test semantics, controlling aspects of how " "doctest decides whether actual output matches an example's expected output:" msgstr "" -#: ../../library/doctest.rst:582 +#: ../../library/doctest.rst:589 msgid "" "By default, if an expected output block contains just ``1``, an actual " "output block containing just ``1`` or just ``True`` is considered to be a " @@ -921,7 +933,7 @@ msgid "" "not for several years." msgstr "" -#: ../../library/doctest.rst:594 +#: ../../library/doctest.rst:601 msgid "" "By default, if an expected output block contains a line containing only the " "string ````, then that line will match a blank line in the actual " @@ -930,7 +942,7 @@ msgid "" "`DONT_ACCEPT_BLANKLINE` is specified, this substitution is not allowed." msgstr "" -#: ../../library/doctest.rst:603 +#: ../../library/doctest.rst:610 msgid "" "When specified, all sequences of whitespace (blanks and newlines) are " "treated as equal. Any sequence of whitespace within the expected output " @@ -940,7 +952,7 @@ msgid "" "across multiple lines in your source." msgstr "" -#: ../../library/doctest.rst:614 +#: ../../library/doctest.rst:621 msgid "" "When specified, an ellipsis marker (``...``) in the expected output can " "match any substring in the actual output. This includes substrings that " @@ -949,14 +961,14 @@ msgid "" "matched too much!\" surprises that ``.*`` is prone to in regular expressions." msgstr "" -#: ../../library/doctest.rst:623 +#: ../../library/doctest.rst:630 msgid "" "When specified, doctests expecting exceptions pass so long as an exception " "of the expected type is raised, even if the details (message and fully " "qualified exception name) don't match." msgstr "" -#: ../../library/doctest.rst:627 +#: ../../library/doctest.rst:634 msgid "" "For example, an example expecting ``ValueError: 42`` will pass if the actual " "exception raised is ``ValueError: 3*14``, but will fail if, say, a :exc:" @@ -966,7 +978,7 @@ msgid "" "these variations will work with the flag specified:" msgstr "" -#: ../../library/doctest.rst:635 +#: ../../library/doctest.rst:642 msgid "" ">>> raise Exception('message')\n" "Traceback (most recent call last):\n" @@ -992,20 +1004,20 @@ msgstr "" "Traceback (most recent call last):\n" "__main__.Exception: message" -#: ../../library/doctest.rst:649 +#: ../../library/doctest.rst:656 msgid "" "Note that :const:`ELLIPSIS` can also be used to ignore the details of the " "exception message, but such a test may still fail based on whether the " "module name is present or matches exactly." msgstr "" -#: ../../library/doctest.rst:653 +#: ../../library/doctest.rst:660 msgid "" ":const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating " "to the module containing the exception under test." msgstr "" -#: ../../library/doctest.rst:660 +#: ../../library/doctest.rst:667 msgid "" "When specified, do not run the example at all. This can be useful in " "contexts where doctest examples serve as both documentation and test cases, " @@ -1014,32 +1026,32 @@ msgid "" "might depend on resources which would be unavailable to the test driver." msgstr "" -#: ../../library/doctest.rst:666 +#: ../../library/doctest.rst:673 msgid "" "The SKIP flag can also be used for temporarily \"commenting out\" examples." msgstr "" -#: ../../library/doctest.rst:671 +#: ../../library/doctest.rst:678 msgid "A bitmask or'ing together all the comparison flags above." msgstr "" -#: ../../library/doctest.rst:673 +#: ../../library/doctest.rst:680 msgid "The second group of options controls how test failures are reported:" msgstr "" -#: ../../library/doctest.rst:678 +#: ../../library/doctest.rst:685 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "are displayed using a unified diff." msgstr "" -#: ../../library/doctest.rst:684 +#: ../../library/doctest.rst:691 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "will be displayed using a context diff." msgstr "" -#: ../../library/doctest.rst:690 +#: ../../library/doctest.rst:697 msgid "" "When specified, differences are computed by ``difflib.Differ``, using the " "same algorithm as the popular :file:`ndiff.py` utility. This is the only " @@ -1049,7 +1061,7 @@ msgid "" "mismatching column positions." msgstr "" -#: ../../library/doctest.rst:699 +#: ../../library/doctest.rst:706 msgid "" "When specified, display the first failing example in each doctest, but " "suppress output for all remaining examples. This will prevent doctest from " @@ -1060,7 +1072,7 @@ msgid "" "of failures reported; only the output is suppressed." msgstr "" -#: ../../library/doctest.rst:710 +#: ../../library/doctest.rst:717 msgid "" "When specified, exit after the first failing example and don't attempt to " "run the remaining examples. Thus, the number of failures reported will be at " @@ -1068,17 +1080,17 @@ msgid "" "first failure won't even produce debugging output." msgstr "" -#: ../../library/doctest.rst:718 +#: ../../library/doctest.rst:725 msgid "A bitmask or'ing together all the reporting flags above." msgstr "" -#: ../../library/doctest.rst:721 +#: ../../library/doctest.rst:728 msgid "" "There is also a way to register new option flag names, though this isn't " "useful unless you intend to extend :mod:`doctest` internals via subclassing:" msgstr "" -#: ../../library/doctest.rst:727 +#: ../../library/doctest.rst:734 msgid "" "Create a new option flag with a given name, and return the new flag's " "integer value. :func:`register_optionflag` can be used when subclassing :" @@ -1087,39 +1099,39 @@ msgid "" "be called using the following idiom::" msgstr "" -#: ../../library/doctest.rst:733 +#: ../../library/doctest.rst:740 msgid "MY_FLAG = register_optionflag('MY_FLAG')" msgstr "MY_FLAG = register_optionflag('MY_FLAG')" -#: ../../library/doctest.rst:743 +#: ../../library/doctest.rst:750 msgid "Directives" msgstr "" -#: ../../library/doctest.rst:745 +#: ../../library/doctest.rst:752 msgid "" "Doctest directives may be used to modify the :ref:`option flags ` for an individual example. Doctest directives are special Python " "comments following an example's source code:" msgstr "" -#: ../../library/doctest.rst:756 +#: ../../library/doctest.rst:763 msgid "" "Whitespace is not allowed between the ``+`` or ``-`` and the directive " "option name. The directive option name can be any of the option flag names " "explained above." msgstr "" -#: ../../library/doctest.rst:760 +#: ../../library/doctest.rst:767 msgid "" "An example's doctest directives modify doctest's behavior for that single " "example. Use ``+`` to enable the named behavior, or ``-`` to disable it." msgstr "" -#: ../../library/doctest.rst:763 +#: ../../library/doctest.rst:770 msgid "For example, this test passes:" msgstr "" -#: ../../library/doctest.rst:765 +#: ../../library/doctest.rst:772 msgid "" ">>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" @@ -1129,7 +1141,7 @@ msgstr "" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" "10, 11, 12, 13, 14, 15, 16, 17, 18, 19]" -#: ../../library/doctest.rst:772 +#: ../../library/doctest.rst:779 msgid "" "Without the directive it would fail, both because the actual output doesn't " "have two blanks before the single-digit list elements, and because the " @@ -1137,7 +1149,7 @@ msgid "" "a directive to do so:" msgstr "" -#: ../../library/doctest.rst:777 +#: ../../library/doctest.rst:784 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" @@ -1145,13 +1157,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:783 +#: ../../library/doctest.rst:790 msgid "" "Multiple directives can be used on a single physical line, separated by " "commas:" msgstr "" -#: ../../library/doctest.rst:786 +#: ../../library/doctest.rst:793 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" @@ -1159,13 +1171,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:792 +#: ../../library/doctest.rst:799 msgid "" "If multiple directive comments are used for a single example, then they are " "combined:" msgstr "" -#: ../../library/doctest.rst:795 +#: ../../library/doctest.rst:802 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "... # doctest: +NORMALIZE_WHITESPACE\n" @@ -1175,14 +1187,14 @@ msgstr "" "... # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:802 +#: ../../library/doctest.rst:809 msgid "" "As the previous example shows, you can add ``...`` lines to your example " "containing only directives. This can be useful when an example is too long " "for a directive to comfortably fit on the same line:" msgstr "" -#: ../../library/doctest.rst:806 +#: ../../library/doctest.rst:813 msgid "" ">>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))\n" "... # doctest: +ELLIPSIS\n" @@ -1192,7 +1204,7 @@ msgstr "" "... # doctest: +ELLIPSIS\n" "[0, ..., 4, 10, ..., 19, 30, ..., 39]" -#: ../../library/doctest.rst:813 +#: ../../library/doctest.rst:820 msgid "" "Note that since all options are disabled by default, and directives apply " "only to the example they appear in, enabling options (via ``+`` in a " @@ -1202,11 +1214,11 @@ msgid "" "be useful." msgstr "" -#: ../../library/doctest.rst:823 +#: ../../library/doctest.rst:830 msgid "Warnings" msgstr "警告" -#: ../../library/doctest.rst:825 +#: ../../library/doctest.rst:832 msgid "" ":mod:`doctest` is serious about requiring exact matches in expected output. " "If even a single character doesn't match, the test fails. This will " @@ -1216,7 +1228,7 @@ msgid "" "test like ::" msgstr "" -#: ../../library/doctest.rst:831 +#: ../../library/doctest.rst:838 msgid "" ">>> foo()\n" "{\"spam\", \"eggs\"}" @@ -1224,11 +1236,11 @@ msgstr "" ">>> foo()\n" "{\"spam\", \"eggs\"}" -#: ../../library/doctest.rst:834 +#: ../../library/doctest.rst:841 msgid "is vulnerable! One workaround is to do ::" msgstr "" -#: ../../library/doctest.rst:836 +#: ../../library/doctest.rst:843 msgid "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" @@ -1236,11 +1248,11 @@ msgstr "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" -#: ../../library/doctest.rst:839 +#: ../../library/doctest.rst:846 msgid "instead. Another is to do ::" msgstr "" -#: ../../library/doctest.rst:841 +#: ../../library/doctest.rst:848 msgid "" ">>> d = sorted(foo())\n" ">>> d\n" @@ -1250,15 +1262,15 @@ msgstr "" ">>> d\n" "['eggs', 'spam']" -#: ../../library/doctest.rst:845 +#: ../../library/doctest.rst:852 msgid "There are others, but you get the idea." msgstr "" -#: ../../library/doctest.rst:847 +#: ../../library/doctest.rst:854 msgid "Another bad idea is to print things that embed an object address, like" msgstr "" -#: ../../library/doctest.rst:849 +#: ../../library/doctest.rst:856 msgid "" ">>> id(1.0) # certain to fail some of the time\n" "7948648\n" @@ -1267,12 +1279,12 @@ msgid "" "" msgstr "" -#: ../../library/doctest.rst:857 +#: ../../library/doctest.rst:864 msgid "" "The :const:`ELLIPSIS` directive gives a nice approach for the last example:" msgstr "" -#: ../../library/doctest.rst:859 +#: ../../library/doctest.rst:866 msgid "" ">>> C() # doctest: +ELLIPSIS\n" "" @@ -1280,14 +1292,14 @@ msgstr "" ">>> C() # doctest: +ELLIPSIS\n" "" -#: ../../library/doctest.rst:865 +#: ../../library/doctest.rst:872 msgid "" "Floating-point numbers are also subject to small output variations across " "platforms, because Python defers to the platform C library for some floating-" "point calculations, and C libraries vary widely in quality here. ::" msgstr "" -#: ../../library/doctest.rst:869 +#: ../../library/doctest.rst:876 msgid "" ">>> 1000**0.1 # risky\n" "1.9952623149688797\n" @@ -1297,29 +1309,29 @@ msgid "" "1.9953" msgstr "" -#: ../../library/doctest.rst:876 +#: ../../library/doctest.rst:883 msgid "" "Numbers of the form ``I/2.**J`` are safe across all platforms, and I often " "contrive doctest examples to produce numbers of that form::" msgstr "" -#: ../../library/doctest.rst:879 +#: ../../library/doctest.rst:886 msgid "" ">>> 3./4 # utterly safe\n" "0.75" msgstr "" -#: ../../library/doctest.rst:882 +#: ../../library/doctest.rst:889 msgid "" "Simple fractions are also easier for people to understand, and that makes " "for better documentation." msgstr "" -#: ../../library/doctest.rst:889 +#: ../../library/doctest.rst:896 msgid "Basic API" msgstr "基礎 API" -#: ../../library/doctest.rst:891 +#: ../../library/doctest.rst:898 msgid "" "The functions :func:`testmod` and :func:`testfile` provide a simple " "interface to doctest that should be sufficient for most basic uses. For a " @@ -1327,25 +1339,25 @@ msgid "" "simple-testmod` and :ref:`doctest-simple-testfile`." msgstr "" -#: ../../library/doctest.rst:899 +#: ../../library/doctest.rst:906 msgid "" "All arguments except *filename* are optional, and should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:902 +#: ../../library/doctest.rst:909 msgid "" "Test examples in the file named *filename*. Return ``(failure_count, " "test_count)``." msgstr "" -#: ../../library/doctest.rst:905 +#: ../../library/doctest.rst:912 msgid "" "Optional argument *module_relative* specifies how the filename should be " "interpreted:" msgstr "" -#: ../../library/doctest.rst:908 +#: ../../library/doctest.rst:915 msgid "" "If *module_relative* is ``True`` (the default), then *filename* specifies an " "OS-independent module-relative path. By default, this path is relative to " @@ -1355,20 +1367,20 @@ msgid "" "absolute path (i.e., it may not begin with ``/``)." msgstr "" -#: ../../library/doctest.rst:915 +#: ../../library/doctest.rst:922 msgid "" "If *module_relative* is ``False``, then *filename* specifies an OS-specific " "path. The path may be absolute or relative; relative paths are resolved " "with respect to the current working directory." msgstr "" -#: ../../library/doctest.rst:919 +#: ../../library/doctest.rst:926 msgid "" "Optional argument *name* gives the name of the test; by default, or if " "``None``, ``os.path.basename(filename)`` is used." msgstr "" -#: ../../library/doctest.rst:922 +#: ../../library/doctest.rst:929 msgid "" "Optional argument *package* is a Python package or the name of a Python " "package whose directory should be used as the base directory for a module-" @@ -1377,7 +1389,7 @@ msgid "" "is an error to specify *package* if *module_relative* is ``False``." msgstr "" -#: ../../library/doctest.rst:928 +#: ../../library/doctest.rst:935 msgid "" "Optional argument *globs* gives a dict to be used as the globals when " "executing examples. A new shallow copy of this dict is created for the " @@ -1385,7 +1397,7 @@ msgid "" "``None``, a new empty dict is used." msgstr "" -#: ../../library/doctest.rst:933 +#: ../../library/doctest.rst:940 msgid "" "Optional argument *extraglobs* gives a dict merged into the globals used to " "execute examples. This works like :meth:`dict.update`: if *globs* and " @@ -1398,27 +1410,27 @@ msgid "" "tested." msgstr "" -#: ../../library/doctest.rst:942 +#: ../../library/doctest.rst:949 msgid "" "Optional argument *verbose* prints lots of stuff if true, and prints only " "failures if false; by default, or if ``None``, it's true if and only if ``'-" "v'`` is in :data:`sys.argv`." msgstr "" -#: ../../library/doctest.rst:946 +#: ../../library/doctest.rst:953 msgid "" "Optional argument *report* prints a summary at the end when true, else " "prints nothing at the end. In verbose mode, the summary is detailed, else " "the summary is very brief (in fact, empty if all tests passed)." msgstr "" -#: ../../library/doctest.rst:950 +#: ../../library/doctest.rst:957 msgid "" "Optional argument *optionflags* (default value ``0``) takes the :ref:" "`bitwise OR ` of option flags. See section :ref:`doctest-options`." msgstr "" -#: ../../library/doctest.rst:954 +#: ../../library/doctest.rst:961 msgid "" "Optional argument *raise_on_error* defaults to false. If true, an exception " "is raised upon the first failure or unexpected exception in an example. " @@ -1426,33 +1438,33 @@ msgid "" "continue running examples." msgstr "" -#: ../../library/doctest.rst:959 ../../library/doctest.rst:1102 +#: ../../library/doctest.rst:966 ../../library/doctest.rst:1109 msgid "" "Optional argument *parser* specifies a :class:`DocTestParser` (or subclass) " "that should be used to extract tests from the files. It defaults to a " "normal parser (i.e., ``DocTestParser()``)." msgstr "" -#: ../../library/doctest.rst:963 ../../library/doctest.rst:1106 +#: ../../library/doctest.rst:970 ../../library/doctest.rst:1113 msgid "" "Optional argument *encoding* specifies an encoding that should be used to " "convert the file to unicode." msgstr "" -#: ../../library/doctest.rst:969 +#: ../../library/doctest.rst:976 msgid "" "All arguments are optional, and all except for *m* should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:972 +#: ../../library/doctest.rst:979 msgid "" "Test examples in docstrings in functions and classes reachable from module " "*m* (or module :mod:`__main__` if *m* is not supplied or is ``None``), " "starting with ``m.__doc__``." msgstr "" -#: ../../library/doctest.rst:976 +#: ../../library/doctest.rst:983 msgid "" "Also test examples reachable from dict ``m.__test__``, if it exists. ``m." "__test__`` maps names (strings) to functions, classes and strings; function " @@ -1460,22 +1472,22 @@ msgid "" "directly, as if they were docstrings." msgstr "" -#: ../../library/doctest.rst:981 +#: ../../library/doctest.rst:988 msgid "" "Only docstrings attached to objects belonging to module *m* are searched." msgstr "" -#: ../../library/doctest.rst:983 +#: ../../library/doctest.rst:990 msgid "Return ``(failure_count, test_count)``." msgstr "" -#: ../../library/doctest.rst:985 +#: ../../library/doctest.rst:992 msgid "" "Optional argument *name* gives the name of the module; by default, or if " "``None``, ``m.__name__`` is used." msgstr "" -#: ../../library/doctest.rst:988 +#: ../../library/doctest.rst:995 msgid "" "Optional argument *exclude_empty* defaults to false. If true, objects for " "which no doctests are found are excluded from consideration. The default is " @@ -1486,39 +1498,39 @@ msgid "" "defaults to true." msgstr "" -#: ../../library/doctest.rst:996 +#: ../../library/doctest.rst:1003 msgid "" "Optional arguments *extraglobs*, *verbose*, *report*, *optionflags*, " "*raise_on_error*, and *globs* are the same as for function :func:`testfile` " "above, except that *globs* defaults to ``m.__dict__``." msgstr "" -#: ../../library/doctest.rst:1003 +#: ../../library/doctest.rst:1010 msgid "" "Test examples associated with object *f*; for example, *f* may be a string, " "a module, a function, or a class object." msgstr "" -#: ../../library/doctest.rst:1006 +#: ../../library/doctest.rst:1013 msgid "" "A shallow copy of dictionary argument *globs* is used for the execution " "context." msgstr "" -#: ../../library/doctest.rst:1008 +#: ../../library/doctest.rst:1015 msgid "" "Optional argument *name* is used in failure messages, and defaults to " "``\"NoName\"``." msgstr "" -#: ../../library/doctest.rst:1011 +#: ../../library/doctest.rst:1018 msgid "" "If optional argument *verbose* is true, output is generated even if there " "are no failures. By default, output is generated only in case of an example " "failure." msgstr "" -#: ../../library/doctest.rst:1014 +#: ../../library/doctest.rst:1021 msgid "" "Optional argument *compileflags* gives the set of flags that should be used " "by the Python compiler when running the examples. By default, or if " @@ -1526,16 +1538,16 @@ msgid "" "found in *globs*." msgstr "" -#: ../../library/doctest.rst:1018 +#: ../../library/doctest.rst:1025 msgid "" "Optional argument *optionflags* works as for function :func:`testfile` above." msgstr "" -#: ../../library/doctest.rst:1024 +#: ../../library/doctest.rst:1031 msgid "Unittest API" msgstr "" -#: ../../library/doctest.rst:1026 +#: ../../library/doctest.rst:1033 msgid "" "As your collection of doctest'ed modules grows, you'll want a way to run all " "their doctests systematically. :mod:`doctest` provides two functions that " @@ -1545,7 +1557,7 @@ msgid "" "your test module::" msgstr "" -#: ../../library/doctest.rst:1032 +#: ../../library/doctest.rst:1039 msgid "" "import unittest\n" "import doctest\n" @@ -1563,19 +1575,19 @@ msgstr "" " tests.addTests(doctest.DocTestSuite(my_module_with_doctests))\n" " return tests" -#: ../../library/doctest.rst:1040 +#: ../../library/doctest.rst:1047 msgid "" "There are two main functions for creating :class:`unittest.TestSuite` " "instances from text files and modules with doctests:" msgstr "" -#: ../../library/doctest.rst:1046 +#: ../../library/doctest.rst:1053 msgid "" "Convert doctest tests from one or more text files to a :class:`unittest." "TestSuite`." msgstr "" -#: ../../library/doctest.rst:1049 +#: ../../library/doctest.rst:1056 msgid "" "The returned :class:`unittest.TestSuite` is to be run by the unittest " "framework and runs the interactive examples in each file. If an example in " @@ -1586,21 +1598,21 @@ msgid "" "marked as skipped." msgstr "" -#: ../../library/doctest.rst:1056 +#: ../../library/doctest.rst:1063 msgid "Pass one or more paths (as strings) to text files to be examined." msgstr "" -#: ../../library/doctest.rst:1058 +#: ../../library/doctest.rst:1065 msgid "Options may be provided as keyword arguments:" msgstr "" -#: ../../library/doctest.rst:1060 +#: ../../library/doctest.rst:1067 msgid "" "Optional argument *module_relative* specifies how the filenames in *paths* " "should be interpreted:" msgstr "" -#: ../../library/doctest.rst:1063 +#: ../../library/doctest.rst:1070 msgid "" "If *module_relative* is ``True`` (the default), then each filename in " "*paths* specifies an OS-independent module-relative path. By default, this " @@ -1611,14 +1623,14 @@ msgid "" "``)." msgstr "" -#: ../../library/doctest.rst:1071 +#: ../../library/doctest.rst:1078 msgid "" "If *module_relative* is ``False``, then each filename in *paths* specifies " "an OS-specific path. The path may be absolute or relative; relative paths " "are resolved with respect to the current working directory." msgstr "" -#: ../../library/doctest.rst:1075 +#: ../../library/doctest.rst:1082 msgid "" "Optional argument *package* is a Python package or the name of a Python " "package whose directory should be used as the base directory for module-" @@ -1628,7 +1640,7 @@ msgid "" "``False``." msgstr "" -#: ../../library/doctest.rst:1082 +#: ../../library/doctest.rst:1089 msgid "" "Optional argument *setUp* specifies a set-up function for the test suite. " "This is called before running the tests in each file. The *setUp* function " @@ -1636,7 +1648,7 @@ msgid "" "the test globals as the :attr:`~DocTest.globs` attribute of the test passed." msgstr "" -#: ../../library/doctest.rst:1087 +#: ../../library/doctest.rst:1094 msgid "" "Optional argument *tearDown* specifies a tear-down function for the test " "suite. This is called after running the tests in each file. The *tearDown* " @@ -1645,14 +1657,14 @@ msgid "" "test passed." msgstr "" -#: ../../library/doctest.rst:1093 +#: ../../library/doctest.rst:1100 msgid "" "Optional argument *globs* is a dictionary containing the initial global " "variables for the tests. A new copy of this dictionary is created for each " "test. By default, *globs* is a new empty dictionary." msgstr "" -#: ../../library/doctest.rst:1097 +#: ../../library/doctest.rst:1104 msgid "" "Optional argument *optionflags* specifies the default doctest options for " "the tests, created by or-ing together individual option flags. See section :" @@ -1660,17 +1672,17 @@ msgid "" "for a better way to set reporting options." msgstr "" -#: ../../library/doctest.rst:1109 +#: ../../library/doctest.rst:1116 msgid "" "The global ``__file__`` is added to the globals provided to doctests loaded " "from a text file using :func:`DocFileSuite`." msgstr "" -#: ../../library/doctest.rst:1115 +#: ../../library/doctest.rst:1122 msgid "Convert doctest tests for a module to a :class:`unittest.TestSuite`." msgstr "" -#: ../../library/doctest.rst:1117 +#: ../../library/doctest.rst:1124 msgid "" "The returned :class:`unittest.TestSuite` is to be run by the unittest " "framework and runs each doctest in the module. Each docstring is run as a " @@ -1681,50 +1693,50 @@ msgid "" "then the" msgstr "" -#: ../../library/doctest.rst:1125 +#: ../../library/doctest.rst:1132 msgid "" "Optional argument *module* provides the module to be tested. It can be a " "module object or a (possibly dotted) module name. If not specified, the " "module calling this function is used." msgstr "" -#: ../../library/doctest.rst:1129 +#: ../../library/doctest.rst:1136 msgid "" "Optional argument *globs* is a dictionary containing the initial global " "variables for the tests. A new copy of this dictionary is created for each " "test. By default, *globs* is the module's :attr:`~module.__dict__`." msgstr "" -#: ../../library/doctest.rst:1133 +#: ../../library/doctest.rst:1140 msgid "" "Optional argument *extraglobs* specifies an extra set of global variables, " "which is merged into *globs*. By default, no extra globals are used." msgstr "" -#: ../../library/doctest.rst:1136 +#: ../../library/doctest.rst:1143 msgid "" "Optional argument *test_finder* is the :class:`DocTestFinder` object (or a " "drop-in replacement) that is used to extract doctests from the module." msgstr "" -#: ../../library/doctest.rst:1139 +#: ../../library/doctest.rst:1146 msgid "" "Optional arguments *setUp*, *tearDown*, and *optionflags* are the same as " "for function :func:`DocFileSuite` above, but they are called for each " "docstring." msgstr "" -#: ../../library/doctest.rst:1142 +#: ../../library/doctest.rst:1149 msgid "This function uses the same search technique as :func:`testmod`." msgstr "" -#: ../../library/doctest.rst:1144 +#: ../../library/doctest.rst:1151 msgid "" ":func:`DocTestSuite` returns an empty :class:`unittest.TestSuite` if " "*module* contains no docstrings instead of raising :exc:`ValueError`." msgstr "" -#: ../../library/doctest.rst:1148 +#: ../../library/doctest.rst:1155 msgid "" "Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` " "out of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is " @@ -1733,14 +1745,14 @@ msgid "" "questions about the exact details of :mod:`unittest` integration." msgstr "" -#: ../../library/doctest.rst:1154 +#: ../../library/doctest.rst:1161 msgid "" "Similarly, :func:`DocFileSuite` creates a :class:`unittest.TestSuite` out " "of :class:`!doctest.DocFileCase` instances, and :class:`!DocFileCase` is a " "subclass of :class:`!DocTestCase`." msgstr "" -#: ../../library/doctest.rst:1158 +#: ../../library/doctest.rst:1165 msgid "" "So both ways of creating a :class:`unittest.TestSuite` run instances of :" "class:`!DocTestCase`. This is important for a subtle reason: when you run :" @@ -1753,23 +1765,23 @@ msgid "" "pass options through :mod:`!unittest` to :mod:`!doctest` test runners." msgstr "" -#: ../../library/doctest.rst:1168 +#: ../../library/doctest.rst:1175 msgid "" "For this reason, :mod:`doctest` also supports a notion of :mod:`!doctest` " "reporting flags specific to :mod:`unittest` support, via this function:" msgstr "" -#: ../../library/doctest.rst:1174 +#: ../../library/doctest.rst:1181 msgid "Set the :mod:`doctest` reporting flags to use." msgstr "" -#: ../../library/doctest.rst:1176 +#: ../../library/doctest.rst:1183 msgid "" "Argument *flags* takes the :ref:`bitwise OR ` of option flags. See " "section :ref:`doctest-options`. Only \"reporting flags\" can be used." msgstr "" -#: ../../library/doctest.rst:1179 +#: ../../library/doctest.rst:1186 msgid "" "This is a module-global setting, and affects all future doctests run by " "module :mod:`unittest`: the :meth:`!runTest` method of :class:`!" @@ -1783,17 +1795,17 @@ msgid "" "`!doctest`'s :mod:`!unittest` reporting flags are ignored." msgstr "" -#: ../../library/doctest.rst:1190 +#: ../../library/doctest.rst:1197 msgid "" "The value of the :mod:`unittest` reporting flags in effect before the " "function was called is returned by the function." msgstr "" -#: ../../library/doctest.rst:1197 +#: ../../library/doctest.rst:1204 msgid "Advanced API" msgstr "" -#: ../../library/doctest.rst:1199 +#: ../../library/doctest.rst:1206 msgid "" "The basic API is a simple wrapper that's intended to make doctest easy to " "use. It is fairly flexible, and should meet most users' needs; however, if " @@ -1801,62 +1813,62 @@ msgid "" "doctest's capabilities, then you should use the advanced API." msgstr "" -#: ../../library/doctest.rst:1204 +#: ../../library/doctest.rst:1211 msgid "" "The advanced API revolves around two container classes, which are used to " "store the interactive examples extracted from doctest cases:" msgstr "" -#: ../../library/doctest.rst:1207 +#: ../../library/doctest.rst:1214 msgid "" ":class:`Example`: A single Python :term:`statement`, paired with its " "expected output." msgstr "" -#: ../../library/doctest.rst:1210 +#: ../../library/doctest.rst:1217 msgid "" ":class:`DocTest`: A collection of :class:`Example`\\ s, typically extracted " "from a single docstring or text file." msgstr "" -#: ../../library/doctest.rst:1213 +#: ../../library/doctest.rst:1220 msgid "" "Additional processing classes are defined to find, parse, and run, and check " "doctest examples:" msgstr "" -#: ../../library/doctest.rst:1216 +#: ../../library/doctest.rst:1223 msgid "" ":class:`DocTestFinder`: Finds all docstrings in a given module, and uses a :" "class:`DocTestParser` to create a :class:`DocTest` from every docstring that " "contains interactive examples." msgstr "" -#: ../../library/doctest.rst:1220 +#: ../../library/doctest.rst:1227 msgid "" ":class:`DocTestParser`: Creates a :class:`DocTest` object from a string " "(such as an object's docstring)." msgstr "" -#: ../../library/doctest.rst:1223 +#: ../../library/doctest.rst:1230 msgid "" ":class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and " "uses an :class:`OutputChecker` to verify their output." msgstr "" -#: ../../library/doctest.rst:1226 +#: ../../library/doctest.rst:1233 msgid "" ":class:`OutputChecker`: Compares the actual output from a doctest example " "with the expected output, and decides whether they match." msgstr "" -#: ../../library/doctest.rst:1229 +#: ../../library/doctest.rst:1236 msgid "" "The relationships among these processing classes are summarized in the " "following diagram::" msgstr "" -#: ../../library/doctest.rst:1232 +#: ../../library/doctest.rst:1239 msgid "" " list of:\n" "+------+ +---------+\n" @@ -1876,30 +1888,30 @@ msgstr "" " DocTestParser | Example | OutputChecker\n" " +---------+" -#: ../../library/doctest.rst:1245 +#: ../../library/doctest.rst:1252 msgid "DocTest Objects" msgstr "DocTest 物件" -#: ../../library/doctest.rst:1250 +#: ../../library/doctest.rst:1257 msgid "" "A collection of doctest examples that should be run in a single namespace. " "The constructor arguments are used to initialize the attributes of the same " "names." msgstr "" -#: ../../library/doctest.rst:1254 +#: ../../library/doctest.rst:1261 msgid "" ":class:`DocTest` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1260 +#: ../../library/doctest.rst:1267 msgid "" "A list of :class:`Example` objects encoding the individual interactive " "Python examples that should be run by this test." msgstr "" -#: ../../library/doctest.rst:1266 +#: ../../library/doctest.rst:1273 msgid "" "The namespace (aka globals) that the examples should be run in. This is a " "dictionary mapping names to values. Any changes to the namespace made by " @@ -1907,57 +1919,57 @@ msgid "" "`globs` after the test is run." msgstr "" -#: ../../library/doctest.rst:1274 +#: ../../library/doctest.rst:1281 msgid "" "A string name identifying the :class:`DocTest`. Typically, this is the name " "of the object or file that the test was extracted from." msgstr "" -#: ../../library/doctest.rst:1280 +#: ../../library/doctest.rst:1287 msgid "" "The name of the file that this :class:`DocTest` was extracted from; or " "``None`` if the filename is unknown, or if the :class:`!DocTest` was not " "extracted from a file." msgstr "" -#: ../../library/doctest.rst:1287 +#: ../../library/doctest.rst:1294 msgid "" "The line number within :attr:`filename` where this :class:`DocTest` begins, " "or ``None`` if the line number is unavailable. This line number is zero-" "based with respect to the beginning of the file." msgstr "" -#: ../../library/doctest.rst:1294 +#: ../../library/doctest.rst:1301 msgid "" "The string that the test was extracted from, or ``None`` if the string is " "unavailable, or if the test was not extracted from a string." msgstr "" -#: ../../library/doctest.rst:1301 +#: ../../library/doctest.rst:1308 msgid "Example Objects" msgstr "Example 物件" -#: ../../library/doctest.rst:1306 +#: ../../library/doctest.rst:1313 msgid "" "A single interactive example, consisting of a Python statement and its " "expected output. The constructor arguments are used to initialize the " "attributes of the same names." msgstr "" -#: ../../library/doctest.rst:1311 +#: ../../library/doctest.rst:1318 msgid "" ":class:`Example` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1317 +#: ../../library/doctest.rst:1324 msgid "" "A string containing the example's source code. This source code consists of " "a single Python statement, and always ends with a newline; the constructor " "adds a newline when necessary." msgstr "" -#: ../../library/doctest.rst:1324 +#: ../../library/doctest.rst:1331 msgid "" "The expected output from running the example's source code (either from " "stdout, or a traceback in case of exception). :attr:`want` ends with a " @@ -1965,7 +1977,7 @@ msgid "" "The constructor adds a newline when necessary." msgstr "" -#: ../../library/doctest.rst:1332 +#: ../../library/doctest.rst:1339 msgid "" "The exception message generated by the example, if the example is expected " "to generate an exception; or ``None`` if it is not expected to generate an " @@ -1974,20 +1986,20 @@ msgid "" "unless it's ``None``. The constructor adds a newline if needed." msgstr "" -#: ../../library/doctest.rst:1341 +#: ../../library/doctest.rst:1348 msgid "" "The line number within the string containing this example where the example " "begins. This line number is zero-based with respect to the beginning of the " "containing string." msgstr "" -#: ../../library/doctest.rst:1348 +#: ../../library/doctest.rst:1355 msgid "" "The example's indentation in the containing string, i.e., the number of " "space characters that precede the example's first prompt." msgstr "" -#: ../../library/doctest.rst:1354 +#: ../../library/doctest.rst:1361 msgid "" "A dictionary mapping from option flags to ``True`` or ``False``, which is " "used to override default options for this example. Any option flags not " @@ -1996,11 +2008,11 @@ msgid "" "default, no options are set." msgstr "" -#: ../../library/doctest.rst:1364 +#: ../../library/doctest.rst:1371 msgid "DocTestFinder objects" msgstr "DocTestFinder 物件" -#: ../../library/doctest.rst:1369 +#: ../../library/doctest.rst:1376 msgid "" "A processing class used to extract the :class:`DocTest`\\ s that are " "relevant to a given object, from its docstring and the docstrings of its " @@ -2008,48 +2020,48 @@ msgid "" "classes, functions, methods, staticmethods, classmethods, and properties." msgstr "" -#: ../../library/doctest.rst:1374 +#: ../../library/doctest.rst:1381 msgid "" "The optional argument *verbose* can be used to display the objects searched " "by the finder. It defaults to ``False`` (no output)." msgstr "" -#: ../../library/doctest.rst:1377 +#: ../../library/doctest.rst:1384 msgid "" "The optional argument *parser* specifies the :class:`DocTestParser` object " "(or a drop-in replacement) that is used to extract doctests from docstrings." msgstr "" -#: ../../library/doctest.rst:1380 +#: ../../library/doctest.rst:1387 msgid "" "If the optional argument *recurse* is false, then :meth:`DocTestFinder.find` " "will only examine the given object, and not any contained objects." msgstr "" -#: ../../library/doctest.rst:1383 +#: ../../library/doctest.rst:1390 msgid "" "If the optional argument *exclude_empty* is false, then :meth:`DocTestFinder." "find` will include tests for objects with empty docstrings." msgstr "" -#: ../../library/doctest.rst:1387 +#: ../../library/doctest.rst:1394 msgid ":class:`DocTestFinder` defines the following method:" msgstr ":class:`DocTestFinder` 定義了以下方法:" -#: ../../library/doctest.rst:1392 +#: ../../library/doctest.rst:1399 msgid "" "Return a list of the :class:`DocTest`\\ s that are defined by *obj*'s " "docstring, or by any of its contained objects' docstrings." msgstr "" -#: ../../library/doctest.rst:1395 +#: ../../library/doctest.rst:1402 msgid "" "The optional argument *name* specifies the object's name; this name will be " "used to construct names for the returned :class:`DocTest`\\ s. If *name* is " "not specified, then ``obj.__name__`` is used." msgstr "" -#: ../../library/doctest.rst:1399 +#: ../../library/doctest.rst:1406 msgid "" "The optional parameter *module* is the module that contains the given " "object. If the module is not specified or is ``None``, then the test finder " @@ -2057,26 +2069,26 @@ msgid "" "module is used:" msgstr "" -#: ../../library/doctest.rst:1403 +#: ../../library/doctest.rst:1410 msgid "As a default namespace, if *globs* is not specified." msgstr "" -#: ../../library/doctest.rst:1405 +#: ../../library/doctest.rst:1412 msgid "" "To prevent the DocTestFinder from extracting DocTests from objects that are " "imported from other modules. (Contained objects with modules other than " "*module* are ignored.)" msgstr "" -#: ../../library/doctest.rst:1409 +#: ../../library/doctest.rst:1416 msgid "To find the name of the file containing the object." msgstr "" -#: ../../library/doctest.rst:1411 +#: ../../library/doctest.rst:1418 msgid "To help find the line number of the object within its file." msgstr "" -#: ../../library/doctest.rst:1413 +#: ../../library/doctest.rst:1420 msgid "" "If *module* is ``False``, no attempt to find the module will be made. This " "is obscure, of use mostly in testing doctest itself: if *module* is " @@ -2085,7 +2097,7 @@ msgid "" "contained objects will (recursively) be searched for doctests." msgstr "" -#: ../../library/doctest.rst:1419 +#: ../../library/doctest.rst:1426 msgid "" "The globals for each :class:`DocTest` is formed by combining *globs* and " "*extraglobs* (bindings in *extraglobs* override bindings in *globs*). A new " @@ -2095,34 +2107,34 @@ msgid "" "is not specified, then it defaults to ``{}``." msgstr "" -#: ../../library/doctest.rst:1430 +#: ../../library/doctest.rst:1437 msgid "DocTestParser objects" msgstr "DocTestParser 物件" -#: ../../library/doctest.rst:1435 +#: ../../library/doctest.rst:1442 msgid "" "A processing class used to extract interactive examples from a string, and " "use them to create a :class:`DocTest` object." msgstr "" -#: ../../library/doctest.rst:1439 +#: ../../library/doctest.rst:1446 msgid ":class:`DocTestParser` defines the following methods:" msgstr ":class:`DocTestParser` 定義了以下方法:" -#: ../../library/doctest.rst:1444 +#: ../../library/doctest.rst:1451 msgid "" "Extract all doctest examples from the given string, and collect them into a :" "class:`DocTest` object." msgstr "" -#: ../../library/doctest.rst:1447 +#: ../../library/doctest.rst:1454 msgid "" "*globs*, *name*, *filename*, and *lineno* are attributes for the new :class:" "`!DocTest` object. See the documentation for :class:`DocTest` for more " "information." msgstr "" -#: ../../library/doctest.rst:1454 +#: ../../library/doctest.rst:1461 msgid "" "Extract all doctest examples from the given string, and return them as a " "list of :class:`Example` objects. Line numbers are 0-based. The optional " @@ -2130,7 +2142,7 @@ msgid "" "error messages." msgstr "" -#: ../../library/doctest.rst:1461 +#: ../../library/doctest.rst:1468 msgid "" "Divide the given string into examples and intervening text, and return them " "as a list of alternating :class:`Example`\\ s and strings. Line numbers for " @@ -2138,33 +2150,33 @@ msgid "" "name identifying this string, and is only used for error messages." msgstr "" -#: ../../library/doctest.rst:1468 +#: ../../library/doctest.rst:1475 msgid "TestResults objects" msgstr "TestResults 物件" -#: ../../library/doctest.rst:1475 +#: ../../library/doctest.rst:1482 msgid "Number of failed tests." msgstr "" -#: ../../library/doctest.rst:1479 +#: ../../library/doctest.rst:1486 msgid "Number of attempted tests." msgstr "" -#: ../../library/doctest.rst:1483 +#: ../../library/doctest.rst:1490 msgid "Number of skipped tests." msgstr "" -#: ../../library/doctest.rst:1491 +#: ../../library/doctest.rst:1498 msgid "DocTestRunner objects" msgstr "DocTestRunner 物件" -#: ../../library/doctest.rst:1496 +#: ../../library/doctest.rst:1503 msgid "" "A processing class used to execute and verify the interactive examples in a :" "class:`DocTest`." msgstr "" -#: ../../library/doctest.rst:1499 +#: ../../library/doctest.rst:1506 msgid "" "The comparison between expected outputs and actual outputs is done by an :" "class:`OutputChecker`. This comparison may be customized with a number of " @@ -2174,7 +2186,7 @@ msgid "" "constructor." msgstr "" -#: ../../library/doctest.rst:1505 +#: ../../library/doctest.rst:1512 msgid "" "The test runner's display output can be controlled in two ways. First, an " "output function can be passed to :meth:`run`; this function will be called " @@ -2185,14 +2197,14 @@ msgid "" "`report_unexpected_exception`, and :meth:`report_failure`." msgstr "" -#: ../../library/doctest.rst:1513 +#: ../../library/doctest.rst:1520 msgid "" "The optional keyword argument *checker* specifies the :class:`OutputChecker` " "object (or drop-in replacement) that should be used to compare the expected " "outputs to the actual outputs of doctest examples." msgstr "" -#: ../../library/doctest.rst:1517 +#: ../../library/doctest.rst:1524 msgid "" "The optional keyword argument *verbose* controls the :class:" "`DocTestRunner`'s verbosity. If *verbose* is ``True``, then information is " @@ -2201,14 +2213,14 @@ msgid "" "verbose output is used iff the command-line switch ``-v`` is used." msgstr "" -#: ../../library/doctest.rst:1523 +#: ../../library/doctest.rst:1530 msgid "" "The optional keyword argument *optionflags* can be used to control how the " "test runner compares expected output to actual output, and how it displays " "failures. For more information, see section :ref:`doctest-options`." msgstr "" -#: ../../library/doctest.rst:1527 +#: ../../library/doctest.rst:1534 msgid "" "The test runner accumulates statistics. The aggregated number of attempted, " "failed and skipped examples is also available via the :attr:`tries`, :attr:" @@ -2216,53 +2228,53 @@ msgid "" "`summarize` methods return a :class:`TestResults` instance." msgstr "" -#: ../../library/doctest.rst:1532 +#: ../../library/doctest.rst:1539 msgid ":class:`DocTestRunner` defines the following methods:" msgstr ":class:`DocTestRunner` 定義了以下方法:" -#: ../../library/doctest.rst:1537 +#: ../../library/doctest.rst:1544 msgid "" "Report that the test runner is about to process the given example. This " "method is provided to allow subclasses of :class:`DocTestRunner` to " "customize their output; it should not be called directly." msgstr "" -#: ../../library/doctest.rst:1541 +#: ../../library/doctest.rst:1548 msgid "" "*example* is the example about to be processed. *test* is the test " "containing *example*. *out* is the output function that was passed to :meth:" "`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1548 +#: ../../library/doctest.rst:1555 msgid "" "Report that the given example ran successfully. This method is provided to " "allow subclasses of :class:`DocTestRunner` to customize their output; it " "should not be called directly." msgstr "" -#: ../../library/doctest.rst:1552 ../../library/doctest.rst:1563 +#: ../../library/doctest.rst:1559 ../../library/doctest.rst:1570 msgid "" "*example* is the example about to be processed. *got* is the actual output " "from the example. *test* is the test containing *example*. *out* is the " "output function that was passed to :meth:`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1559 +#: ../../library/doctest.rst:1566 msgid "" "Report that the given example failed. This method is provided to allow " "subclasses of :class:`DocTestRunner` to customize their output; it should " "not be called directly." msgstr "" -#: ../../library/doctest.rst:1570 +#: ../../library/doctest.rst:1577 msgid "" "Report that the given example raised an unexpected exception. This method is " "provided to allow subclasses of :class:`DocTestRunner` to customize their " "output; it should not be called directly." msgstr "" -#: ../../library/doctest.rst:1574 +#: ../../library/doctest.rst:1581 msgid "" "*example* is the example about to be processed. *exc_info* is a tuple " "containing information about the unexpected exception (as returned by :func:" @@ -2270,14 +2282,14 @@ msgid "" "output function that was passed to :meth:`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1582 +#: ../../library/doctest.rst:1589 msgid "" "Run the examples in *test* (a :class:`DocTest` object), and display the " "results using the writer function *out*. Return a :class:`TestResults` " "instance." msgstr "" -#: ../../library/doctest.rst:1586 +#: ../../library/doctest.rst:1593 msgid "" "The examples are run in the namespace ``test.globs``. If *clear_globs* is " "true (the default), then this namespace will be cleared after the test runs, " @@ -2285,54 +2297,54 @@ msgid "" "after the test completes, then use *clear_globs=False*." msgstr "" -#: ../../library/doctest.rst:1591 +#: ../../library/doctest.rst:1598 msgid "" "*compileflags* gives the set of flags that should be used by the Python " "compiler when running the examples. If not specified, then it will default " "to the set of future-import flags that apply to *globs*." msgstr "" -#: ../../library/doctest.rst:1595 +#: ../../library/doctest.rst:1602 msgid "" "The output of each example is checked using the :class:`DocTestRunner`'s " "output checker, and the results are formatted by the :meth:`!DocTestRunner." "report_\\*` methods." msgstr "" -#: ../../library/doctest.rst:1602 +#: ../../library/doctest.rst:1609 msgid "" "Print a summary of all the test cases that have been run by this " "DocTestRunner, and return a :class:`TestResults` instance." msgstr "" -#: ../../library/doctest.rst:1605 +#: ../../library/doctest.rst:1612 msgid "" "The optional *verbose* argument controls how detailed the summary is. If " "the verbosity is not specified, then the :class:`DocTestRunner`'s verbosity " "is used." msgstr "" -#: ../../library/doctest.rst:1609 +#: ../../library/doctest.rst:1616 msgid ":class:`DocTestParser` has the following attributes:" msgstr ":class:`DocTestParser` 有以下屬性:" -#: ../../library/doctest.rst:1613 +#: ../../library/doctest.rst:1620 msgid "Number of attempted examples." msgstr "" -#: ../../library/doctest.rst:1617 +#: ../../library/doctest.rst:1624 msgid "Number of failed examples." msgstr "" -#: ../../library/doctest.rst:1621 +#: ../../library/doctest.rst:1628 msgid "Number of skipped examples." msgstr "" -#: ../../library/doctest.rst:1629 +#: ../../library/doctest.rst:1636 msgid "OutputChecker objects" msgstr "OutputChecker 物件" -#: ../../library/doctest.rst:1634 +#: ../../library/doctest.rst:1641 msgid "" "A class used to check the whether the actual output from a doctest example " "matches the expected output. :class:`OutputChecker` defines two methods: :" @@ -2341,11 +2353,11 @@ msgid "" "string describing the differences between two outputs." msgstr "" -#: ../../library/doctest.rst:1641 +#: ../../library/doctest.rst:1648 msgid ":class:`OutputChecker` defines the following methods:" msgstr ":class:`OutputChecker` 定義了以下方法:" -#: ../../library/doctest.rst:1645 +#: ../../library/doctest.rst:1652 msgid "" "Return ``True`` iff the actual output from an example (*got*) matches the " "expected output (*want*). These strings are always considered to match if " @@ -2354,28 +2366,28 @@ msgid "" "`doctest-options` for more information about option flags." msgstr "" -#: ../../library/doctest.rst:1654 +#: ../../library/doctest.rst:1661 msgid "" "Return a string describing the differences between the expected output for a " "given example (*example*) and the actual output (*got*). *optionflags* is " "the set of option flags used to compare *want* and *got*." msgstr "" -#: ../../library/doctest.rst:1662 +#: ../../library/doctest.rst:1669 msgid "Debugging" msgstr "" -#: ../../library/doctest.rst:1664 +#: ../../library/doctest.rst:1671 msgid "Doctest provides several mechanisms for debugging doctest examples:" msgstr "" -#: ../../library/doctest.rst:1666 +#: ../../library/doctest.rst:1673 msgid "" "Several functions convert doctests to executable Python programs, which can " "be run under the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1669 +#: ../../library/doctest.rst:1676 msgid "" "The :class:`DebugRunner` class is a subclass of :class:`DocTestRunner` that " "raises an exception for the first failing example, containing information " @@ -2383,13 +2395,13 @@ msgid "" "debugging on the example." msgstr "" -#: ../../library/doctest.rst:1674 +#: ../../library/doctest.rst:1681 msgid "" "The :mod:`unittest` cases generated by :func:`DocTestSuite` support the :" "meth:`debug` method defined by :class:`unittest.TestCase`." msgstr "" -#: ../../library/doctest.rst:1677 +#: ../../library/doctest.rst:1684 msgid "" "You can add a call to :func:`pdb.set_trace` in a doctest example, and you'll " "drop into the Python debugger when that line is executed. Then you can " @@ -2397,7 +2409,7 @@ msgid "" "`a.py` contains just this module docstring::" msgstr "" -#: ../../library/doctest.rst:1682 +#: ../../library/doctest.rst:1689 msgid "" "\"\"\"\n" ">>> def f(x):\n" @@ -2419,11 +2431,11 @@ msgstr "" "9\n" "\"\"\"" -#: ../../library/doctest.rst:1692 +#: ../../library/doctest.rst:1699 msgid "Then an interactive Python session may look like this::" msgstr "" -#: ../../library/doctest.rst:1694 +#: ../../library/doctest.rst:1701 msgid "" ">>> import a, doctest\n" ">>> doctest.testmod(a)\n" @@ -2485,17 +2497,17 @@ msgstr "" "(0, 3)\n" ">>>" -#: ../../library/doctest.rst:1725 +#: ../../library/doctest.rst:1732 msgid "" "Functions that convert doctests to Python code, and possibly run the " "synthesized code under the debugger:" msgstr "" -#: ../../library/doctest.rst:1731 +#: ../../library/doctest.rst:1738 msgid "Convert text with examples to a script." msgstr "" -#: ../../library/doctest.rst:1733 +#: ../../library/doctest.rst:1740 msgid "" "Argument *s* is a string containing doctest examples. The string is " "converted to a Python script, where doctest examples in *s* are converted to " @@ -2503,7 +2515,7 @@ msgid "" "generated script is returned as a string. For example, ::" msgstr "" -#: ../../library/doctest.rst:1738 +#: ../../library/doctest.rst:1745 msgid "" "import doctest\n" "print(doctest.script_from_examples(r\"\"\"\n" @@ -2516,11 +2528,11 @@ msgid "" "\"\"\"))" msgstr "" -#: ../../library/doctest.rst:1748 +#: ../../library/doctest.rst:1755 msgid "displays::" msgstr "" -#: ../../library/doctest.rst:1750 +#: ../../library/doctest.rst:1757 msgid "" "# Set x and y to 1 and 2.\n" "x, y = 1, 2\n" @@ -2531,18 +2543,18 @@ msgid "" "## 3" msgstr "" -#: ../../library/doctest.rst:1758 +#: ../../library/doctest.rst:1765 msgid "" "This function is used internally by other functions (see below), but can " "also be useful when you want to transform an interactive Python session into " "a Python script." msgstr "" -#: ../../library/doctest.rst:1765 +#: ../../library/doctest.rst:1772 msgid "Convert the doctest for an object to a script." msgstr "" -#: ../../library/doctest.rst:1767 +#: ../../library/doctest.rst:1774 msgid "" "Argument *module* is a module object, or dotted name of a module, containing " "the object whose doctests are of interest. Argument *name* is the name " @@ -2552,7 +2564,7 @@ msgid "" "module :file:`a.py` contains a top-level function :func:`!f`, then ::" msgstr "" -#: ../../library/doctest.rst:1774 +#: ../../library/doctest.rst:1781 msgid "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" @@ -2560,17 +2572,17 @@ msgstr "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" -#: ../../library/doctest.rst:1777 +#: ../../library/doctest.rst:1784 msgid "" "prints a script version of function :func:`!f`'s docstring, with doctests " "converted to code, and the rest placed in comments." msgstr "" -#: ../../library/doctest.rst:1783 +#: ../../library/doctest.rst:1790 msgid "Debug the doctests for an object." msgstr "" -#: ../../library/doctest.rst:1785 +#: ../../library/doctest.rst:1792 msgid "" "The *module* and *name* arguments are the same as for function :func:" "`testsource` above. The synthesized Python script for the named object's " @@ -2578,13 +2590,13 @@ msgid "" "the control of the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1790 +#: ../../library/doctest.rst:1797 msgid "" "A shallow copy of ``module.__dict__`` is used for both local and global " "execution context." msgstr "" -#: ../../library/doctest.rst:1793 +#: ../../library/doctest.rst:1800 msgid "" "Optional argument *pm* controls whether post-mortem debugging is used. If " "*pm* has a true value, the script file is run directly, and the debugger " @@ -2596,30 +2608,30 @@ msgid "" "to :func:`pdb.run`." msgstr "" -#: ../../library/doctest.rst:1804 +#: ../../library/doctest.rst:1811 msgid "Debug the doctests in a string." msgstr "" -#: ../../library/doctest.rst:1806 +#: ../../library/doctest.rst:1813 msgid "" "This is like function :func:`debug` above, except that a string containing " "doctest examples is specified directly, via the *src* argument." msgstr "" -#: ../../library/doctest.rst:1809 +#: ../../library/doctest.rst:1816 msgid "" "Optional argument *pm* has the same meaning as in function :func:`debug` " "above." msgstr "" -#: ../../library/doctest.rst:1811 +#: ../../library/doctest.rst:1818 msgid "" "Optional argument *globs* gives a dictionary to use as both local and global " "execution context. If not specified, or ``None``, an empty dictionary is " "used. If specified, a shallow copy of the dictionary is used." msgstr "" -#: ../../library/doctest.rst:1816 +#: ../../library/doctest.rst:1823 msgid "" "The :class:`DebugRunner` class, and the special exceptions it may raise, are " "of most interest to testing framework authors, and will only be sketched " @@ -2627,7 +2639,7 @@ msgid "" "(which is a doctest!) for more details:" msgstr "" -#: ../../library/doctest.rst:1824 +#: ../../library/doctest.rst:1831 msgid "" "A subclass of :class:`DocTestRunner` that raises an exception as soon as a " "failure is encountered. If an unexpected exception occurs, an :exc:" @@ -2637,89 +2649,89 @@ msgid "" "the actual output." msgstr "" -#: ../../library/doctest.rst:1831 +#: ../../library/doctest.rst:1838 msgid "" "For information about the constructor parameters and methods, see the " "documentation for :class:`DocTestRunner` in section :ref:`doctest-advanced-" "api`." msgstr "" -#: ../../library/doctest.rst:1834 +#: ../../library/doctest.rst:1841 msgid "" "There are two exceptions that may be raised by :class:`DebugRunner` " "instances:" msgstr "" -#: ../../library/doctest.rst:1839 +#: ../../library/doctest.rst:1846 msgid "" "An exception raised by :class:`DocTestRunner` to signal that a doctest " "example's actual output did not match its expected output. The constructor " "arguments are used to initialize the attributes of the same names." msgstr "" -#: ../../library/doctest.rst:1843 +#: ../../library/doctest.rst:1850 msgid ":exc:`DocTestFailure` defines the following attributes:" msgstr ":exc:`DocTestFailure` 定義了以下屬性:" -#: ../../library/doctest.rst:1848 ../../library/doctest.rst:1872 +#: ../../library/doctest.rst:1855 ../../library/doctest.rst:1879 msgid "The :class:`DocTest` object that was being run when the example failed." msgstr "" -#: ../../library/doctest.rst:1853 ../../library/doctest.rst:1877 +#: ../../library/doctest.rst:1860 ../../library/doctest.rst:1884 msgid "The :class:`Example` that failed." msgstr "" -#: ../../library/doctest.rst:1858 +#: ../../library/doctest.rst:1865 msgid "The example's actual output." msgstr "" -#: ../../library/doctest.rst:1863 +#: ../../library/doctest.rst:1870 msgid "" "An exception raised by :class:`DocTestRunner` to signal that a doctest " "example raised an unexpected exception. The constructor arguments are used " "to initialize the attributes of the same names." msgstr "" -#: ../../library/doctest.rst:1867 +#: ../../library/doctest.rst:1874 msgid ":exc:`UnexpectedException` defines the following attributes:" msgstr ":exc:`UnexpectedException` 定義了以下屬性:" -#: ../../library/doctest.rst:1882 +#: ../../library/doctest.rst:1889 msgid "" "A tuple containing information about the unexpected exception, as returned " "by :func:`sys.exc_info`." msgstr "" -#: ../../library/doctest.rst:1889 +#: ../../library/doctest.rst:1896 msgid "Soapbox" msgstr "" -#: ../../library/doctest.rst:1891 +#: ../../library/doctest.rst:1898 msgid "" "As mentioned in the introduction, :mod:`doctest` has grown to have three " "primary uses:" msgstr "" -#: ../../library/doctest.rst:1894 +#: ../../library/doctest.rst:1901 msgid "Checking examples in docstrings." msgstr "" -#: ../../library/doctest.rst:1896 +#: ../../library/doctest.rst:1903 msgid "Regression testing." msgstr "" -#: ../../library/doctest.rst:1898 +#: ../../library/doctest.rst:1905 msgid "Executable documentation / literate testing." msgstr "" -#: ../../library/doctest.rst:1900 +#: ../../library/doctest.rst:1907 msgid "" "These uses have different requirements, and it is important to distinguish " "them. In particular, filling your docstrings with obscure test cases makes " "for bad documentation." msgstr "" -#: ../../library/doctest.rst:1904 +#: ../../library/doctest.rst:1911 msgid "" "When writing a docstring, choose docstring examples with care. There's an " "art to this that needs to be learned---it may not be natural at first. " @@ -2731,7 +2743,7 @@ msgid "" "\"harmless\" change." msgstr "" -#: ../../library/doctest.rst:1912 +#: ../../library/doctest.rst:1919 msgid "" "Doctest also makes an excellent tool for regression testing, especially if " "you don't skimp on explanatory text. By interleaving prose and examples, it " @@ -2752,13 +2764,13 @@ msgid "" "different results, blurring the distinction between testing and explaining." msgstr "" -#: ../../library/doctest.rst:1930 +#: ../../library/doctest.rst:1937 msgid "" "Regression testing is best confined to dedicated objects or files. There " "are several options for organizing tests:" msgstr "" -#: ../../library/doctest.rst:1933 +#: ../../library/doctest.rst:1940 msgid "" "Write text files containing test cases as interactive examples, and test the " "files using :func:`testfile` or :func:`DocFileSuite`. This is recommended, " @@ -2766,7 +2778,7 @@ msgid "" "doctest." msgstr "" -#: ../../library/doctest.rst:1938 +#: ../../library/doctest.rst:1945 msgid "" "Define functions named ``_regrtest_topic`` that consist of single " "docstrings, containing test cases for the named topics. These functions can " @@ -2774,13 +2786,13 @@ msgid "" "test file." msgstr "" -#: ../../library/doctest.rst:1942 +#: ../../library/doctest.rst:1949 msgid "" "Define a :attr:`~module.__test__` dictionary mapping from regression test " "topics to docstrings containing test cases." msgstr "" -#: ../../library/doctest.rst:1945 +#: ../../library/doctest.rst:1952 msgid "" "When you have placed your tests in a module, the module can itself be the " "test runner. When a test fails, you can arrange for your test runner to re-" @@ -2788,7 +2800,7 @@ msgid "" "example of such a test runner::" msgstr "" -#: ../../library/doctest.rst:1950 +#: ../../library/doctest.rst:1957 msgid "" "if __name__ == '__main__':\n" " import doctest\n" @@ -2820,54 +2832,54 @@ msgstr "" " fail, total = doctest.testmod(optionflags=flags)\n" " print(f\"{fail} failures out of {total} tests\")" -#: ../../library/doctest.rst:1967 +#: ../../library/doctest.rst:1974 msgid "Footnotes" msgstr "註腳" -#: ../../library/doctest.rst:1968 +#: ../../library/doctest.rst:1975 msgid "" "Examples containing both expected output and an exception are not supported. " "Trying to guess where one ends and the other begins is too error-prone, and " "that also makes for a confusing test." msgstr "" -#: ../../library/doctest.rst:376 +#: ../../library/doctest.rst:383 msgid ">>>" msgstr ">>>" -#: ../../library/doctest.rst:376 +#: ../../library/doctest.rst:383 msgid "interpreter prompt" msgstr "interpreter prompt(直譯器提示)" -#: ../../library/doctest.rst:376 ../../library/doctest.rst:611 +#: ../../library/doctest.rst:383 ../../library/doctest.rst:618 msgid "..." msgstr "..." -#: ../../library/doctest.rst:542 +#: ../../library/doctest.rst:549 msgid "^ (caret)" msgstr "^ (插入符號)" -#: ../../library/doctest.rst:542 +#: ../../library/doctest.rst:549 msgid "marker" msgstr "marker(標記)" -#: ../../library/doctest.rst:591 +#: ../../library/doctest.rst:598 msgid "" msgstr "" -#: ../../library/doctest.rst:611 ../../library/doctest.rst:736 +#: ../../library/doctest.rst:618 ../../library/doctest.rst:743 msgid "in doctests" msgstr "於 doctests 中" -#: ../../library/doctest.rst:736 +#: ../../library/doctest.rst:743 msgid "# (hash)" msgstr "# (井字號)" -#: ../../library/doctest.rst:736 +#: ../../library/doctest.rst:743 msgid "+ (plus)" msgstr "+ (加號)" -#: ../../library/doctest.rst:736 +#: ../../library/doctest.rst:743 msgid "- (minus)" msgstr "- (減號)" From 90106c9e21eec8f4aa0c71f8b11daf73905f62a9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 20 Aug 2025 00:17:02 +0000 Subject: [PATCH 19/23] sync with cpython 511b37a6 --- library/asyncio-eventloop.po | 790 +++++++++++----------- library/dbm.po | 281 ++++---- library/ssl.po | 1240 +++++++++++++++++----------------- whatsnew/3.13.po | 8 +- 4 files changed, 1172 insertions(+), 1147 deletions(-) diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index a337f0aedd..76a0099f80 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-28 17:30+0000\n" +"POT-Creation-Date: 2025-08-20 00:15+0000\n" "PO-Revision-Date: 2022-02-20 12:36+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -295,8 +295,8 @@ msgid "" msgstr "請注意,使用 :func:`asyncio.run` 時不需要呼叫此函式。" #: ../../library/asyncio-eventloop.rst:177 -#: ../../library/asyncio-eventloop.rst:1326 -#: ../../library/asyncio-eventloop.rst:1775 +#: ../../library/asyncio-eventloop.rst:1338 +#: ../../library/asyncio-eventloop.rst:1787 msgid "Example::" msgstr "範例: ::" @@ -422,8 +422,8 @@ msgid "" msgstr "請參閱文件的\\ :ref:`並行和多執行緒 `\\ 部分。" #: ../../library/asyncio-eventloop.rst:251 -#: ../../library/asyncio-eventloop.rst:301 -#: ../../library/asyncio-eventloop.rst:321 +#: ../../library/asyncio-eventloop.rst:307 +#: ../../library/asyncio-eventloop.rst:333 msgid "" "The *context* keyword-only parameter was added. See :pep:`567` for more " "details." @@ -474,7 +474,7 @@ msgid "" msgstr "排程 *callback* 在給定的 *delay* 秒數後呼叫(可以是整數或浮點數)。" #: ../../library/asyncio-eventloop.rst:286 -#: ../../library/asyncio-eventloop.rst:318 +#: ../../library/asyncio-eventloop.rst:324 msgid "" "An instance of :class:`asyncio.TimerHandle` is returned which can be used to " "cancel the callback." @@ -506,7 +506,14 @@ msgstr "" "可選的僅限關鍵字 *context* 引數允許為 *callback* 指定自定義的 :class:" "`contextvars.Context` 以提供運行。當未提供 *context* 時,將使用目前情境。" -#: ../../library/asyncio-eventloop.rst:305 +#: ../../library/asyncio-eventloop.rst:303 +msgid "" +"For performance, callbacks scheduled with :meth:`loop.call_later` may run up " +"to one clock-resolution early (see ``time.get_clock_info('monotonic')." +"resolution``)." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:311 msgid "" "In Python 3.7 and earlier with the default event loop implementation, the " "*delay* could not exceed one day. This has been fixed in Python 3.8." @@ -514,7 +521,7 @@ msgstr "" "在 Python 3.7 及更早版本中,使用預設事件迴圈實作時,*delay* 不能超過一天。這" "在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:312 +#: ../../library/asyncio-eventloop.rst:318 msgid "" "Schedule *callback* to be called at the given absolute timestamp *when* (an " "int or a float), using the same time reference as :meth:`loop.time`." @@ -522,11 +529,18 @@ msgstr "" "排程 *callback* 在給定的絕對時間戳 *when* (整數或浮點數)處呼叫,使用與 :" "meth:`loop.time` 相同的時間參照。" -#: ../../library/asyncio-eventloop.rst:316 +#: ../../library/asyncio-eventloop.rst:322 msgid "This method's behavior is the same as :meth:`call_later`." msgstr "此方法的行為與 :meth:`call_later` 相同。" -#: ../../library/asyncio-eventloop.rst:325 +#: ../../library/asyncio-eventloop.rst:329 +msgid "" +"For performance, callbacks scheduled with :meth:`loop.call_at` may run up to " +"one clock-resolution early (see ``time.get_clock_info('monotonic')." +"resolution``)." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:337 msgid "" "In Python 3.7 and earlier with the default event loop implementation, the " "difference between *when* and the current time could not exceed one day. " @@ -535,13 +549,13 @@ msgstr "" "在 Python 3.7 及更早版本中,使用預設事件迴圈實作時,*when* 和目前時間之間的差" "值不能超過一天。這在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:332 +#: ../../library/asyncio-eventloop.rst:344 msgid "" "Return the current time, as a :class:`float` value, according to the event " "loop's internal monotonic clock." msgstr "根據事件迴圈的內部單調時鐘,回傳目前時間,以 :class:`float` 值表示。" -#: ../../library/asyncio-eventloop.rst:336 +#: ../../library/asyncio-eventloop.rst:348 msgid "" "In Python 3.7 and earlier timeouts (relative *delay* or absolute *when*) " "should not exceed one day. This has been fixed in Python 3.8." @@ -549,19 +563,19 @@ msgstr "" "在 Python 3.7 及更早版本中,超時(相對 *delay* 或絕對 *when*)不應超過一天。" "這在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:342 +#: ../../library/asyncio-eventloop.rst:354 msgid "The :func:`asyncio.sleep` function." msgstr "函式 :func:`asyncio.sleep`。" -#: ../../library/asyncio-eventloop.rst:346 +#: ../../library/asyncio-eventloop.rst:358 msgid "Creating Futures and Tasks" msgstr "建立 Futures 和 Tasks" -#: ../../library/asyncio-eventloop.rst:350 +#: ../../library/asyncio-eventloop.rst:362 msgid "Create an :class:`asyncio.Future` object attached to the event loop." msgstr "建立附加到事件迴圈的 :class:`asyncio.Future` 物件。" -#: ../../library/asyncio-eventloop.rst:352 +#: ../../library/asyncio-eventloop.rst:364 msgid "" "This is the preferred way to create Futures in asyncio. This lets third-" "party event loops provide alternative implementations of the Future object " @@ -570,13 +584,13 @@ msgstr "" "這是在 asyncio 中建立 Futures 的首選方式。這允許第三方事件迴圈提供 Future 物" "件的替代實作(具有更好的性能或儀器計測表現)。" -#: ../../library/asyncio-eventloop.rst:360 +#: ../../library/asyncio-eventloop.rst:372 msgid "" "Schedule the execution of :ref:`coroutine ` *coro*. Return a :" "class:`Task` object." msgstr "排程執行\\ :ref:`協程 ` *coro*。回傳 :class:`Task` 物件。" -#: ../../library/asyncio-eventloop.rst:363 +#: ../../library/asyncio-eventloop.rst:375 msgid "" "Third-party event loops can use their own subclass of :class:`Task` for " "interoperability. In this case, the result type is a subclass of :class:" @@ -585,7 +599,7 @@ msgstr "" "第三方事件迴圈可以使用其自己的 :class:`Task` 子類別以實現互操作性" "(interoperability)。在這種情況下,結果類型是 :class:`Task` 的子類別。" -#: ../../library/asyncio-eventloop.rst:367 +#: ../../library/asyncio-eventloop.rst:379 msgid "" "The full function signature is largely the same as that of the :class:`Task` " "constructor (or factory) - all of the keyword arguments to this function are " @@ -593,7 +607,7 @@ msgid "" "``None``." msgstr "" -#: ../../library/asyncio-eventloop.rst:372 +#: ../../library/asyncio-eventloop.rst:384 msgid "" "If the *name* argument is provided and not ``None``, it is set as the name " "of the task using :meth:`Task.set_name`." @@ -601,7 +615,7 @@ msgstr "" "如果提供了 *name* 引數且不為 ``None``,則將其設置為任務的名稱,使用 :meth:" "`Task.set_name`。" -#: ../../library/asyncio-eventloop.rst:375 +#: ../../library/asyncio-eventloop.rst:387 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *coro* to run in. The current context " @@ -611,32 +625,32 @@ msgstr "" "`contextvars.Context` 以提供運行。當未提供 *context* 時,將建立目前情境的副" "本。" -#: ../../library/asyncio-eventloop.rst:379 +#: ../../library/asyncio-eventloop.rst:391 msgid "Added the *name* parameter." msgstr "加入 *name* 參數。" -#: ../../library/asyncio-eventloop.rst:382 +#: ../../library/asyncio-eventloop.rst:394 msgid "Added the *context* parameter." msgstr "加入 *context* 參數。" -#: ../../library/asyncio-eventloop.rst:385 +#: ../../library/asyncio-eventloop.rst:397 msgid "" "Added ``kwargs`` which passes on arbitrary extra parameters, including " "``name`` and ``context``." msgstr "" -#: ../../library/asyncio-eventloop.rst:388 +#: ../../library/asyncio-eventloop.rst:400 msgid "" "Rolled back the change that passes on *name* and *context* (if it is None), " "while still passing on other arbitrary keyword arguments (to avoid breaking " "backwards compatibility with 3.13.3)." msgstr "" -#: ../../library/asyncio-eventloop.rst:394 +#: ../../library/asyncio-eventloop.rst:406 msgid "Set a task factory that will be used by :meth:`loop.create_task`." msgstr "設置將由 :meth:`loop.create_task` 使用的任務工廠。" -#: ../../library/asyncio-eventloop.rst:397 +#: ../../library/asyncio-eventloop.rst:409 msgid "" "If *factory* is ``None`` the default task factory will be set. Otherwise, " "*factory* must be a *callable* with the signature matching ``(loop, coro, " @@ -649,31 +663,31 @@ msgstr "" "迴圈的參照、*coro* 是一個協程物件。該可呼叫物件必須傳遞所有 *kwargs* 並回傳一" "個與 :class:`asyncio.Task` 相容的物件。" -#: ../../library/asyncio-eventloop.rst:403 +#: ../../library/asyncio-eventloop.rst:415 msgid "Required that all *kwargs* are passed on to :class:`asyncio.Task`." msgstr "" -#: ../../library/asyncio-eventloop.rst:406 +#: ../../library/asyncio-eventloop.rst:418 msgid "" "*name* is no longer passed to task factories. *context* is no longer passed " "to task factories if it is ``None``." msgstr "" -#: ../../library/asyncio-eventloop.rst:412 +#: ../../library/asyncio-eventloop.rst:424 msgid "Return a task factory or ``None`` if the default one is in use." msgstr "回傳任務工廠,如果使用預設任務工廠則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:416 +#: ../../library/asyncio-eventloop.rst:428 msgid "Opening network connections" msgstr "打開網路連線" -#: ../../library/asyncio-eventloop.rst:428 +#: ../../library/asyncio-eventloop.rst:440 msgid "" "Open a streaming transport connection to a given address specified by *host* " "and *port*." msgstr "打開以 *host* 和 *port* 指定之給定地址的串流傳輸連線。" -#: ../../library/asyncio-eventloop.rst:431 +#: ../../library/asyncio-eventloop.rst:443 msgid "" "The socket family can be either :py:const:`~socket.AF_INET` or :py:const:" "`~socket.AF_INET6` depending on *host* (or the *family* argument, if " @@ -682,13 +696,13 @@ msgstr "" "根據 *host*(或提供的 *family* 引數)的情況,socket 家族可以是 :py:const:" "`~socket.AF_INET` 或 :py:const:`~socket.AF_INET6`。" -#: ../../library/asyncio-eventloop.rst:435 +#: ../../library/asyncio-eventloop.rst:447 msgid "The socket type will be :py:const:`~socket.SOCK_STREAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_STREAM`。" -#: ../../library/asyncio-eventloop.rst:437 -#: ../../library/asyncio-eventloop.rst:1236 -#: ../../library/asyncio-eventloop.rst:1253 +#: ../../library/asyncio-eventloop.rst:449 +#: ../../library/asyncio-eventloop.rst:1248 +#: ../../library/asyncio-eventloop.rst:1265 msgid "" "*protocol_factory* must be a callable returning an :ref:`asyncio protocol " "` implementation." @@ -696,24 +710,24 @@ msgstr "" "*protocol_factory* 必須是一個回傳 :ref:`asyncio protocol ` " "實作的可呼叫函式。" -#: ../../library/asyncio-eventloop.rst:440 +#: ../../library/asyncio-eventloop.rst:452 msgid "" "This method will try to establish the connection in the background. When " "successful, it returns a ``(transport, protocol)`` pair." msgstr "" "此方法將嘗試在背景建立連線。成功時,它將回傳一對 ``(transport, protocol)``。" -#: ../../library/asyncio-eventloop.rst:443 +#: ../../library/asyncio-eventloop.rst:455 msgid "The chronological synopsis of the underlying operation is as follows:" msgstr "底層操作的時間軸簡介如下:" -#: ../../library/asyncio-eventloop.rst:445 +#: ../../library/asyncio-eventloop.rst:457 msgid "" "The connection is established and a :ref:`transport ` is " "created for it." msgstr "建立連線並為其建立\\ :ref:`傳輸 `。" -#: ../../library/asyncio-eventloop.rst:448 +#: ../../library/asyncio-eventloop.rst:460 msgid "" "*protocol_factory* is called without arguments and is expected to return a :" "ref:`protocol ` instance." @@ -721,7 +735,7 @@ msgstr "" "*protocol_factory* 在無引數的情況下被呼叫,並且預計回傳一個 :ref:`協定 " "` 實例。" -#: ../../library/asyncio-eventloop.rst:451 +#: ../../library/asyncio-eventloop.rst:463 msgid "" "The protocol instance is coupled with the transport by calling its :meth:" "`~BaseProtocol.connection_made` method." @@ -729,21 +743,21 @@ msgstr "" "通過呼叫其 :meth:`~BaseProtocol.connection_made` 方法,將協定實例與傳輸連線在" "一起。" -#: ../../library/asyncio-eventloop.rst:454 +#: ../../library/asyncio-eventloop.rst:466 msgid "A ``(transport, protocol)`` tuple is returned on success." msgstr "成功時回傳一個 ``(transport, protocol)`` 元組。" -#: ../../library/asyncio-eventloop.rst:456 +#: ../../library/asyncio-eventloop.rst:468 msgid "" "The created transport is an implementation-dependent bidirectional stream." msgstr "建立的傳輸是一個依賴實作的雙向串流。" -#: ../../library/asyncio-eventloop.rst:459 -#: ../../library/asyncio-eventloop.rst:592 +#: ../../library/asyncio-eventloop.rst:471 +#: ../../library/asyncio-eventloop.rst:604 msgid "Other arguments:" msgstr "其他引數:" -#: ../../library/asyncio-eventloop.rst:461 +#: ../../library/asyncio-eventloop.rst:473 msgid "" "*ssl*: if given and not false, a SSL/TLS transport is created (by default a " "plain TCP transport is created). If *ssl* is a :class:`ssl.SSLContext` " @@ -755,11 +769,11 @@ msgstr "" "果 *ssl* 為 :class:`ssl.SSLContext` 物件,則使用該情境來建立傳輸;如果 *ssl* " "為 :const:`True`,則使用 :func:`ssl.create_default_context` 回傳的預設情境。" -#: ../../library/asyncio-eventloop.rst:467 +#: ../../library/asyncio-eventloop.rst:479 msgid ":ref:`SSL/TLS security considerations `" msgstr ":ref:`SSL/TLS 安全考量 `" -#: ../../library/asyncio-eventloop.rst:469 +#: ../../library/asyncio-eventloop.rst:481 msgid "" "*server_hostname* sets or overrides the hostname that the target server's " "certificate will be matched against. Should only be passed if *ssl* is not " @@ -774,7 +788,7 @@ msgstr "" "預設值,必須傳遞 *server_hostname* 的值。若 *server_hostname* 為空字串,將停" "用主機名稱匹配(這是一個嚴重的安全風險,可能導致中間人攻擊)。" -#: ../../library/asyncio-eventloop.rst:477 +#: ../../library/asyncio-eventloop.rst:489 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to getaddrinfo() for *host* resolution. If given, " @@ -785,7 +799,7 @@ msgstr "" "getaddrinfo() 進行 *host* 解析。若有給定這些應該都是相應 :mod:`socket` 模組常" "數的整數。" -#: ../../library/asyncio-eventloop.rst:482 +#: ../../library/asyncio-eventloop.rst:494 msgid "" "*happy_eyeballs_delay*, if given, enables Happy Eyeballs for this " "connection. It should be a floating-point number representing the amount of " @@ -799,7 +813,7 @@ msgstr "" "`8305` 中定義的「連線嘗試延遲」。RFC 建議的合理預設值為 ``0.25`` 秒(250 毫" "秒)。" -#: ../../library/asyncio-eventloop.rst:490 +#: ../../library/asyncio-eventloop.rst:502 msgid "" "*interleave* controls address reordering when a host name resolves to " "multiple IP addresses. If ``0`` or unspecified, no reordering is done, and " @@ -815,7 +829,7 @@ msgstr "" "族計數」。如果未指定 *happy_eyeballs_delay*,則預設值為 ``0``,如果指定則為 " "``1``。" -#: ../../library/asyncio-eventloop.rst:499 +#: ../../library/asyncio-eventloop.rst:511 msgid "" "*sock*, if given, should be an existing, already connected :class:`socket." "socket` object to be used by the transport. If *sock* is given, none of " @@ -826,9 +840,9 @@ msgstr "" "輸使用。如果提供了 *sock*,則不應指定 *host*、*port*、*family*、*proto*、" "*flags*、*happy_eyeballs_delay*、*interleave* 和 *local_addr* 中的任何一項。" -#: ../../library/asyncio-eventloop.rst:507 -#: ../../library/asyncio-eventloop.rst:629 -#: ../../library/asyncio-eventloop.rst:877 +#: ../../library/asyncio-eventloop.rst:519 +#: ../../library/asyncio-eventloop.rst:641 +#: ../../library/asyncio-eventloop.rst:889 msgid "" "The *sock* argument transfers ownership of the socket to the transport " "created. To close the socket, call the transport's :meth:`~asyncio." @@ -837,7 +851,7 @@ msgstr "" "引數 *sock* 將 socket 所有權轉移給所建立的傳輸 socket,請呼叫傳輸的 :meth:" "`~asyncio.BaseTransport.close` 方法。" -#: ../../library/asyncio-eventloop.rst:511 +#: ../../library/asyncio-eventloop.rst:523 msgid "" "*local_addr*, if given, is a ``(local_host, local_port)`` tuple used to bind " "the socket locally. The *local_host* and *local_port* are looked up using " @@ -847,8 +861,8 @@ msgstr "" "地綁定 socket。將使用 ``getaddrinfo()`` 查找 *local_host* 和 *local_port*,方" "式類似於 *host* 和 *port*。" -#: ../../library/asyncio-eventloop.rst:515 -#: ../../library/asyncio-eventloop.rst:973 +#: ../../library/asyncio-eventloop.rst:527 +#: ../../library/asyncio-eventloop.rst:985 msgid "" "*ssl_handshake_timeout* is (for a TLS connection) the time in seconds to " "wait for the TLS handshake to complete before aborting the connection. " @@ -858,10 +872,10 @@ msgstr "" "在那之前若未完成則會中斷連線。如果為 ``None`` (預設值),則會等待 ``60.0`` " "秒。" -#: ../../library/asyncio-eventloop.rst:519 -#: ../../library/asyncio-eventloop.rst:784 -#: ../../library/asyncio-eventloop.rst:888 -#: ../../library/asyncio-eventloop.rst:977 +#: ../../library/asyncio-eventloop.rst:531 +#: ../../library/asyncio-eventloop.rst:796 +#: ../../library/asyncio-eventloop.rst:900 +#: ../../library/asyncio-eventloop.rst:989 msgid "" "*ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown " "to complete before aborting the connection. ``30.0`` seconds if ``None`` " @@ -870,7 +884,7 @@ msgstr "" "*ssl_shutdown_timeout* 是等待 SSL 關閉完成以前中斷連線的時間,以秒為單位。如" "果為 ``None`` (預設值),則會等待 ``30.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:523 +#: ../../library/asyncio-eventloop.rst:535 msgid "" "*all_errors* determines what exceptions are raised when a connection cannot " "be created. By default, only a single ``Exception`` is raised: the first " @@ -884,12 +898,12 @@ msgstr "" "包含所有錯誤訊息的單一 ``OSError``。當 ``all_errors`` 為 ``True`` 時,將引發" "包含所有例外的 ``ExceptionGroup`` (即使只有一個例外)。" -#: ../../library/asyncio-eventloop.rst:533 -#: ../../library/asyncio-eventloop.rst:796 +#: ../../library/asyncio-eventloop.rst:545 +#: ../../library/asyncio-eventloop.rst:808 msgid "Added support for SSL/TLS in :class:`ProactorEventLoop`." msgstr "新增 :class:`ProactorEventLoop` 中的 SSL/TLS 支援。" -#: ../../library/asyncio-eventloop.rst:537 +#: ../../library/asyncio-eventloop.rst:549 msgid "" "The socket option :ref:`socket.TCP_NODELAY ` is set " "by default for all TCP connections." @@ -897,16 +911,16 @@ msgstr "" "所有 TCP 連線都預設有 :ref:`socket.TCP_NODELAY ` " "socket 選項。" -#: ../../library/asyncio-eventloop.rst:542 -#: ../../library/asyncio-eventloop.rst:898 +#: ../../library/asyncio-eventloop.rst:554 +#: ../../library/asyncio-eventloop.rst:910 msgid "Added the *ssl_handshake_timeout* parameter." msgstr "增加 *ssl_handshake_timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:546 +#: ../../library/asyncio-eventloop.rst:558 msgid "Added the *happy_eyeballs_delay* and *interleave* parameters." msgstr "加入 *happy_eyeballs_delay* 和 *interleave* 參數。" -#: ../../library/asyncio-eventloop.rst:548 +#: ../../library/asyncio-eventloop.rst:560 msgid "" "Happy Eyeballs Algorithm: Success with Dual-Stack Hosts. When a server's " "IPv4 path and protocol are working, but the server's IPv6 path and protocol " @@ -922,24 +936,24 @@ msgstr "" "用戶端的使用者體驗變差。本文件具體說明了減少此用戶可見延遲的演算法要求並提供" "了一種演算法。" -#: ../../library/asyncio-eventloop.rst:557 +#: ../../library/asyncio-eventloop.rst:569 msgid "For more information: https://datatracker.ietf.org/doc/html/rfc6555" msgstr "更多資訊請見: https://datatracker.ietf.org/doc/html/rfc6555" -#: ../../library/asyncio-eventloop.rst:561 -#: ../../library/asyncio-eventloop.rst:693 -#: ../../library/asyncio-eventloop.rst:810 -#: ../../library/asyncio-eventloop.rst:850 -#: ../../library/asyncio-eventloop.rst:902 -#: ../../library/asyncio-eventloop.rst:985 +#: ../../library/asyncio-eventloop.rst:573 +#: ../../library/asyncio-eventloop.rst:705 +#: ../../library/asyncio-eventloop.rst:822 +#: ../../library/asyncio-eventloop.rst:862 +#: ../../library/asyncio-eventloop.rst:914 +#: ../../library/asyncio-eventloop.rst:997 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "增加 *ssl_shutdown_timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:563 +#: ../../library/asyncio-eventloop.rst:575 msgid "*all_errors* was added." msgstr "已新增 *all_errors*。" -#: ../../library/asyncio-eventloop.rst:568 +#: ../../library/asyncio-eventloop.rst:580 msgid "" "The :func:`open_connection` function is a high-level alternative API. It " "returns a pair of (:class:`StreamReader`, :class:`StreamWriter`) that can be " @@ -948,11 +962,11 @@ msgstr "" "函式 :func:`open_connection` 是高階的替代 API。它回傳一對 (:class:" "`StreamReader`, :class:`StreamWriter`) 可直接在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:579 +#: ../../library/asyncio-eventloop.rst:591 msgid "Create a datagram connection." msgstr "建立一個資料報連線。" -#: ../../library/asyncio-eventloop.rst:581 +#: ../../library/asyncio-eventloop.rst:593 msgid "" "The socket family can be either :py:const:`~socket.AF_INET`, :py:const:" "`~socket.AF_INET6`, or :py:const:`~socket.AF_UNIX`, depending on *host* (or " @@ -962,13 +976,13 @@ msgstr "" "或 :py:const:`~socket.AF_UNIX`,視乎 *host*\\ (或提供的 *family* 引數)而" "定。" -#: ../../library/asyncio-eventloop.rst:585 +#: ../../library/asyncio-eventloop.rst:597 msgid "The socket type will be :py:const:`~socket.SOCK_DGRAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_DGRAM`。" -#: ../../library/asyncio-eventloop.rst:587 -#: ../../library/asyncio-eventloop.rst:720 -#: ../../library/asyncio-eventloop.rst:869 +#: ../../library/asyncio-eventloop.rst:599 +#: ../../library/asyncio-eventloop.rst:732 +#: ../../library/asyncio-eventloop.rst:881 msgid "" "*protocol_factory* must be a callable returning a :ref:`protocol ` implementation." @@ -976,12 +990,12 @@ msgstr "" "*protocol_factory* 必須是可呼叫的函式,回傳 :ref:`protocol ` 實作。" -#: ../../library/asyncio-eventloop.rst:590 -#: ../../library/asyncio-eventloop.rst:675 +#: ../../library/asyncio-eventloop.rst:602 +#: ../../library/asyncio-eventloop.rst:687 msgid "A tuple of ``(transport, protocol)`` is returned on success." msgstr "成功時回傳 ``(transport, protocol)`` 元組。" -#: ../../library/asyncio-eventloop.rst:594 +#: ../../library/asyncio-eventloop.rst:606 msgid "" "*local_addr*, if given, is a ``(local_host, local_port)`` tuple used to bind " "the socket locally. The *local_host* and *local_port* are looked up using :" @@ -990,13 +1004,13 @@ msgstr "" "*local_addr*,如果提供,是一個 ``(local_host, local_port)`` 元組,用於在本地" "綁定 socket。*local_host* 和 *local_port* 使用 :meth:`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:600 +#: ../../library/asyncio-eventloop.rst:612 msgid "" "On Windows, when using the proactor event loop with ``local_addr=None``, an :" "exc:`OSError` with :attr:`!errno.WSAEINVAL` will be raised when running it." msgstr "" -#: ../../library/asyncio-eventloop.rst:604 +#: ../../library/asyncio-eventloop.rst:616 msgid "" "*remote_addr*, if given, is a ``(remote_host, remote_port)`` tuple used to " "connect the socket to a remote address. The *remote_host* and *remote_port* " @@ -1006,7 +1020,7 @@ msgstr "" "socket 連線到遠端位址。 *remote_host* 和 *remote_port* 使用 :meth:" "`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:608 +#: ../../library/asyncio-eventloop.rst:620 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to :meth:`getaddrinfo` for *host* resolution. If " @@ -1017,7 +1031,7 @@ msgstr "" "的可選地址家族、協定和旗標。如果提供,這些應該都是來自相應的 :mod:`socket` 模" "組常數的整數。" -#: ../../library/asyncio-eventloop.rst:613 +#: ../../library/asyncio-eventloop.rst:625 msgid "" "*reuse_port* tells the kernel to allow this endpoint to be bound to the same " "port as other existing endpoints are bound to, so long as they all set this " @@ -1029,13 +1043,13 @@ msgstr "" "時都設定了此旗標。此選項不受 Windows 和某些 Unix 系統支援。如果未定義 :py:" "const:`~socket.SO_REUSEPORT` 常數,則不支援此功能。" -#: ../../library/asyncio-eventloop.rst:619 +#: ../../library/asyncio-eventloop.rst:631 msgid "" "*allow_broadcast* tells the kernel to allow this endpoint to send messages " "to the broadcast address." msgstr "*allow_broadcast* 告訴核心允許此端點向廣播位址發送訊息。" -#: ../../library/asyncio-eventloop.rst:622 +#: ../../library/asyncio-eventloop.rst:634 msgid "" "*sock* can optionally be specified in order to use a preexisting, already " "connected, :class:`socket.socket` object to be used by the transport. If " @@ -1046,7 +1060,7 @@ msgstr "" "供傳輸使用。如果指定,*local_addr* 和 *remote_addr* 應省略(必須是 :const:" "`None`\\ )。" -#: ../../library/asyncio-eventloop.rst:633 +#: ../../library/asyncio-eventloop.rst:645 msgid "" "See :ref:`UDP echo client protocol ` and :" "ref:`UDP echo server protocol ` examples." @@ -1054,7 +1068,7 @@ msgstr "" "請參閱 :ref:`UDP 回應用戶端協定 ` 和 :ref:" "`UDP 回應伺服器協定 ` 範例。" -#: ../../library/asyncio-eventloop.rst:636 +#: ../../library/asyncio-eventloop.rst:648 msgid "" "The *family*, *proto*, *flags*, *reuse_address*, *reuse_port*, " "*allow_broadcast*, and *sock* parameters were added." @@ -1062,11 +1076,11 @@ msgstr "" "新增 *family*、*proto*、*flags*、*reuse_address*、*reuse_port*、" "*allow_broadcast* 和 *sock* 參數。" -#: ../../library/asyncio-eventloop.rst:640 +#: ../../library/asyncio-eventloop.rst:652 msgid "Added support for Windows." msgstr "新增對於 Windows 的支援。" -#: ../../library/asyncio-eventloop.rst:643 +#: ../../library/asyncio-eventloop.rst:655 msgid "" "The *reuse_address* parameter is no longer supported, as using :ref:`socket." "SO_REUSEADDR ` poses a significant security concern " @@ -1075,7 +1089,7 @@ msgstr "" "不再支援 *reuse_address* 參數,因為使用 :py:const:`~sockets.SO_REUSEADDR` 對" "於 UDP 存有重大的安全疑慮。明確傳遞 ``reuse_address=True`` 將引發例外。" -#: ../../library/asyncio-eventloop.rst:649 +#: ../../library/asyncio-eventloop.rst:661 msgid "" "When multiple processes with differing UIDs assign sockets to an identical " "UDP socket address with ``SO_REUSEADDR``, incoming packets can become " @@ -1084,7 +1098,7 @@ msgstr "" "當具有不同 UID 的多個行程使用 ``SO_REUSEADDR`` 將 socket 分配給相同的 UDP " "socket 地址時,傳入的封包可能會在 socket 之間隨機分佈。" -#: ../../library/asyncio-eventloop.rst:653 +#: ../../library/asyncio-eventloop.rst:665 msgid "" "For supported platforms, *reuse_port* can be used as a replacement for " "similar functionality. With *reuse_port*, :ref:`socket.SO_REUSEPORT ` is set by default " @@ -1310,7 +1324,7 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。所有 TCP 連線都預設有 :" "ref:`socket.TCP_NODELAY ` socket 選項。" -#: ../../library/asyncio-eventloop.rst:814 +#: ../../library/asyncio-eventloop.rst:826 msgid "" "The :func:`start_server` function is a higher-level alternative API that " "returns a pair of :class:`StreamReader` and :class:`StreamWriter` that can " @@ -1319,7 +1333,7 @@ msgstr "" ":func:`start_server` 函式是一個更高階的替代 API,它回傳一對 :class:" "`StreamReader` 和 :class:`StreamWriter`,可以在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:826 +#: ../../library/asyncio-eventloop.rst:838 msgid "" "Similar to :meth:`loop.create_server` but works with the :py:const:`~socket." "AF_UNIX` socket family." @@ -1327,7 +1341,7 @@ msgstr "" "類似 :meth:`loop.create_server`,但適用於 :py:const:`~socket.AF_UNIX` socket " "家族。" -#: ../../library/asyncio-eventloop.rst:829 +#: ../../library/asyncio-eventloop.rst:841 msgid "" "*path* is the name of a Unix domain socket, and is required, unless a *sock* " "argument is provided. Abstract Unix sockets, :class:`str`, :class:`bytes`, " @@ -1337,7 +1351,7 @@ msgstr "" "象 Unix sockets、:class:`str`、:class:`bytes` 和 :class:`~pathlib.Path` 路" "徑。" -#: ../../library/asyncio-eventloop.rst:834 +#: ../../library/asyncio-eventloop.rst:846 msgid "" "If *cleanup_socket* is true then the Unix socket will automatically be " "removed from the filesystem when the server is closed, unless the socket has " @@ -1346,13 +1360,13 @@ msgstr "" "如果 *cleanup_socket* 為真,則 Unix socket 將在伺服器關閉時自動從檔案系統中刪" "除,除非在建立伺服器後替換了 socket。" -#: ../../library/asyncio-eventloop.rst:838 +#: ../../library/asyncio-eventloop.rst:850 msgid "" "See the documentation of the :meth:`loop.create_server` method for " "information about arguments to this method." msgstr "有關此方法的引數資訊,請參閱 :meth:`loop.create_server` 方法的文件。" -#: ../../library/asyncio-eventloop.rst:845 +#: ../../library/asyncio-eventloop.rst:857 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :class:`~pathlib.Path` object." @@ -1360,26 +1374,26 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。*path* 參數現在可為一" "個 :class:`~pathlib.Path` 物件。" -#: ../../library/asyncio-eventloop.rst:854 +#: ../../library/asyncio-eventloop.rst:866 msgid "Added the *cleanup_socket* parameter." msgstr "加入 *cleanup_socket* 參數。" -#: ../../library/asyncio-eventloop.rst:862 +#: ../../library/asyncio-eventloop.rst:874 msgid "Wrap an already accepted connection into a transport/protocol pair." msgstr "將已接受的連線包裝成傳輸層/協定對。" -#: ../../library/asyncio-eventloop.rst:864 +#: ../../library/asyncio-eventloop.rst:876 msgid "" "This method can be used by servers that accept connections outside of " "asyncio but that use asyncio to handle them." msgstr "此方法可以由在 asyncio 外接受連線但使用 asyncio 處理連線的伺服器使用。" -#: ../../library/asyncio-eventloop.rst:867 -#: ../../library/asyncio-eventloop.rst:959 +#: ../../library/asyncio-eventloop.rst:879 +#: ../../library/asyncio-eventloop.rst:971 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-eventloop.rst:872 +#: ../../library/asyncio-eventloop.rst:884 msgid "" "*sock* is a preexisting socket object returned from :meth:`socket.accept " "`." @@ -1387,13 +1401,13 @@ msgstr "" "*sock* 是從 :meth:`socket.accept ` 回傳的預先存在的 " "socket 物件。" -#: ../../library/asyncio-eventloop.rst:881 +#: ../../library/asyncio-eventloop.rst:893 msgid "" "*ssl* can be set to an :class:`~ssl.SSLContext` to enable SSL over the " "accepted connections." msgstr "*ssl* 可以設置為 :class:`~ssl.SSLContext` 以在已接受的連線上啟用 SSL。" -#: ../../library/asyncio-eventloop.rst:884 +#: ../../library/asyncio-eventloop.rst:896 msgid "" "*ssl_handshake_timeout* is (for an SSL connection) the time in seconds to " "wait for the SSL handshake to complete before aborting the connection. " @@ -1402,29 +1416,29 @@ msgstr "" "(對於 SSL 連線)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 SSL 握手完成" "的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:892 +#: ../../library/asyncio-eventloop.rst:904 msgid "Returns a ``(transport, protocol)`` pair." msgstr "回傳 ``(transport, protocol)`` 對。" -#: ../../library/asyncio-eventloop.rst:906 +#: ../../library/asyncio-eventloop.rst:918 msgid "Transferring files" msgstr "傳輸檔案" -#: ../../library/asyncio-eventloop.rst:912 +#: ../../library/asyncio-eventloop.rst:924 msgid "" "Send a *file* over a *transport*. Return the total number of bytes sent." msgstr "通過 *transport* 發送 *file*。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:915 +#: ../../library/asyncio-eventloop.rst:927 msgid "The method uses high-performance :meth:`os.sendfile` if available." msgstr "如果可用,該方法使用高性能 :meth:`os.sendfile`。" -#: ../../library/asyncio-eventloop.rst:917 +#: ../../library/asyncio-eventloop.rst:929 msgid "*file* must be a regular file object opened in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:919 -#: ../../library/asyncio-eventloop.rst:1180 +#: ../../library/asyncio-eventloop.rst:931 +#: ../../library/asyncio-eventloop.rst:1192 msgid "" "*offset* tells from where to start reading the file. If specified, *count* " "is the total number of bytes to transmit as opposed to sending the file " @@ -1436,7 +1450,7 @@ msgstr "" "不是發送檔案直到達到 EOF。即使此方法引發錯誤時,檔案位置也始終更新,可以使" "用 :meth:`file.tell() ` 取得實際發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:926 +#: ../../library/asyncio-eventloop.rst:938 msgid "" "*fallback* set to ``True`` makes asyncio to manually read and send the file " "when the platform does not support the sendfile system call (e.g. Windows or " @@ -1445,7 +1459,7 @@ msgstr "" "將 *fallback* 設置為 ``True`` 會使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:930 +#: ../../library/asyncio-eventloop.rst:942 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support the " "*sendfile* syscall and *fallback* is ``False``." @@ -1453,15 +1467,15 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,則引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:937 +#: ../../library/asyncio-eventloop.rst:949 msgid "TLS Upgrade" msgstr "TLS 升級" -#: ../../library/asyncio-eventloop.rst:945 +#: ../../library/asyncio-eventloop.rst:957 msgid "Upgrade an existing transport-based connection to TLS." msgstr "將基於傳輸的現有連線升級到 TLS。" -#: ../../library/asyncio-eventloop.rst:947 +#: ../../library/asyncio-eventloop.rst:959 msgid "" "Create a TLS coder/decoder instance and insert it between the *transport* " "and the *protocol*. The coder/decoder implements both *transport*-facing " @@ -1470,7 +1484,7 @@ msgstr "" "建立 TLS 編解碼器實例並在 *transport* 和 *protocol* 之間插入它。編解碼器既實" "作了對於 *transport* 的協定,也實作了對於 *protocol* 的傳輸。" -#: ../../library/asyncio-eventloop.rst:951 +#: ../../library/asyncio-eventloop.rst:963 msgid "" "Return the created two-interface instance. After *await*, the *protocol* " "must stop using the original *transport* and communicate with the returned " @@ -1481,13 +1495,13 @@ msgstr "" "*transport*,僅與回傳的物件通信,因為編碼器快取了 *protocol* 端的資料,並且" "與 *transport* 間歇性地交換額外的 TLS session 封包。" -#: ../../library/asyncio-eventloop.rst:956 +#: ../../library/asyncio-eventloop.rst:968 msgid "" "In some situations (e.g. when the passed transport is already closing) this " "may return ``None``." msgstr "在某些情況下(例如傳入的傳輸已經關閉),此函式可能回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:961 +#: ../../library/asyncio-eventloop.rst:973 msgid "" "*transport* and *protocol* instances that methods like :meth:`~loop." "create_server` and :meth:`~loop.create_connection` return." @@ -1495,11 +1509,11 @@ msgstr "" "*transport* 和 *protocol* 實例,由像 :meth:`~loop.create_server` 和 :meth:" "`~loop.create_connection` 等方法回傳。" -#: ../../library/asyncio-eventloop.rst:965 +#: ../../library/asyncio-eventloop.rst:977 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "*sslcontext*:配置好的 :class:`~ssl.SSLContext` 實例。" -#: ../../library/asyncio-eventloop.rst:967 +#: ../../library/asyncio-eventloop.rst:979 msgid "" "*server_side* pass ``True`` when a server-side connection is being upgraded " "(like the one created by :meth:`~loop.create_server`)." @@ -1507,17 +1521,17 @@ msgstr "" "當升級伺服器端連線時(像由 :meth:`~loop.create_server` 建立的那樣)傳遞 " "``True``。" -#: ../../library/asyncio-eventloop.rst:970 +#: ../../library/asyncio-eventloop.rst:982 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." msgstr "*server_hostname*:設置或覆蓋將用於匹配目標伺服器憑證的主機名。" -#: ../../library/asyncio-eventloop.rst:990 +#: ../../library/asyncio-eventloop.rst:1002 msgid "Watching file descriptors" msgstr "監視檔案描述器" -#: ../../library/asyncio-eventloop.rst:994 +#: ../../library/asyncio-eventloop.rst:1006 msgid "" "Start monitoring the *fd* file descriptor for read availability and invoke " "*callback* with the specified arguments once *fd* is available for reading." @@ -1525,14 +1539,14 @@ msgstr "" "開始監視 *fd* 檔案描述器的讀取可用性,一但 *fd* 可讀取,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:998 -#: ../../library/asyncio-eventloop.rst:1012 +#: ../../library/asyncio-eventloop.rst:1010 +#: ../../library/asyncio-eventloop.rst:1024 msgid "" "Any preexisting callback registered for *fd* is cancelled and replaced by " "*callback*." msgstr "任何預先存在、為 *fd* 註冊的回呼函式將被取消並替換為 *callback*。" -#: ../../library/asyncio-eventloop.rst:1003 +#: ../../library/asyncio-eventloop.rst:1015 msgid "" "Stop monitoring the *fd* file descriptor for read availability. Returns " "``True`` if *fd* was previously being monitored for reads." @@ -1540,7 +1554,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的讀取可用性。如果 *fd* 之前正在監視讀取,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:1008 +#: ../../library/asyncio-eventloop.rst:1020 msgid "" "Start monitoring the *fd* file descriptor for write availability and invoke " "*callback* with the specified arguments once *fd* is available for writing." @@ -1548,8 +1562,8 @@ msgstr "" "開始監視 *fd* 檔案描述器的寫入可用性,一旦 *fd* 可寫入,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:1015 -#: ../../library/asyncio-eventloop.rst:1293 +#: ../../library/asyncio-eventloop.rst:1027 +#: ../../library/asyncio-eventloop.rst:1305 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *callback*." @@ -1557,7 +1571,7 @@ msgstr "" "使用 :func:`functools.partial` 向 *callback* :ref:`傳送關鍵字引數 `。" -#: ../../library/asyncio-eventloop.rst:1020 +#: ../../library/asyncio-eventloop.rst:1032 msgid "" "Stop monitoring the *fd* file descriptor for write availability. Returns " "``True`` if *fd* was previously being monitored for writes." @@ -1565,7 +1579,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的寫入可用性。如果 *fd* 之前正在監視寫入,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:1023 +#: ../../library/asyncio-eventloop.rst:1035 msgid "" "See also :ref:`Platform Support ` section for some " "limitations of these methods." @@ -1573,11 +1587,11 @@ msgstr "" "另請參閱\\ :ref:`平台支援 `\\ 部分以了解這些方法的" "一些限制。" -#: ../../library/asyncio-eventloop.rst:1028 +#: ../../library/asyncio-eventloop.rst:1040 msgid "Working with socket objects directly" msgstr "直接使用 socket 物件" -#: ../../library/asyncio-eventloop.rst:1030 +#: ../../library/asyncio-eventloop.rst:1042 msgid "" "In general, protocol implementations that use transport-based APIs such as :" "meth:`loop.create_connection` and :meth:`loop.create_server` are faster than " @@ -1589,7 +1603,7 @@ msgstr "" "`loop.create_server`)的協定實作比直接使用 socket 的實作更快。然而在某些情況" "下性能不是關鍵,直接使用 :class:`~socket.socket` 物件更方便。" -#: ../../library/asyncio-eventloop.rst:1040 +#: ../../library/asyncio-eventloop.rst:1052 msgid "" "Receive up to *nbytes* from *sock*. Asynchronous version of :meth:`socket." "recv() `." @@ -1597,23 +1611,23 @@ msgstr "" "從 *sock* 接收最多 *nbytes*。:meth:`socket.recv() ` 的非" "同步版本。" -#: ../../library/asyncio-eventloop.rst:1043 +#: ../../library/asyncio-eventloop.rst:1055 msgid "Return the received data as a bytes object." msgstr "將接收到的資料作為 bytes 物件回傳。" -#: ../../library/asyncio-eventloop.rst:1045 -#: ../../library/asyncio-eventloop.rst:1060 +#: ../../library/asyncio-eventloop.rst:1057 #: ../../library/asyncio-eventloop.rst:1072 -#: ../../library/asyncio-eventloop.rst:1085 -#: ../../library/asyncio-eventloop.rst:1101 -#: ../../library/asyncio-eventloop.rst:1117 -#: ../../library/asyncio-eventloop.rst:1128 -#: ../../library/asyncio-eventloop.rst:1155 -#: ../../library/asyncio-eventloop.rst:1194 +#: ../../library/asyncio-eventloop.rst:1084 +#: ../../library/asyncio-eventloop.rst:1097 +#: ../../library/asyncio-eventloop.rst:1113 +#: ../../library/asyncio-eventloop.rst:1129 +#: ../../library/asyncio-eventloop.rst:1140 +#: ../../library/asyncio-eventloop.rst:1167 +#: ../../library/asyncio-eventloop.rst:1206 msgid "*sock* must be a non-blocking socket." msgstr "*sock* 必須是非阻塞 socket。" -#: ../../library/asyncio-eventloop.rst:1047 +#: ../../library/asyncio-eventloop.rst:1059 msgid "" "Even though this method was always documented as a coroutine method, " "releases before Python 3.7 returned a :class:`Future`. Since Python 3.7 this " @@ -1622,7 +1636,7 @@ msgstr "" "儘管此方法一直記錄為協程方法,但 Python 3.7 之前的版本回傳 :class:`Future`。" "自 Python 3.7 起,這是 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1055 +#: ../../library/asyncio-eventloop.rst:1067 msgid "" "Receive data from *sock* into the *buf* buffer. Modeled after the blocking :" "meth:`socket.recv_into() ` method." @@ -1630,11 +1644,11 @@ msgstr "" "從 *sock* 接收資料到 *buf* 緩衝區。仿照阻塞 :meth:`socket.recv_into() " "` 方法。" -#: ../../library/asyncio-eventloop.rst:1058 +#: ../../library/asyncio-eventloop.rst:1070 msgid "Return the number of bytes written to the buffer." msgstr "回傳寫入緩衝區位元組的數目。" -#: ../../library/asyncio-eventloop.rst:1067 +#: ../../library/asyncio-eventloop.rst:1079 msgid "" "Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of :" "meth:`socket.recvfrom() `." @@ -1642,11 +1656,11 @@ msgstr "" "從 *sock* 接收最多 *bufsize* 大小的資料單元。:meth:`socket.recvfrom() " "` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1070 +#: ../../library/asyncio-eventloop.rst:1082 msgid "Return a tuple of (received data, remote address)." msgstr "回傳一個元組 (received data, remote address)。" -#: ../../library/asyncio-eventloop.rst:1079 +#: ../../library/asyncio-eventloop.rst:1091 msgid "" "Receive a datagram of up to *nbytes* from *sock* into *buf*. Asynchronous " "version of :meth:`socket.recvfrom_into() `." @@ -1654,11 +1668,11 @@ msgstr "" "從 *sock* 接收最多 *nbytes* 大小的資料單元到 *buf*。:meth:`socket." "recvfrom_into() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1083 +#: ../../library/asyncio-eventloop.rst:1095 msgid "Return a tuple of (number of bytes received, remote address)." msgstr "回傳一個元組 (number of bytes received, remote address)。" -#: ../../library/asyncio-eventloop.rst:1092 +#: ../../library/asyncio-eventloop.rst:1104 msgid "" "Send *data* to the *sock* socket. Asynchronous version of :meth:`socket." "sendall() `." @@ -1666,7 +1680,7 @@ msgstr "" "將 *data* 發送到 *sock* socket。:meth:`socket.sendall() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1095 +#: ../../library/asyncio-eventloop.rst:1107 msgid "" "This method continues to send to the socket until either all data in *data* " "has been sent or an error occurs. ``None`` is returned on success. On " @@ -1678,8 +1692,8 @@ msgstr "" "回傳 ``None``。錯誤時引發例外。此外,沒有辦法確定接收端成功處理了多少資料(如" "果有的話)。" -#: ../../library/asyncio-eventloop.rst:1103 -#: ../../library/asyncio-eventloop.rst:1157 +#: ../../library/asyncio-eventloop.rst:1115 +#: ../../library/asyncio-eventloop.rst:1169 msgid "" "Even though the method was always documented as a coroutine method, before " "Python 3.7 it returned a :class:`Future`. Since Python 3.7, this is an " @@ -1688,7 +1702,7 @@ msgstr "" "儘管該方法一直被記錄為協程方法,但在 Python 3.7 之前它回傳 :class:`Future`。" "從 Python 3.7 開始,這是一個 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1111 +#: ../../library/asyncio-eventloop.rst:1123 msgid "" "Send a datagram from *sock* to *address*. Asynchronous version of :meth:" "`socket.sendto() `." @@ -1696,20 +1710,20 @@ msgstr "" "從 *sock* 向 *address* 發送一個資料單元。:meth:`socket.sendto() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1115 +#: ../../library/asyncio-eventloop.rst:1127 msgid "Return the number of bytes sent." msgstr "回傳發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:1124 +#: ../../library/asyncio-eventloop.rst:1136 msgid "Connect *sock* to a remote socket at *address*." msgstr "將 *sock* 連線到位於 *address* 的遠端 socket。" -#: ../../library/asyncio-eventloop.rst:1126 +#: ../../library/asyncio-eventloop.rst:1138 msgid "" "Asynchronous version of :meth:`socket.connect() `." msgstr ":meth:`socket.connect() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1130 +#: ../../library/asyncio-eventloop.rst:1142 msgid "" "``address`` no longer needs to be resolved. ``sock_connect`` will try to " "check if the *address* is already resolved by calling :func:`socket." @@ -1720,7 +1734,7 @@ msgstr "" "inet_pton` 檢查 *address* 是否已解析。如果沒有,將使用 :meth:`loop." "getaddrinfo` 解析 *address*。" -#: ../../library/asyncio-eventloop.rst:1139 +#: ../../library/asyncio-eventloop.rst:1151 msgid "" ":meth:`loop.create_connection` and :func:`asyncio.open_connection() " "`." @@ -1728,7 +1742,7 @@ msgstr "" ":meth:`loop.create_connection` 和 :func:`asyncio.open_connection() " "`。" -#: ../../library/asyncio-eventloop.rst:1146 +#: ../../library/asyncio-eventloop.rst:1158 msgid "" "Accept a connection. Modeled after the blocking :meth:`socket.accept() " "` method." @@ -1736,7 +1750,7 @@ msgstr "" "接受一個連線。模擬阻塞的 :meth:`socket.accept() ` 方" "法。" -#: ../../library/asyncio-eventloop.rst:1149 +#: ../../library/asyncio-eventloop.rst:1161 msgid "" "The socket must be bound to an address and listening for connections. The " "return value is a pair ``(conn, address)`` where *conn* is a *new* socket " @@ -1747,34 +1761,34 @@ msgstr "" "中 *conn* 是一個 *新* socket 物件,可在連線上發送和接收資料,*address* 是連接" "另一端對應的 socket 地址。" -#: ../../library/asyncio-eventloop.rst:1164 +#: ../../library/asyncio-eventloop.rst:1176 msgid ":meth:`loop.create_server` and :func:`start_server`." msgstr ":meth:`loop.create_server` 和 :func:`start_server`。" -#: ../../library/asyncio-eventloop.rst:1170 +#: ../../library/asyncio-eventloop.rst:1182 msgid "" "Send a file using high-performance :mod:`os.sendfile` if possible. Return " "the total number of bytes sent." msgstr "" "如果可行,使用高性能 :mod:`os.sendfile` 發送檔案。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:1173 +#: ../../library/asyncio-eventloop.rst:1185 msgid "" "Asynchronous version of :meth:`socket.sendfile() `." msgstr ":meth:`socket.sendfile() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1175 +#: ../../library/asyncio-eventloop.rst:1187 msgid "" "*sock* must be a non-blocking :const:`socket.SOCK_STREAM` :class:`~socket." "socket`." msgstr "" "*sock* 必須是非阻塞的 :const:`socket.SOCK_STREAM` :class:`~socket.socket`。" -#: ../../library/asyncio-eventloop.rst:1178 +#: ../../library/asyncio-eventloop.rst:1190 msgid "*file* must be a regular file object open in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:1187 +#: ../../library/asyncio-eventloop.rst:1199 msgid "" "*fallback*, when set to ``True``, makes asyncio manually read and send the " "file when the platform does not support the sendfile syscall (e.g. Windows " @@ -1783,7 +1797,7 @@ msgstr "" "當設置為 ``True`` 時,*fallback* 使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:1191 +#: ../../library/asyncio-eventloop.rst:1203 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support " "*sendfile* syscall and *fallback* is ``False``." @@ -1791,19 +1805,19 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:1200 +#: ../../library/asyncio-eventloop.rst:1212 msgid "DNS" msgstr "DNS" -#: ../../library/asyncio-eventloop.rst:1206 +#: ../../library/asyncio-eventloop.rst:1218 msgid "Asynchronous version of :meth:`socket.getaddrinfo`." msgstr ":meth:`socket.getaddrinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1211 +#: ../../library/asyncio-eventloop.rst:1223 msgid "Asynchronous version of :meth:`socket.getnameinfo`." msgstr ":meth:`socket.getnameinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1214 +#: ../../library/asyncio-eventloop.rst:1226 msgid "" "Both *getaddrinfo* and *getnameinfo* internally utilize their synchronous " "versions through the loop's default thread pool executor. When this executor " @@ -1813,7 +1827,7 @@ msgid "" "executor with a larger number of workers." msgstr "" -#: ../../library/asyncio-eventloop.rst:1221 +#: ../../library/asyncio-eventloop.rst:1233 msgid "" "Both *getaddrinfo* and *getnameinfo* methods were always documented to " "return a coroutine, but prior to Python 3.7 they were, in fact, returning :" @@ -1824,19 +1838,19 @@ msgstr "" "它們實際上回傳 :class:`asyncio.Future` 物件。從 Python 3.7 開始,兩個方法都是" "協程。" -#: ../../library/asyncio-eventloop.rst:1229 +#: ../../library/asyncio-eventloop.rst:1241 msgid "Working with pipes" msgstr "使用管道" -#: ../../library/asyncio-eventloop.rst:1234 +#: ../../library/asyncio-eventloop.rst:1246 msgid "Register the read end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的讀取端。" -#: ../../library/asyncio-eventloop.rst:1239 +#: ../../library/asyncio-eventloop.rst:1251 msgid "*pipe* is a :term:`file-like object `." msgstr "*pipe* 是 :term:`類檔案物件 `。" -#: ../../library/asyncio-eventloop.rst:1241 +#: ../../library/asyncio-eventloop.rst:1253 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports the :class:" "`ReadTransport` interface and *protocol* is an object instantiated by the " @@ -1845,22 +1859,22 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`ReadTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1245 -#: ../../library/asyncio-eventloop.rst:1262 +#: ../../library/asyncio-eventloop.rst:1257 +#: ../../library/asyncio-eventloop.rst:1274 msgid "" "With :class:`SelectorEventLoop` event loop, the *pipe* is set to non-" "blocking mode." msgstr "使用 :class:`SelectorEventLoop` 事件迴圈時,*pipe* 設置為非阻塞模式。" -#: ../../library/asyncio-eventloop.rst:1251 +#: ../../library/asyncio-eventloop.rst:1263 msgid "Register the write end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的寫入端。" -#: ../../library/asyncio-eventloop.rst:1256 +#: ../../library/asyncio-eventloop.rst:1268 msgid "*pipe* is :term:`file-like object `." msgstr "*pipe* 是 :term:`file-like object `。" -#: ../../library/asyncio-eventloop.rst:1258 +#: ../../library/asyncio-eventloop.rst:1270 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports :class:" "`WriteTransport` interface and *protocol* is an object instantiated by the " @@ -1869,7 +1883,7 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`WriteTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1267 +#: ../../library/asyncio-eventloop.rst:1279 msgid "" ":class:`SelectorEventLoop` does not support the above methods on Windows. " "Use :class:`ProactorEventLoop` instead for Windows." @@ -1877,20 +1891,20 @@ msgstr "" ":class:`SelectorEventLoop` 在 Windows 上不支援上述方法。對於 Windows 請使用 :" "class:`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1272 +#: ../../library/asyncio-eventloop.rst:1284 msgid "" "The :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell` methods." msgstr ":meth:`loop.subprocess_exec` 和 :meth:`loop.subprocess_shell` 方法。" -#: ../../library/asyncio-eventloop.rst:1277 +#: ../../library/asyncio-eventloop.rst:1289 msgid "Unix signals" msgstr "Unix 訊號" -#: ../../library/asyncio-eventloop.rst:1283 +#: ../../library/asyncio-eventloop.rst:1295 msgid "Set *callback* as the handler for the *signum* signal." msgstr "將 *callback* 設置為 *signum* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1285 +#: ../../library/asyncio-eventloop.rst:1297 msgid "" "The callback will be invoked by *loop*, along with other queued callbacks " "and runnable coroutines of that event loop. Unlike signal handlers " @@ -1901,7 +1915,7 @@ msgstr "" "用 :func:`signal.signal` 註冊的訊號處理程式不同,使用此函式註冊的回呼允許與事" "件迴圈進行互動。" -#: ../../library/asyncio-eventloop.rst:1290 +#: ../../library/asyncio-eventloop.rst:1302 msgid "" "Raise :exc:`ValueError` if the signal number is invalid or uncatchable. " "Raise :exc:`RuntimeError` if there is a problem setting up the handler." @@ -1909,16 +1923,16 @@ msgstr "" "如果訊號號無效或不可捕獲,引發 :exc:`ValueError`。如果設定處理程序有問題,拋" "出 :exc:`RuntimeError`。" -#: ../../library/asyncio-eventloop.rst:1296 +#: ../../library/asyncio-eventloop.rst:1308 msgid "" "Like :func:`signal.signal`, this function must be invoked in the main thread." msgstr "像 :func:`signal.signal` 一樣,此函式必須在主執行緒中叫用。" -#: ../../library/asyncio-eventloop.rst:1301 +#: ../../library/asyncio-eventloop.rst:1313 msgid "Remove the handler for the *sig* signal." msgstr "移除 *sig* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1303 +#: ../../library/asyncio-eventloop.rst:1315 msgid "" "Return ``True`` if the signal handler was removed, or ``False`` if no " "handler was set for the given signal." @@ -1926,19 +1940,19 @@ msgstr "" "如果訊號處理程式被移除,回傳 ``True``;如果給定訊號沒有設置處理程式,回傳 " "``False``。" -#: ../../library/asyncio-eventloop.rst:1310 +#: ../../library/asyncio-eventloop.rst:1322 msgid "The :mod:`signal` module." msgstr ":mod:`signal` 模組。" -#: ../../library/asyncio-eventloop.rst:1314 +#: ../../library/asyncio-eventloop.rst:1326 msgid "Executing code in thread or process pools" msgstr "在執行緒池或行程池中執行程式碼" -#: ../../library/asyncio-eventloop.rst:1318 +#: ../../library/asyncio-eventloop.rst:1330 msgid "Arrange for *func* to be called in the specified executor." msgstr "安排在指定的執行器中呼叫 *func*。" -#: ../../library/asyncio-eventloop.rst:1320 +#: ../../library/asyncio-eventloop.rst:1332 msgid "" "The *executor* argument should be an :class:`concurrent.futures.Executor` " "instance. The default executor is used if *executor* is ``None``. The " @@ -1947,7 +1961,7 @@ msgid "" "and used by :func:`run_in_executor` if needed." msgstr "" -#: ../../library/asyncio-eventloop.rst:1328 +#: ../../library/asyncio-eventloop.rst:1340 msgid "" "import asyncio\n" "import concurrent.futures\n" @@ -1990,7 +2004,7 @@ msgid "" " asyncio.run(main())" msgstr "" -#: ../../library/asyncio-eventloop.rst:1368 +#: ../../library/asyncio-eventloop.rst:1380 msgid "" "Note that the entry point guard (``if __name__ == '__main__'``) is required " "for option 3 due to the peculiarities of :mod:`multiprocessing`, which is " @@ -2002,11 +2016,11 @@ msgstr "" "== '__main__'``\\ )。請參閱\\ :ref:`主模組的安全引入 `。" -#: ../../library/asyncio-eventloop.rst:1373 +#: ../../library/asyncio-eventloop.rst:1385 msgid "This method returns a :class:`asyncio.Future` object." msgstr "此方法回傳 :class:`asyncio.Future` 物件。" -#: ../../library/asyncio-eventloop.rst:1375 +#: ../../library/asyncio-eventloop.rst:1387 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *func*." @@ -2014,7 +2028,7 @@ msgstr "" "使用 :func:`functools.partial` 將來\\ :ref:`關鍵字引數傳遞 `\\ 給 *func*。" -#: ../../library/asyncio-eventloop.rst:1378 +#: ../../library/asyncio-eventloop.rst:1390 msgid "" ":meth:`loop.run_in_executor` no longer configures the ``max_workers`` of the " "thread pool executor it creates, instead leaving it up to the thread pool " @@ -2025,7 +2039,7 @@ msgstr "" "``max_workers``,而是讓執行緒池執行器(\\ :class:`~concurrent.futures." "ThreadPoolExecutor`)設定預設值。" -#: ../../library/asyncio-eventloop.rst:1387 +#: ../../library/asyncio-eventloop.rst:1399 msgid "" "Set *executor* as the default executor used by :meth:`run_in_executor`. " "*executor* must be an instance of :class:`~concurrent.futures." @@ -2034,26 +2048,26 @@ msgstr "" "將 *executor* 設置為 :meth:`run_in_executor` 使用的預設執行器。*executor* 必" "須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1391 +#: ../../library/asyncio-eventloop.rst:1403 msgid "" "*executor* must be an instance of :class:`~concurrent.futures." "ThreadPoolExecutor`." msgstr "" "*executor* 必須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1397 +#: ../../library/asyncio-eventloop.rst:1409 msgid "Error Handling API" msgstr "錯誤處理 API" -#: ../../library/asyncio-eventloop.rst:1399 +#: ../../library/asyncio-eventloop.rst:1411 msgid "Allows customizing how exceptions are handled in the event loop." msgstr "允許自定義事件迴圈中的例外處理方式。" -#: ../../library/asyncio-eventloop.rst:1403 +#: ../../library/asyncio-eventloop.rst:1415 msgid "Set *handler* as the new event loop exception handler." msgstr "將 *handler* 設定為新的事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1405 +#: ../../library/asyncio-eventloop.rst:1417 msgid "" "If *handler* is ``None``, the default exception handler will be set. " "Otherwise, *handler* must be a callable with the signature matching ``(loop, " @@ -2066,7 +2080,7 @@ msgstr "" "圈的,``context`` 是包含例外詳細資訊的 ``dict`` 物件(有關情境的詳細資訊,請" "參閱 :meth:`call_exception_handler` 文件)。" -#: ../../library/asyncio-eventloop.rst:1413 +#: ../../library/asyncio-eventloop.rst:1425 msgid "" "If the handler is called on behalf of a :class:`~asyncio.Task` or :class:" "`~asyncio.Handle`, it is run in the :class:`contextvars.Context` of that " @@ -2075,7 +2089,7 @@ msgstr "" "如果代表 :class:`~asyncio.Task` 或 :class:`~asyncio.Handle` 呼叫處理程式,它" "將在該任務或回呼處理程式的 :class:`contextvars.Context` 中運行。" -#: ../../library/asyncio-eventloop.rst:1419 +#: ../../library/asyncio-eventloop.rst:1431 msgid "" "The handler may be called in the :class:`~contextvars.Context` of the task " "or handle where the exception originated." @@ -2083,18 +2097,18 @@ msgstr "" "處理程式可能在引發例外的任務或處理程式的 :class:`~contextvars.Context` 中被呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1424 +#: ../../library/asyncio-eventloop.rst:1436 msgid "" "Return the current exception handler, or ``None`` if no custom exception " "handler was set." msgstr "" "回傳目前的例外處理程式,如果未設置自定義例外處理程式,則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:1431 +#: ../../library/asyncio-eventloop.rst:1443 msgid "Default exception handler." msgstr "預設例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1433 +#: ../../library/asyncio-eventloop.rst:1445 msgid "" "This is called when an exception occurs and no exception handler is set. " "This can be called by a custom exception handler that wants to defer to the " @@ -2103,17 +2117,17 @@ msgstr "" "當發生例外且未設置例外處理程式時呼叫此函式。自定義例外處理程式可以呼叫此函式" "以轉由預設處理程式處理。" -#: ../../library/asyncio-eventloop.rst:1437 +#: ../../library/asyncio-eventloop.rst:1449 msgid "" "*context* parameter has the same meaning as in :meth:" "`call_exception_handler`." msgstr "*context* 參數與 :meth:`call_exception_handler` 中的意思相同。" -#: ../../library/asyncio-eventloop.rst:1442 +#: ../../library/asyncio-eventloop.rst:1454 msgid "Call the current event loop exception handler." msgstr "呼叫目前事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1444 +#: ../../library/asyncio-eventloop.rst:1456 msgid "" "*context* is a ``dict`` object containing the following keys (new keys may " "be introduced in future Python versions):" @@ -2121,55 +2135,55 @@ msgstr "" "*context* 是一個包含以下鍵的 ``dict`` 物件(未來的 Python 版本中可能會引入新" "的鍵):" -#: ../../library/asyncio-eventloop.rst:1447 +#: ../../library/asyncio-eventloop.rst:1459 msgid "'message': Error message;" msgstr "'message':錯誤訊息;" -#: ../../library/asyncio-eventloop.rst:1448 +#: ../../library/asyncio-eventloop.rst:1460 msgid "'exception' (optional): Exception object;" msgstr "'exception'(可選):例外物件;" -#: ../../library/asyncio-eventloop.rst:1449 +#: ../../library/asyncio-eventloop.rst:1461 msgid "'future' (optional): :class:`asyncio.Future` instance;" msgstr "'future'(可選): :class:`asyncio.Future` 實例;" -#: ../../library/asyncio-eventloop.rst:1450 +#: ../../library/asyncio-eventloop.rst:1462 msgid "'task' (optional): :class:`asyncio.Task` instance;" msgstr "'task'(可選): :class:`asyncio.Task` 實例;" -#: ../../library/asyncio-eventloop.rst:1451 +#: ../../library/asyncio-eventloop.rst:1463 msgid "'handle' (optional): :class:`asyncio.Handle` instance;" msgstr "'handle'(可選): :class:`asyncio.Handle` 實例;" -#: ../../library/asyncio-eventloop.rst:1452 +#: ../../library/asyncio-eventloop.rst:1464 msgid "'protocol' (optional): :ref:`Protocol ` instance;" msgstr "'protocol'(可選): :ref:`Protocol ` 實例;" -#: ../../library/asyncio-eventloop.rst:1453 +#: ../../library/asyncio-eventloop.rst:1465 msgid "'transport' (optional): :ref:`Transport ` instance;" msgstr "'transport'(可選): :ref:`Transport ` 實例;" -#: ../../library/asyncio-eventloop.rst:1454 +#: ../../library/asyncio-eventloop.rst:1466 msgid "'socket' (optional): :class:`socket.socket` instance;" msgstr "'socket'(可選): :class:`socket.socket` 實例;" -#: ../../library/asyncio-eventloop.rst:1455 +#: ../../library/asyncio-eventloop.rst:1467 msgid "'source_traceback' (optional): Traceback of the source;" msgstr "" -#: ../../library/asyncio-eventloop.rst:1456 +#: ../../library/asyncio-eventloop.rst:1468 msgid "'handle_traceback' (optional): Traceback of the handle;" msgstr "" -#: ../../library/asyncio-eventloop.rst:1457 +#: ../../library/asyncio-eventloop.rst:1469 msgid "'asyncgen' (optional): Asynchronous generator that caused" msgstr "'asyncgen'(可選): 非同步產生器引發" -#: ../../library/asyncio-eventloop.rst:1458 +#: ../../library/asyncio-eventloop.rst:1470 msgid "the exception." msgstr "例外。" -#: ../../library/asyncio-eventloop.rst:1462 +#: ../../library/asyncio-eventloop.rst:1474 msgid "" "This method should not be overloaded in subclassed event loops. For custom " "exception handling, use the :meth:`set_exception_handler` method." @@ -2177,15 +2191,15 @@ msgstr "" "此方法不應在子類別事件迴圈中被覆寫。為了自定義例外處理,請使用 :meth:" "`set_exception_handler` 方法。" -#: ../../library/asyncio-eventloop.rst:1467 +#: ../../library/asyncio-eventloop.rst:1479 msgid "Enabling debug mode" msgstr "啟用除錯模式" -#: ../../library/asyncio-eventloop.rst:1471 +#: ../../library/asyncio-eventloop.rst:1483 msgid "Get the debug mode (:class:`bool`) of the event loop." msgstr "取得事件迴圈的除錯模式(\\ :class:`bool`\\ )。" -#: ../../library/asyncio-eventloop.rst:1473 +#: ../../library/asyncio-eventloop.rst:1485 msgid "" "The default value is ``True`` if the environment variable :envvar:" "`PYTHONASYNCIODEBUG` is set to a non-empty string, ``False`` otherwise." @@ -2193,17 +2207,17 @@ msgstr "" "如果環境變數 :envvar:`PYTHONASYNCIODEBUG` 被設定為非空字串,則預設值為 " "``True``,否則為 ``False``。" -#: ../../library/asyncio-eventloop.rst:1479 +#: ../../library/asyncio-eventloop.rst:1491 msgid "Set the debug mode of the event loop." msgstr "設定事件迴圈的除錯模式。" -#: ../../library/asyncio-eventloop.rst:1483 +#: ../../library/asyncio-eventloop.rst:1495 msgid "" "The new :ref:`Python Development Mode ` can now also be used to " "enable the debug mode." msgstr "現在也可以使用新的 :ref:`Python 開發模式 ` 啟用除錯模式。" -#: ../../library/asyncio-eventloop.rst:1488 +#: ../../library/asyncio-eventloop.rst:1500 msgid "" "This attribute can be used to set the minimum execution duration in seconds " "that is considered \"slow\". When debug mode is enabled, \"slow\" callbacks " @@ -2212,19 +2226,19 @@ msgstr "" "此屬性可用於設定被視為\"慢\"的最短執行時間(以秒為單位)。啟用偵錯模式" "後,\"慢\"回呼將被記錄。" -#: ../../library/asyncio-eventloop.rst:1492 +#: ../../library/asyncio-eventloop.rst:1504 msgid "Default value is 100 milliseconds." msgstr "預設值為 100 毫秒" -#: ../../library/asyncio-eventloop.rst:1496 +#: ../../library/asyncio-eventloop.rst:1508 msgid "The :ref:`debug mode of asyncio `." msgstr ":ref:`asyncio 的除錯模式 `。" -#: ../../library/asyncio-eventloop.rst:1500 +#: ../../library/asyncio-eventloop.rst:1512 msgid "Running Subprocesses" msgstr "運行子行程" -#: ../../library/asyncio-eventloop.rst:1502 +#: ../../library/asyncio-eventloop.rst:1514 msgid "" "Methods described in this subsections are low-level. In regular async/await " "code consider using the high-level :func:`asyncio.create_subprocess_shell` " @@ -2234,7 +2248,7 @@ msgstr "" "func:`asyncio.create_subprocess_shell` 和 :func:`asyncio." "create_subprocess_exec` 輔助功能而不是。" -#: ../../library/asyncio-eventloop.rst:1509 +#: ../../library/asyncio-eventloop.rst:1521 msgid "" "On Windows, the default event loop :class:`ProactorEventLoop` supports " "subprocesses, whereas :class:`SelectorEventLoop` does not. See :ref:" @@ -2244,26 +2258,26 @@ msgstr "" "`SelectorEventLoop` 不支援。詳細資訊請參見 :ref:`Windows 上對於子行程的支援 " "`。" -#: ../../library/asyncio-eventloop.rst:1521 +#: ../../library/asyncio-eventloop.rst:1533 msgid "" "Create a subprocess from one or more string arguments specified by *args*." msgstr "從 *args* 指定的一個或多個字串引數建立子行程。" -#: ../../library/asyncio-eventloop.rst:1524 +#: ../../library/asyncio-eventloop.rst:1536 msgid "*args* must be a list of strings represented by:" msgstr "*args* 必須是由以下項表示的字串串列:" -#: ../../library/asyncio-eventloop.rst:1526 +#: ../../library/asyncio-eventloop.rst:1538 msgid ":class:`str`;" msgstr ":class:`str`;" -#: ../../library/asyncio-eventloop.rst:1527 +#: ../../library/asyncio-eventloop.rst:1539 msgid "" "or :class:`bytes`, encoded to the :ref:`filesystem encoding `." msgstr "或 :class:`bytes`,編碼為 :ref:`檔案系統編碼 `。" -#: ../../library/asyncio-eventloop.rst:1530 +#: ../../library/asyncio-eventloop.rst:1542 msgid "" "The first string specifies the program executable, and the remaining strings " "specify the arguments. Together, string arguments form the ``argv`` of the " @@ -2272,7 +2286,7 @@ msgstr "" "第一個字串指定程序可執行檔案,其餘字串指定引數。字串引數一起組成程序的 " "``argv``。" -#: ../../library/asyncio-eventloop.rst:1534 +#: ../../library/asyncio-eventloop.rst:1546 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=False`` and the list of strings passed as the first " @@ -2283,7 +2297,7 @@ msgstr "" "字串串列作為第一個引數傳遞;然而,:class:`~subprocess.Popen` 接受單個字串串列" "引數,*subprocess_exec* 接受多個字串引數。" -#: ../../library/asyncio-eventloop.rst:1540 +#: ../../library/asyncio-eventloop.rst:1552 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`asyncio.SubprocessProtocol` class." @@ -2291,67 +2305,67 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`asyncio.SubprocessProtocol` 子類別的可" "呼叫物件。" -#: ../../library/asyncio-eventloop.rst:1543 +#: ../../library/asyncio-eventloop.rst:1555 msgid "Other parameters:" msgstr "其他參數:" -#: ../../library/asyncio-eventloop.rst:1545 +#: ../../library/asyncio-eventloop.rst:1557 msgid "*stdin* can be any of these:" msgstr "*stdin* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1547 -#: ../../library/asyncio-eventloop.rst:1558 -#: ../../library/asyncio-eventloop.rst:1568 +#: ../../library/asyncio-eventloop.rst:1559 +#: ../../library/asyncio-eventloop.rst:1570 +#: ../../library/asyncio-eventloop.rst:1580 msgid "a file-like object" msgstr "類檔案物件" -#: ../../library/asyncio-eventloop.rst:1548 +#: ../../library/asyncio-eventloop.rst:1560 msgid "" "an existing file descriptor (a positive integer), for example those created " "with :meth:`os.pipe`" msgstr "現有的檔案描述器(正整數),例如用 :meth:`os.pipe` 建立的" -#: ../../library/asyncio-eventloop.rst:1549 -#: ../../library/asyncio-eventloop.rst:1559 -#: ../../library/asyncio-eventloop.rst:1569 +#: ../../library/asyncio-eventloop.rst:1561 +#: ../../library/asyncio-eventloop.rst:1571 +#: ../../library/asyncio-eventloop.rst:1581 msgid "" "the :const:`subprocess.PIPE` constant (default) which will create a new pipe " "and connect it," msgstr ":const:`subprocess.PIPE` 常數(預設),它將建立一個新的管道並連線," -#: ../../library/asyncio-eventloop.rst:1551 -#: ../../library/asyncio-eventloop.rst:1561 -#: ../../library/asyncio-eventloop.rst:1571 +#: ../../library/asyncio-eventloop.rst:1563 +#: ../../library/asyncio-eventloop.rst:1573 +#: ../../library/asyncio-eventloop.rst:1583 msgid "" "the value ``None`` which will make the subprocess inherit the file " "descriptor from this process" msgstr "值 ``None`` 將使子行程從此行程繼承檔案描述器" -#: ../../library/asyncio-eventloop.rst:1553 -#: ../../library/asyncio-eventloop.rst:1563 -#: ../../library/asyncio-eventloop.rst:1573 +#: ../../library/asyncio-eventloop.rst:1565 +#: ../../library/asyncio-eventloop.rst:1575 +#: ../../library/asyncio-eventloop.rst:1585 msgid "" "the :const:`subprocess.DEVNULL` constant which indicates that the special :" "data:`os.devnull` file will be used" msgstr "" ":const:`subprocess.DEVNULL` 常數,表示將使用特殊的 :data:`os.devnull` 檔案" -#: ../../library/asyncio-eventloop.rst:1556 +#: ../../library/asyncio-eventloop.rst:1568 msgid "*stdout* can be any of these:" msgstr "*stdout* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1566 +#: ../../library/asyncio-eventloop.rst:1578 msgid "*stderr* can be any of these:" msgstr "*stderr* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1575 +#: ../../library/asyncio-eventloop.rst:1587 msgid "" "the :const:`subprocess.STDOUT` constant which will connect the standard " "error stream to the process' standard output stream" msgstr "" ":const:`subprocess.STDOUT` 常數,它將標準錯誤串流連線到行程的標準輸出串流" -#: ../../library/asyncio-eventloop.rst:1578 +#: ../../library/asyncio-eventloop.rst:1590 msgid "" "All other keyword arguments are passed to :class:`subprocess.Popen` without " "interpretation, except for *bufsize*, *universal_newlines*, *shell*, *text*, " @@ -2361,7 +2375,7 @@ msgstr "" "*bufsize*、*universal_newlines*、*shell*、*text*、*encoding* 和 *errors* 除" "外,這些不應該指定。" -#: ../../library/asyncio-eventloop.rst:1583 +#: ../../library/asyncio-eventloop.rst:1595 msgid "" "The ``asyncio`` subprocess API does not support decoding the streams as " "text. :func:`bytes.decode` can be used to convert the bytes returned from " @@ -2370,7 +2384,7 @@ msgstr "" "``asyncio`` 子行程 API 不支援將串流解碼為文本。可以使用 :func:`bytes.decode` " "將從串流回傳的位元組轉換為文本。" -#: ../../library/asyncio-eventloop.rst:1587 +#: ../../library/asyncio-eventloop.rst:1599 msgid "" "If a file-like object passed as *stdin*, *stdout* or *stderr* represents a " "pipe, then the other side of this pipe should be registered with :meth:" @@ -2381,13 +2395,13 @@ msgstr "" "端應該使用 :meth:`~loop.connect_write_pipe` 或 :meth:`~loop." "connect_read_pipe` 註冊到事件迴圈中。" -#: ../../library/asyncio-eventloop.rst:1592 +#: ../../library/asyncio-eventloop.rst:1604 msgid "" "See the constructor of the :class:`subprocess.Popen` class for documentation " "on other arguments." msgstr "有關其他引數的文件,請參閱 :class:`subprocess.Popen` 類別的建構函式。" -#: ../../library/asyncio-eventloop.rst:1595 +#: ../../library/asyncio-eventloop.rst:1607 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`asyncio.SubprocessTransport` base class and *protocol* is an " @@ -2397,7 +2411,7 @@ msgstr "" "SubprocessTransport` 基底類別,*protocol* 是由 *protocol_factory* 實例化的物" "件。" -#: ../../library/asyncio-eventloop.rst:1604 +#: ../../library/asyncio-eventloop.rst:1616 msgid "" "Create a subprocess from *cmd*, which can be a :class:`str` or a :class:" "`bytes` string encoded to the :ref:`filesystem encoding ` 的 :class:`bytes` 字串。" -#: ../../library/asyncio-eventloop.rst:1609 +#: ../../library/asyncio-eventloop.rst:1621 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=True``." @@ -2414,7 +2428,7 @@ msgstr "" "這類似於標準函式庫中的 :class:`subprocess.Popen` 類別,使用 ``shell=True`` 呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1612 +#: ../../library/asyncio-eventloop.rst:1624 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`SubprocessProtocol` class." @@ -2422,13 +2436,13 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`SubprocessProtocol` 子類別的可呼叫物" "件。" -#: ../../library/asyncio-eventloop.rst:1615 +#: ../../library/asyncio-eventloop.rst:1627 msgid "" "See :meth:`~loop.subprocess_exec` for more details about the remaining " "arguments." msgstr "有關其餘引數的更多詳細資訊,請參閱 :meth:`~loop.subprocess_exec`。" -#: ../../library/asyncio-eventloop.rst:1618 +#: ../../library/asyncio-eventloop.rst:1630 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`SubprocessTransport` base class and *protocol* is an object " @@ -2438,7 +2452,7 @@ msgstr "" "`SubprocessTransport` 基底類別,而 *protocol* 是由 *protocol_factory* 實例化" "的物件。" -#: ../../library/asyncio-eventloop.rst:1623 +#: ../../library/asyncio-eventloop.rst:1635 msgid "" "It is the application's responsibility to ensure that all whitespace and " "special characters are quoted appropriately to avoid `shell injection " @@ -2451,11 +2465,11 @@ msgstr "" "wikipedia.org/wiki/Shell_injection#Shell_injection>`_\\ 風險。可以使用 :func:" "`shlex.quote` 函式來正確跳脫用於構建 shell 命令的字串中的空白和特殊字元。" -#: ../../library/asyncio-eventloop.rst:1632 +#: ../../library/asyncio-eventloop.rst:1644 msgid "Callback Handles" msgstr "回呼處理" -#: ../../library/asyncio-eventloop.rst:1636 +#: ../../library/asyncio-eventloop.rst:1648 msgid "" "A callback wrapper object returned by :meth:`loop.call_soon`, :meth:`loop." "call_soon_threadsafe`." @@ -2463,46 +2477,46 @@ msgstr "" "由 :meth:`loop.call_soon` 和 :meth:`loop.call_soon_threadsafe` 回傳的回呼包裝" "器。" -#: ../../library/asyncio-eventloop.rst:1641 +#: ../../library/asyncio-eventloop.rst:1653 msgid "" "Return the :class:`contextvars.Context` object associated with the handle." msgstr "回傳與處理相關聯的 :class:`contextvars.Context` 物件。" -#: ../../library/asyncio-eventloop.rst:1648 +#: ../../library/asyncio-eventloop.rst:1660 msgid "" "Cancel the callback. If the callback has already been canceled or executed, " "this method has no effect." msgstr "取消回呼。如果回呼已被取消或執行,此方法將不起作用。" -#: ../../library/asyncio-eventloop.rst:1653 +#: ../../library/asyncio-eventloop.rst:1665 msgid "Return ``True`` if the callback was cancelled." msgstr "如果回呼已被取消,回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1659 +#: ../../library/asyncio-eventloop.rst:1671 msgid "" "A callback wrapper object returned by :meth:`loop.call_later`, and :meth:" "`loop.call_at`." msgstr "由 :meth:`loop.call_later` 和 :meth:`loop.call_at` 回傳的回呼包裝器。" -#: ../../library/asyncio-eventloop.rst:1662 +#: ../../library/asyncio-eventloop.rst:1674 msgid "This class is a subclass of :class:`Handle`." msgstr "這個類別是 :class:`Handle` 的子類別。" -#: ../../library/asyncio-eventloop.rst:1666 +#: ../../library/asyncio-eventloop.rst:1678 msgid "Return a scheduled callback time as :class:`float` seconds." msgstr "回傳預定的回呼時間,以 :class:`float` 秒為單位。" -#: ../../library/asyncio-eventloop.rst:1668 +#: ../../library/asyncio-eventloop.rst:1680 msgid "" "The time is an absolute timestamp, using the same time reference as :meth:" "`loop.time`." msgstr "時間是一個絕對的時間戳,使用與 :meth:`loop.time` 相同的時間參照。" -#: ../../library/asyncio-eventloop.rst:1675 +#: ../../library/asyncio-eventloop.rst:1687 msgid "Server Objects" msgstr "Server 物件" -#: ../../library/asyncio-eventloop.rst:1677 +#: ../../library/asyncio-eventloop.rst:1689 msgid "" "Server objects are created by :meth:`loop.create_server`, :meth:`loop." "create_unix_server`, :func:`start_server`, and :func:`start_unix_server` " @@ -2512,11 +2526,11 @@ msgstr "" "create_unix_server`、:func:`start_server` 和 :func:`start_unix_server` 函式所" "建立。" -#: ../../library/asyncio-eventloop.rst:1681 +#: ../../library/asyncio-eventloop.rst:1693 msgid "Do not instantiate the :class:`Server` class directly." msgstr "請勿直接實例化 :class:`Server` 類別。" -#: ../../library/asyncio-eventloop.rst:1685 +#: ../../library/asyncio-eventloop.rst:1697 msgid "" "*Server* objects are asynchronous context managers. When used in an ``async " "with`` statement, it's guaranteed that the Server object is closed and not " @@ -2525,7 +2539,7 @@ msgstr "" "*Server* 物件是非同步情境管理器。當在 ``async with`` 陳述中使用時,可以保證在" "完成 ``async with`` 陳述時,Server 物件將會關閉並停止接受新的連線: ::" -#: ../../library/asyncio-eventloop.rst:1690 +#: ../../library/asyncio-eventloop.rst:1702 msgid "" "srv = await loop.create_server(...)\n" "\n" @@ -2541,30 +2555,30 @@ msgstr "" "\n" "# 此時 srv 已關閉,不再接受新的連線。" -#: ../../library/asyncio-eventloop.rst:1698 +#: ../../library/asyncio-eventloop.rst:1710 msgid "Server object is an asynchronous context manager since Python 3.7." msgstr "自 Python 3.7 起,Server 物件是非同步情境管理器。" -#: ../../library/asyncio-eventloop.rst:1701 +#: ../../library/asyncio-eventloop.rst:1713 msgid "" "This class was exposed publicly as ``asyncio.Server`` in Python 3.9.11, " "3.10.3 and 3.11." msgstr "" "此類別在 Python 3.9.11、3.10.3 和 3.11 中以 ``asyncio.Server`` 的形式被公開。" -#: ../../library/asyncio-eventloop.rst:1706 +#: ../../library/asyncio-eventloop.rst:1718 msgid "" "Stop serving: close listening sockets and set the :attr:`sockets` attribute " "to ``None``." msgstr "停止服務:關閉監聽的 sockets 並將 :attr:`sockets` 屬性設為 ``None``。" -#: ../../library/asyncio-eventloop.rst:1709 +#: ../../library/asyncio-eventloop.rst:1721 msgid "" "The sockets that represent existing incoming client connections are left " "open." msgstr "代表現有傳入用戶端連線的 sockets 仍然保持開啟。" -#: ../../library/asyncio-eventloop.rst:1712 +#: ../../library/asyncio-eventloop.rst:1724 msgid "" "The server is closed asynchronously; use the :meth:`wait_closed` coroutine " "to wait until the server is closed (and no more connections are active)." @@ -2572,53 +2586,53 @@ msgstr "" "伺服器以非同步方式關閉;使用 :meth:`wait_close` 協程等待伺服器關閉(不再有活" "躍連線)。" -#: ../../library/asyncio-eventloop.rst:1718 +#: ../../library/asyncio-eventloop.rst:1730 msgid "Close all existing incoming client connections." msgstr "關閉所有現有的傳入用戶端連線。" -#: ../../library/asyncio-eventloop.rst:1720 +#: ../../library/asyncio-eventloop.rst:1732 msgid "" "Calls :meth:`~asyncio.BaseTransport.close` on all associated transports." msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" -#: ../../library/asyncio-eventloop.rst:1723 +#: ../../library/asyncio-eventloop.rst:1735 msgid "" ":meth:`close` should be called before :meth:`close_clients` when closing the " "server to avoid races with new clients connecting." msgstr "" -#: ../../library/asyncio-eventloop.rst:1730 +#: ../../library/asyncio-eventloop.rst:1742 msgid "" "Close all existing incoming client connections immediately, without waiting " "for pending operations to complete." msgstr "立即關閉所有現有的傳入用戶端連線,而不等待待定操作完成。" -#: ../../library/asyncio-eventloop.rst:1733 +#: ../../library/asyncio-eventloop.rst:1745 msgid "" "Calls :meth:`~asyncio.WriteTransport.abort` on all associated transports." msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" -#: ../../library/asyncio-eventloop.rst:1736 +#: ../../library/asyncio-eventloop.rst:1748 msgid "" ":meth:`close` should be called before :meth:`abort_clients` when closing the " "server to avoid races with new clients connecting." msgstr "" -#: ../../library/asyncio-eventloop.rst:1743 +#: ../../library/asyncio-eventloop.rst:1755 msgid "Return the event loop associated with the server object." msgstr "回傳與伺服器物件關聯的事件迴圈。" -#: ../../library/asyncio-eventloop.rst:1750 +#: ../../library/asyncio-eventloop.rst:1762 msgid "Start accepting connections." msgstr "開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1752 +#: ../../library/asyncio-eventloop.rst:1764 msgid "" "This method is idempotent, so it can be called when the server is already " "serving." msgstr "此方法是幂等的,因此可以在伺服器已經運行時呼叫。" -#: ../../library/asyncio-eventloop.rst:1755 +#: ../../library/asyncio-eventloop.rst:1767 msgid "" "The *start_serving* keyword-only parameter to :meth:`loop.create_server` " "and :meth:`asyncio.start_server` allows creating a Server object that is not " @@ -2631,14 +2645,14 @@ msgstr "" "種情況下,可以使用 ``Server.start_serving()`` 或 :meth:`Server." "serve_forever` 來使 Server 開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1767 +#: ../../library/asyncio-eventloop.rst:1779 msgid "" "Start accepting connections until the coroutine is cancelled. Cancellation " "of ``serve_forever`` task causes the server to be closed." msgstr "" "開始接受連線,直到協程被取消。取消 ``serve_forever`` 任務會導致伺服器關閉。" -#: ../../library/asyncio-eventloop.rst:1771 +#: ../../library/asyncio-eventloop.rst:1783 msgid "" "This method can be called if the server is already accepting connections. " "Only one ``serve_forever`` task can exist per one *Server* object." @@ -2646,7 +2660,7 @@ msgstr "" "如果伺服器已經接受連線,則可以呼叫此方法。每個 *Server* 物件只能存在一個 " "``serve_forever`` 任務。" -#: ../../library/asyncio-eventloop.rst:1777 +#: ../../library/asyncio-eventloop.rst:1789 msgid "" "async def client_connected(reader, writer):\n" " # Communicate with the client with\n" @@ -2672,24 +2686,24 @@ msgstr "" "\n" "asyncio.run(main('127.0.0.1', 0))" -#: ../../library/asyncio-eventloop.rst:1793 +#: ../../library/asyncio-eventloop.rst:1805 msgid "Return ``True`` if the server is accepting new connections." msgstr "如果伺服器正在接受新連線,則回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1800 +#: ../../library/asyncio-eventloop.rst:1812 msgid "" "Wait until the :meth:`close` method completes and all active connections " "have finished." msgstr "等待 :meth:`close` 方法完成且所有活動連線都已結束。" -#: ../../library/asyncio-eventloop.rst:1805 +#: ../../library/asyncio-eventloop.rst:1817 msgid "" "List of socket-like objects, ``asyncio.trsock.TransportSocket``, which the " "server is listening on." msgstr "" "伺服器正在監聽的類似 socket 的物件串列,``asyncio.trsock.TransportSocket``。" -#: ../../library/asyncio-eventloop.rst:1808 +#: ../../library/asyncio-eventloop.rst:1820 msgid "" "Prior to Python 3.7 ``Server.sockets`` used to return an internal list of " "server sockets directly. In 3.7 a copy of that list is returned." @@ -2697,11 +2711,11 @@ msgstr "" "在 Python 3.7 之前,``Server.sockets`` 曾經直接回傳內部伺服器 sockets 的串" "列。在 3.7 中回傳了該串列的副本。" -#: ../../library/asyncio-eventloop.rst:1818 +#: ../../library/asyncio-eventloop.rst:1830 msgid "Event Loop Implementations" msgstr "事件迴圈實作" -#: ../../library/asyncio-eventloop.rst:1820 +#: ../../library/asyncio-eventloop.rst:1832 msgid "" "asyncio ships with two different event loop implementations: :class:" "`SelectorEventLoop` and :class:`ProactorEventLoop`." @@ -2709,17 +2723,17 @@ msgstr "" "asyncio 內附兩個不同的事件迴圈實作::class:`SelectorEventLoop` 和 :class:" "`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1823 +#: ../../library/asyncio-eventloop.rst:1835 msgid "By default asyncio is configured to use :class:`EventLoop`." msgstr "預設情況下,asyncio 被配置為要使用 :class:`EventLoop`。" -#: ../../library/asyncio-eventloop.rst:1828 +#: ../../library/asyncio-eventloop.rst:1840 msgid "" "A subclass of :class:`AbstractEventLoop` based on the :mod:`selectors` " "module." msgstr "基於 :mod:`selectors` 模組的一個 :class:`AbstractEventLoop` 子類別。" -#: ../../library/asyncio-eventloop.rst:1831 +#: ../../library/asyncio-eventloop.rst:1843 msgid "" "Uses the most efficient *selector* available for the given platform. It is " "also possible to manually configure the exact selector implementation to be " @@ -2728,7 +2742,7 @@ msgstr "" "使用特定平台上最有效的 *selector*。也可以手動配置要使用的確切 selector 實" "作: ::" -#: ../../library/asyncio-eventloop.rst:1835 +#: ../../library/asyncio-eventloop.rst:1847 msgid "" "import asyncio\n" "import selectors\n" @@ -2750,7 +2764,7 @@ msgstr "" "\n" "asyncio.set_event_loop_policy(MyPolicy())" -#: ../../library/asyncio-eventloop.rst:1851 +#: ../../library/asyncio-eventloop.rst:1863 msgid "" "A subclass of :class:`AbstractEventLoop` for Windows that uses \"I/O " "Completion Ports\" (IOCP)." @@ -2758,7 +2772,7 @@ msgstr "" "用於 Windows 的 :class:`AbstractEventLoop` 子類別,使用「I/O 完成埠 (IOCP, I/" "O Completion Ports)」。" -#: ../../library/asyncio-eventloop.rst:1857 +#: ../../library/asyncio-eventloop.rst:1869 msgid "" "`MSDN documentation on I/O Completion Ports `_." @@ -2766,13 +2780,13 @@ msgstr "" "`I/O 完成埠的 MSDN 文件 `_。" -#: ../../library/asyncio-eventloop.rst:1862 +#: ../../library/asyncio-eventloop.rst:1874 msgid "" "An alias to the most efficient available subclass of :class:" "`AbstractEventLoop` for the given platform." msgstr "" -#: ../../library/asyncio-eventloop.rst:1865 +#: ../../library/asyncio-eventloop.rst:1877 msgid "" "It is an alias to :class:`SelectorEventLoop` on Unix and :class:" "`ProactorEventLoop` on Windows." @@ -2780,11 +2794,11 @@ msgstr "" "在 Unix 上是 :class:`SelectorEventLoop` 的別名,在 Windows 上是 :class:" "`ProactorEventLoop` 的別名。" -#: ../../library/asyncio-eventloop.rst:1871 +#: ../../library/asyncio-eventloop.rst:1883 msgid "Abstract base class for asyncio-compliant event loops." msgstr "為符合 asyncio 標準的事件迴圈的抽象基礎類別。" -#: ../../library/asyncio-eventloop.rst:1873 +#: ../../library/asyncio-eventloop.rst:1885 msgid "" "The :ref:`asyncio-event-loop-methods` section lists all methods that an " "alternative implementation of ``AbstractEventLoop`` should have defined." @@ -2792,11 +2806,11 @@ msgstr "" ":ref:`asyncio-event-loop-methods` 部分列出了替代 ``AbstractEventLoop`` 實作應" "該定義的所有方法。" -#: ../../library/asyncio-eventloop.rst:1879 +#: ../../library/asyncio-eventloop.rst:1891 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-eventloop.rst:1881 +#: ../../library/asyncio-eventloop.rst:1893 msgid "" "Note that all examples in this section **purposefully** show how to use the " "low-level event loop APIs, such as :meth:`loop.run_forever` and :meth:`loop." @@ -2807,11 +2821,11 @@ msgstr "" "`loop.run_forever` 和 :meth:`loop.call_soon`。現代 asyncio 應用程式很少需要這" "種方式撰寫;請考慮使用高階的函式,如 :func:`asyncio.run`。" -#: ../../library/asyncio-eventloop.rst:1891 +#: ../../library/asyncio-eventloop.rst:1903 msgid "Hello World with call_soon()" msgstr "使用 call_soon() 的 Hello World 範例" -#: ../../library/asyncio-eventloop.rst:1893 +#: ../../library/asyncio-eventloop.rst:1905 msgid "" "An example using the :meth:`loop.call_soon` method to schedule a callback. " "The callback displays ``\"Hello World\"`` and then stops the event loop::" @@ -2819,7 +2833,7 @@ msgstr "" "使用 :meth:`loop.call_soon` 方法排程回呼的範例。回呼會顯示 ``\"Hello " "World\"``,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1897 +#: ../../library/asyncio-eventloop.rst:1909 msgid "" "import asyncio\n" "\n" @@ -2857,18 +2871,18 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1917 +#: ../../library/asyncio-eventloop.rst:1929 msgid "" "A similar :ref:`Hello World ` example created with a coroutine " "and the :func:`run` function." msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`Hello World ` 範例。" -#: ../../library/asyncio-eventloop.rst:1924 +#: ../../library/asyncio-eventloop.rst:1936 msgid "Display the current date with call_later()" msgstr "使用 call_later() 顯示目前日期" -#: ../../library/asyncio-eventloop.rst:1926 +#: ../../library/asyncio-eventloop.rst:1938 msgid "" "An example of a callback displaying the current date every second. The " "callback uses the :meth:`loop.call_later` method to reschedule itself after " @@ -2877,7 +2891,7 @@ msgstr "" "一個回呼的範例,每秒顯示目前日期。回呼使用 :meth:`loop.call_later` 方法在 5 " "秒後重新排程自己,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1930 +#: ../../library/asyncio-eventloop.rst:1942 msgid "" "import asyncio\n" "import datetime\n" @@ -2923,7 +2937,7 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1954 +#: ../../library/asyncio-eventloop.rst:1966 msgid "" "A similar :ref:`current date ` example created with a " "coroutine and the :func:`run` function." @@ -2931,11 +2945,11 @@ msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`current date " "` 範例。" -#: ../../library/asyncio-eventloop.rst:1961 +#: ../../library/asyncio-eventloop.rst:1973 msgid "Watch a file descriptor for read events" msgstr "監聽檔案描述器以進行讀取事件" -#: ../../library/asyncio-eventloop.rst:1963 +#: ../../library/asyncio-eventloop.rst:1975 msgid "" "Wait until a file descriptor received some data using the :meth:`loop." "add_reader` method and then close the event loop::" @@ -2943,7 +2957,7 @@ msgstr "" "使用 :meth:`loop.add_reader` 方法等待檔案描述器接收到某些資料,然後關閉事件迴" "圈: ::" -#: ../../library/asyncio-eventloop.rst:1966 +#: ../../library/asyncio-eventloop.rst:1978 msgid "" "import asyncio\n" "from socket import socketpair\n" @@ -3011,7 +3025,7 @@ msgstr "" " wsock.close()\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:2001 +#: ../../library/asyncio-eventloop.rst:2013 msgid "" "A similar :ref:`example ` using " "transports, protocols, and the :meth:`loop.create_connection` method." @@ -3019,7 +3033,7 @@ msgstr "" "使用傳輸、協定和 :meth:`loop.create_connection` 方法的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:2005 +#: ../../library/asyncio-eventloop.rst:2017 msgid "" "Another similar :ref:`example ` " "using the high-level :func:`asyncio.open_connection` function and streams." @@ -3027,15 +3041,15 @@ msgstr "" "另一個使用高階 :func:`asyncio.open_connection` 函式和串流的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:2013 +#: ../../library/asyncio-eventloop.rst:2025 msgid "Set signal handlers for SIGINT and SIGTERM" msgstr "設定 SIGINT 和 SIGTERM 的訊號處理程式" -#: ../../library/asyncio-eventloop.rst:2015 +#: ../../library/asyncio-eventloop.rst:2027 msgid "(This ``signals`` example only works on Unix.)" msgstr "(此 ``signals`` 範例僅在 Unix 上運作。)" -#: ../../library/asyncio-eventloop.rst:2017 +#: ../../library/asyncio-eventloop.rst:2029 msgid "" "Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal." "SIGTERM` using the :meth:`loop.add_signal_handler` method::" @@ -3043,7 +3057,7 @@ msgstr "" "使用 :meth:`loop.add_signal_handler` 方法註冊訊號 :py:data:`SIGINT` 和 :py:" "data:`SIGTERM` 的處理程式: ::" -#: ../../library/asyncio-eventloop.rst:2020 +#: ../../library/asyncio-eventloop.rst:2032 msgid "" "import asyncio\n" "import functools\n" diff --git a/library/dbm.po b/library/dbm.po index 70cf899c11..9bfe5f9505 100644 --- a/library/dbm.po +++ b/library/dbm.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-12 00:13+0000\n" +"POT-Creation-Date: 2025-08-20 00:15+0000\n" "PO-Revision-Date: 2018-05-23 14:42+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -82,7 +82,7 @@ msgid "" "``'dbm.gnu'``" msgstr "" -#: ../../library/dbm.rst:41 ../../library/dbm.rst:250 ../../library/dbm.rst:448 +#: ../../library/dbm.rst:41 ../../library/dbm.rst:270 ../../library/dbm.rst:471 msgid "*filename* accepts a :term:`path-like object`." msgstr "" @@ -102,7 +102,7 @@ msgid "" "imported is used." msgstr "" -#: ../../library/dbm.rst:68 ../../library/dbm.rst:222 +#: ../../library/dbm.rst:68 ../../library/dbm.rst:242 msgid "The database file to open." msgstr "要打開的資料庫檔案" @@ -113,7 +113,7 @@ msgid "" "the first submodule listed above that can be imported is used." msgstr "" -#: ../../library/dbm.rst:75 ../../library/dbm.rst:178 ../../library/dbm.rst:353 +#: ../../library/dbm.rst:75 ../../library/dbm.rst:182 ../../library/dbm.rst:374 msgid "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n|" @@ -121,28 +121,28 @@ msgstr "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n|" -#: ../../library/dbm.rst:76 ../../library/dbm.rst:180 ../../library/dbm.rst:227 -#: ../../library/dbm.rst:354 +#: ../../library/dbm.rst:76 ../../library/dbm.rst:184 ../../library/dbm.rst:247 +#: ../../library/dbm.rst:375 msgid "``'r'`` (default): |flag_r|" msgstr "``'r'`` (default): |flag_r|" -#: ../../library/dbm.rst:77 ../../library/dbm.rst:181 ../../library/dbm.rst:228 -#: ../../library/dbm.rst:355 ../../library/dbm.rst:429 +#: ../../library/dbm.rst:77 ../../library/dbm.rst:185 ../../library/dbm.rst:248 +#: ../../library/dbm.rst:376 ../../library/dbm.rst:452 msgid "``'w'``: |flag_w|" msgstr "``'w'``: |flag_w|" -#: ../../library/dbm.rst:78 ../../library/dbm.rst:182 ../../library/dbm.rst:229 -#: ../../library/dbm.rst:356 +#: ../../library/dbm.rst:78 ../../library/dbm.rst:186 ../../library/dbm.rst:249 +#: ../../library/dbm.rst:377 msgid "``'c'``: |flag_c|" msgstr "``'c'``: |flag_c|" -#: ../../library/dbm.rst:79 ../../library/dbm.rst:183 ../../library/dbm.rst:230 -#: ../../library/dbm.rst:357 ../../library/dbm.rst:431 +#: ../../library/dbm.rst:79 ../../library/dbm.rst:187 ../../library/dbm.rst:250 +#: ../../library/dbm.rst:378 ../../library/dbm.rst:454 msgid "``'n'``: |flag_n|" msgstr "``'n'``: |flag_n|" -#: ../../library/dbm.rst:81 ../../library/dbm.rst:244 ../../library/dbm.rst:359 -#: ../../library/dbm.rst:433 +#: ../../library/dbm.rst:81 ../../library/dbm.rst:264 ../../library/dbm.rst:380 +#: ../../library/dbm.rst:456 msgid "|mode_param_doc|" msgstr "|mode_param_doc|" @@ -152,51 +152,56 @@ msgstr "*file* 接受一個\\ :term:`類路徑物件 `。" #: ../../library/dbm.rst:87 msgid "" -"The object returned by :func:`~dbm.open` supports the same basic " -"functionality as a :class:`dict`; keys and their corresponding values can be " -"stored, retrieved, and deleted, and the :keyword:`in` operator and the :meth:" -"`!keys` method are available, as well as :meth:`!get` and :meth:`!" -"setdefault` methods." +"The object returned by :func:`~dbm.open` supports the basic functionality of " +"mutable :term:`mappings `; keys and their corresponding values can " +"be stored, retrieved, and deleted, and iteration, the :keyword:`in` operator " +"and methods :meth:`!keys`, :meth:`!get`, :meth:`!setdefault` and :meth:`!" +"clear` are available. The :meth:`!keys` method returns a list instead of a " +"view object. The :meth:`!setdefault` method requires two arguments." msgstr "" -#: ../../library/dbm.rst:92 +#: ../../library/dbm.rst:95 msgid "" "Key and values are always stored as :class:`bytes`. This means that when " "strings are used they are implicitly converted to the default encoding " "before being stored." msgstr "" -#: ../../library/dbm.rst:96 +#: ../../library/dbm.rst:99 msgid "" "These objects also support being used in a :keyword:`with` statement, which " "will automatically close them when done." msgstr "" -#: ../../library/dbm.rst:99 +#: ../../library/dbm.rst:102 msgid "" ":meth:`!get` and :meth:`!setdefault` methods are now available for all :mod:" "`dbm` backends." msgstr "" -#: ../../library/dbm.rst:103 +#: ../../library/dbm.rst:106 msgid "" "Added native support for the context management protocol to the objects " "returned by :func:`~dbm.open`." msgstr "" -#: ../../library/dbm.rst:107 +#: ../../library/dbm.rst:110 msgid "" "Deleting a key from a read-only database raises a database module specific " "exception instead of :exc:`KeyError`." msgstr "" -#: ../../library/dbm.rst:111 +#: ../../library/dbm.rst:114 +msgid ":meth:`!clear` methods are now available for all :mod:`dbm` backends." +msgstr "" + +#: ../../library/dbm.rst:118 msgid "" "The following example records some hostnames and a corresponding title, and " "then prints out the contents of the database::" msgstr "" -#: ../../library/dbm.rst:114 +#: ../../library/dbm.rst:121 msgid "" "import dbm\n" "\n" @@ -223,27 +228,27 @@ msgid "" "# db is automatically closed when leaving the with statement." msgstr "" -#: ../../library/dbm.rst:141 +#: ../../library/dbm.rst:148 msgid "Module :mod:`shelve`" msgstr ":mod:`shelve` 模組" -#: ../../library/dbm.rst:142 +#: ../../library/dbm.rst:149 msgid "Persistence module which stores non-string data." msgstr "" -#: ../../library/dbm.rst:145 +#: ../../library/dbm.rst:152 msgid "The individual submodules are described in the following sections." msgstr "" -#: ../../library/dbm.rst:148 +#: ../../library/dbm.rst:155 msgid ":mod:`dbm.sqlite3` --- SQLite backend for dbm" msgstr ":mod:`dbm.sqlite3` --- dbm 的 SQLite 後端" -#: ../../library/dbm.rst:156 +#: ../../library/dbm.rst:163 msgid "**Source code:** :source:`Lib/dbm/sqlite3.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/sqlite3.py`" -#: ../../library/dbm.rst:160 +#: ../../library/dbm.rst:167 msgid "" "This module uses the standard library :mod:`sqlite3` module to provide an " "SQLite backend for the :mod:`dbm` module. The files created by :mod:`dbm." @@ -263,39 +268,54 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/dbm.rst:169 -msgid "" -"Open an SQLite database. The returned object behaves like a :term:`mapping`, " -"implements a :meth:`!close` method, and supports a \"closing\" context " -"manager via the :keyword:`with` keyword." -msgstr "" +#: ../../library/dbm.rst:176 +#, fuzzy +msgid "Open an SQLite database." +msgstr "關閉資料庫。" -#: ../../library/dbm.rst:174 +#: ../../library/dbm.rst:178 msgid "The path to the database to be opened." msgstr "要打開的資料庫路徑" -#: ../../library/dbm.rst:185 +#: ../../library/dbm.rst:189 msgid "" "The Unix file access mode of the file (default: octal ``0o666``), used only " "when the database has to be created." msgstr "" -#: ../../library/dbm.rst:191 +#: ../../library/dbm.rst:193 +msgid "" +"The returned database object behaves similar to a mutable :term:`mapping`, " +"but the :meth:`!keys` method returns a list, and the :meth:`!setdefault` " +"method requires two arguments. It also supports a \"closing\" context " +"manager via the :keyword:`with` keyword." +msgstr "" + +#: ../../library/dbm.rst:198 ../../library/dbm.rst:399 +msgid "The following method is also provided:" +msgstr "" + +#: ../../library/dbm.rst:202 +#, fuzzy +msgid "Close the SQLite database." +msgstr "關閉資料庫。" + +#: ../../library/dbm.rst:206 msgid ":mod:`dbm.gnu` --- GNU database manager" msgstr ":mod:`dbm.gnu` --- GNU 資料庫管理器" -#: ../../library/dbm.rst:197 +#: ../../library/dbm.rst:212 msgid "**Source code:** :source:`Lib/dbm/gnu.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/gnu.py`" -#: ../../library/dbm.rst:201 +#: ../../library/dbm.rst:216 msgid "" "The :mod:`dbm.gnu` module provides an interface to the :abbr:`GDBM (GNU " "dbm)` library, similar to the :mod:`dbm.ndbm` module, but with additional " "functionality like crash tolerance." msgstr "" -#: ../../library/dbm.rst:207 ../../library/dbm.rst:321 +#: ../../library/dbm.rst:222 ../../library/dbm.rst:342 msgid "" "The file formats created by :mod:`dbm.gnu` and :mod:`dbm.ndbm` are " "incompatible and can not be used interchangeably." @@ -309,18 +329,24 @@ msgstr "" "此模組在\\ :ref:`行動平台 `\\ 或\\ :ref:`WebAssembly 平" "台 `\\ 上不支援。" -#: ../../library/dbm.rst:214 +#: ../../library/dbm.rst:229 msgid "" "Raised on :mod:`dbm.gnu`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" -#: ../../library/dbm.rst:220 +#: ../../library/dbm.rst:235 +msgid "" +"A string of characters the *flag* parameter of :meth:`~dbm.gnu.open` " +"supports." +msgstr "" + +#: ../../library/dbm.rst:240 msgid "Open a GDBM database and return a :class:`!gdbm` object." msgstr "" -#: ../../library/dbm.rst:226 +#: ../../library/dbm.rst:246 msgid "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n| The following additional characters may be appended to " @@ -332,29 +358,29 @@ msgid "" "flag characters." msgstr "" -#: ../../library/dbm.rst:232 +#: ../../library/dbm.rst:252 msgid "" "The following additional characters may be appended to control how the " "database is opened:" msgstr "" -#: ../../library/dbm.rst:235 +#: ../../library/dbm.rst:255 msgid "" "``'f'``: Open the database in fast mode. Writes to the database will not be " "synchronized." msgstr "" -#: ../../library/dbm.rst:237 +#: ../../library/dbm.rst:257 msgid "" "``'s'``: Synchronized mode. Changes to the database will be written " "immediately to the file." msgstr "" -#: ../../library/dbm.rst:239 +#: ../../library/dbm.rst:259 msgid "``'u'``: Do not lock database." msgstr "``'u'``: 不要鎖住資料庫。" -#: ../../library/dbm.rst:241 +#: ../../library/dbm.rst:261 msgid "" "Not all flags are valid for all versions of GDBM. See the :data:`open_flags` " "member for a list of supported flag characters." @@ -364,24 +390,36 @@ msgstr "" msgid "Raises" msgstr "引發" -#: ../../library/dbm.rst:247 +#: ../../library/dbm.rst:267 msgid "If an invalid *flag* argument is passed." msgstr "如果一個無效的 *flag* 引數被傳入。" -#: ../../library/dbm.rst:255 +#: ../../library/dbm.rst:273 msgid "" -"A string of characters the *flag* parameter of :meth:`~dbm.gnu.open` " -"supports." +":class:`!gdbm` objects behave similar to mutable :term:`mappings `, " +"but methods :meth:`!items`, :meth:`!values`, :meth:`!pop`, :meth:`!popitem`, " +"and :meth:`!update` are not supported, the :meth:`!keys` method returns a " +"list, and the :meth:`!setdefault` method requires two arguments. It also " +"supports a \"closing\" context manager via the :keyword:`with` keyword." msgstr "" -#: ../../library/dbm.rst:257 -msgid "" -":class:`!gdbm` objects behave similar to :term:`mappings `, but :" -"meth:`!items` and :meth:`!values` methods are not supported. The following " -"methods are also provided:" +#: ../../library/dbm.rst:280 ../../library/dbm.rst:393 +msgid "Added the :meth:`!get` and :meth:`!setdefault` methods." +msgstr "" + +#: ../../library/dbm.rst:283 ../../library/dbm.rst:396 +msgid "Added the :meth:`!clear` method." msgstr "" -#: ../../library/dbm.rst:263 +#: ../../library/dbm.rst:286 ../../library/dbm.rst:479 +msgid "The following methods are also provided:" +msgstr "" + +#: ../../library/dbm.rst:290 +msgid "Close the GDBM database." +msgstr "關閉 GDBM 資料庫。" + +#: ../../library/dbm.rst:294 msgid "" "It's possible to loop over every key in the database using this method and " "the :meth:`nextkey` method. The traversal is ordered by GDBM's internal " @@ -389,14 +427,14 @@ msgid "" "starting key." msgstr "" -#: ../../library/dbm.rst:270 +#: ../../library/dbm.rst:301 msgid "" "Returns the key that follows *key* in the traversal. The following code " "prints every key in the database ``db``, without having to create a list in " "memory that contains them all::" msgstr "" -#: ../../library/dbm.rst:274 +#: ../../library/dbm.rst:305 msgid "" "k = db.firstkey()\n" "while k is not None:\n" @@ -408,7 +446,7 @@ msgstr "" " print(k)\n" " k = db.nextkey(k)" -#: ../../library/dbm.rst:281 +#: ../../library/dbm.rst:312 msgid "" "If you have carried out a lot of deletions and would like to shrink the " "space used by the GDBM file, this routine will reorganize the database. :" @@ -417,36 +455,28 @@ msgid "" "reused as new (key, value) pairs are added." msgstr "" -#: ../../library/dbm.rst:289 +#: ../../library/dbm.rst:320 msgid "" "When the database has been opened in fast mode, this method forces any " "unwritten data to be written to the disk." msgstr "" -#: ../../library/dbm.rst:294 -msgid "Close the GDBM database." -msgstr "關閉 GDBM 資料庫。" - -#: ../../library/dbm.rst:298 -msgid "Remove all items from the GDBM database." -msgstr "移除 GDBM 資料庫中所有項目。" - -#: ../../library/dbm.rst:304 +#: ../../library/dbm.rst:325 msgid ":mod:`dbm.ndbm` --- New Database Manager" msgstr ":mod:`dbm.ndbm` --- 新資料庫管理器" -#: ../../library/dbm.rst:310 +#: ../../library/dbm.rst:331 msgid "**Source code:** :source:`Lib/dbm/ndbm.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/ndbm.py`" -#: ../../library/dbm.rst:314 +#: ../../library/dbm.rst:335 msgid "" "The :mod:`dbm.ndbm` module provides an interface to the :abbr:`NDBM (New " "Database Manager)` library. This module can be used with the \"classic\" " "NDBM interface or the :abbr:`GDBM (GNU dbm)` compatibility interface." msgstr "" -#: ../../library/dbm.rst:326 +#: ../../library/dbm.rst:347 msgid "" "The NDBM library shipped as part of macOS has an undocumented limitation on " "the size of values, which can result in corrupted database files when " @@ -454,55 +484,53 @@ msgid "" "result in a hard crash (segmentation fault)." msgstr "" -#: ../../library/dbm.rst:335 +#: ../../library/dbm.rst:356 msgid "" "Raised on :mod:`dbm.ndbm`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" -#: ../../library/dbm.rst:341 +#: ../../library/dbm.rst:362 msgid "Name of the NDBM implementation library used." msgstr "" -#: ../../library/dbm.rst:346 +#: ../../library/dbm.rst:367 msgid "Open an NDBM database and return an :class:`!ndbm` object." msgstr "" -#: ../../library/dbm.rst:348 +#: ../../library/dbm.rst:369 msgid "" "The basename of the database file (without the :file:`.dir` or :file:`.pag` " "extensions)." msgstr "" -#: ../../library/dbm.rst:362 -msgid "" -":class:`!ndbm` objects behave similar to :term:`mappings `, but :" -"meth:`!items` and :meth:`!values` methods are not supported. The following " -"methods are also provided:" +#: ../../library/dbm.rst:383 +msgid "Accepts :term:`path-like object` for filename." msgstr "" -#: ../../library/dbm.rst:366 -msgid "Accepts :term:`path-like object` for filename." +#: ../../library/dbm.rst:386 +msgid "" +":class:`!ndbm` objects behave similar to mutable :term:`mappings `, " +"but methods :meth:`!items`, :meth:`!values`, :meth:`!pop`, :meth:`!popitem`, " +"and :meth:`!update` are not supported, the :meth:`!keys` method returns a " +"list, and the :meth:`!setdefault` method requires two arguments. It also " +"supports a \"closing\" context manager via the :keyword:`with` keyword." msgstr "" -#: ../../library/dbm.rst:371 +#: ../../library/dbm.rst:403 msgid "Close the NDBM database." msgstr "關閉 NDBM 資料庫。" -#: ../../library/dbm.rst:375 -msgid "Remove all items from the NDBM database." -msgstr "移除 NDBM 資料庫中所有項目。" - -#: ../../library/dbm.rst:381 +#: ../../library/dbm.rst:407 msgid ":mod:`dbm.dumb` --- Portable DBM implementation" msgstr ":mod:`dbm.dumb` --- 可攜式 DBM 實作" -#: ../../library/dbm.rst:386 +#: ../../library/dbm.rst:412 msgid "**Source code:** :source:`Lib/dbm/dumb.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/dumb.py`" -#: ../../library/dbm.rst:392 +#: ../../library/dbm.rst:418 msgid "" "The :mod:`dbm.dumb` module is intended as a last resort fallback for the :" "mod:`dbm` module when a more robust module is not available. The :mod:`dbm." @@ -510,53 +538,50 @@ msgid "" "the other database modules." msgstr "" -#: ../../library/dbm.rst:399 +#: ../../library/dbm.rst:425 msgid "" "The :mod:`dbm.dumb` module provides a persistent :class:`dict`-like " "interface which is written entirely in Python. Unlike other :mod:`dbm` " "backends, such as :mod:`dbm.gnu`, no external library is required." msgstr "" -#: ../../library/dbm.rst:404 +#: ../../library/dbm.rst:430 msgid "The :mod:`!dbm.dumb` module defines the following:" msgstr ":mod:`!dbm.dumb` 模組定義了以下項目:" -#: ../../library/dbm.rst:408 +#: ../../library/dbm.rst:434 msgid "" "Raised on :mod:`dbm.dumb`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" -#: ../../library/dbm.rst:414 -msgid "" -"Open a :mod:`!dbm.dumb` database. The returned database object behaves " -"similar to a :term:`mapping`, in addition to providing :meth:`~dumbdbm.sync` " -"and :meth:`~dumbdbm.close` methods." +#: ../../library/dbm.rst:440 +msgid "Open a :mod:`!dbm.dumb` database." msgstr "" -#: ../../library/dbm.rst:419 +#: ../../library/dbm.rst:442 msgid "" "The basename of the database file (without extensions). A new database " "creates the following files: - :file:`{filename}.dat` - :file:`{filename}." "dir`" msgstr "" -#: ../../library/dbm.rst:420 +#: ../../library/dbm.rst:443 msgid "" "The basename of the database file (without extensions). A new database " "creates the following files:" msgstr "" -#: ../../library/dbm.rst:423 +#: ../../library/dbm.rst:446 msgid ":file:`{filename}.dat`" msgstr ":file:`{filename}.dat`" -#: ../../library/dbm.rst:424 +#: ../../library/dbm.rst:447 msgid ":file:`{filename}.dir`" msgstr ":file:`{filename}.dir`" -#: ../../library/dbm.rst:427 +#: ../../library/dbm.rst:450 msgid "" "* ``'r'``: |flag_r| * ``'w'``: |flag_w| * ``'c'`` (default): |flag_c| * " "``'n'``: |flag_n|" @@ -564,48 +589,56 @@ msgstr "" "* ``'r'``: |flag_r| * ``'w'``: |flag_w| * ``'c'`` (default): |flag_c| * " "``'n'``: |flag_n|" -#: ../../library/dbm.rst:428 +#: ../../library/dbm.rst:451 msgid "``'r'``: |flag_r|" msgstr "``'r'``: |flag_r|" -#: ../../library/dbm.rst:430 +#: ../../library/dbm.rst:453 msgid "``'c'`` (default): |flag_c|" msgstr "``'c'`` (default): |flag_c|" -#: ../../library/dbm.rst:437 +#: ../../library/dbm.rst:460 msgid "" "It is possible to crash the Python interpreter when loading a database with " "a sufficiently large/complex entry due to stack depth limitations in " "Python's AST compiler." msgstr "" -#: ../../library/dbm.rst:441 +#: ../../library/dbm.rst:464 msgid "" ":func:`~dbm.dumb.open` always creates a new database when *flag* is ``'n'``." msgstr "" -#: ../../library/dbm.rst:444 +#: ../../library/dbm.rst:467 msgid "" "A database opened read-only if *flag* is ``'r'``. A database is not created " "if it does not exist if *flag* is ``'r'`` or ``'w'``." msgstr "" -#: ../../library/dbm.rst:451 +#: ../../library/dbm.rst:474 msgid "" -"In addition to the methods provided by the :class:`collections.abc." -"MutableMapping` class, the following methods are provided:" +"The returned database object behaves similar to a mutable :term:`mapping`, " +"but the :meth:`!keys` and :meth:`!items` methods return lists, and the :meth:" +"`!setdefault` method requires two arguments. It also supports a \"closing\" " +"context manager via the :keyword:`with` keyword." msgstr "" -#: ../../library/dbm.rst:457 +#: ../../library/dbm.rst:483 +msgid "Close the database." +msgstr "關閉資料庫。" + +#: ../../library/dbm.rst:487 msgid "" "Synchronize the on-disk directory and data files. This method is called by " "the :meth:`shelve.Shelf.sync` method." msgstr "" -#: ../../library/dbm.rst:462 -msgid "Close the database." -msgstr "關閉資料庫。" - -#: ../../library/dbm.rst:388 +#: ../../library/dbm.rst:414 msgid "databases" msgstr "databases(資料庫)" + +#~ msgid "Remove all items from the GDBM database." +#~ msgstr "移除 GDBM 資料庫中所有項目。" + +#~ msgid "Remove all items from the NDBM database." +#~ msgstr "移除 NDBM 資料庫中所有項目。" diff --git a/library/ssl.po b/library/ssl.po index 50fa4bb537..4b4e3e5db7 100644 --- a/library/ssl.po +++ b/library/ssl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-08-20 00:15+0000\n" "PO-Revision-Date: 2024-08-28 00:43+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -89,8 +89,8 @@ msgid "" "also encrypts and decrypts the data going over the socket with SSL. It " "supports additional methods such as :meth:`getpeercert`, which retrieves the " "certificate of the other side of the connection, :meth:`cipher`, which " -"retrieves the cipher being used for the secure connection " -"or :meth:`get_verified_chain`, :meth:`get_unverified_chain` which retrieves " +"retrieves the cipher being used for the secure connection or :meth:" +"`get_verified_chain`, :meth:`get_unverified_chain` which retrieves " "certificate chain." msgstr "" "此模組提供了一個 :class:`ssl.SSLSocket` 類別,它是從 :class:`socket.socket` " @@ -143,10 +143,9 @@ msgstr "Socket 建立" #: ../../library/ssl.rst:79 msgid "" -"Instances of :class:`SSLSocket` must be created using " -"the :meth:`SSLContext.wrap_socket` method. The helper " -"function :func:`create_default_context` returns a new context with secure " -"default settings." +"Instances of :class:`SSLSocket` must be created using the :meth:`SSLContext." +"wrap_socket` method. The helper function :func:`create_default_context` " +"returns a new context with secure default settings." msgstr "" ":class:`SSLSocket` 實例必須使用 :meth:`SSLContext.wrap_socket` 方法來建立。輔" "助函式 :func:`create_default_context` 會回傳有安全預設設定的新語境 " @@ -247,31 +246,31 @@ msgid "" "If all three are :const:`None`, this function can choose to trust the " "system's default CA certificates instead." msgstr "" -"*cafile*, *capath*, *cadata* 是用來選擇用於憑證認證的 CA 憑證,就" -"像 :meth:`SSLContext.load_verify_locations` 一樣。如果三個值都" -"是 :const:`None`,此函式會自動選擇系統預設的 CA 憑證。" +"*cafile*, *capath*, *cadata* 是用來選擇用於憑證認證的 CA 憑證,就像 :meth:" +"`SSLContext.load_verify_locations` 一樣。如果三個值都是 :const:`None`,此函式" +"會自動選擇系統預設的 CA 憑證。" # Skylull: `high encryption cipher` 可能是指 https://superuser.com/questions/1751902/how-to-check-which-ciphers-are-included-in-high-ciphers-constant # 其文中表示可能是指 128bit 以上 key length 的加密算法,需要其他來源佐證。 # 或是 https://help.fortinet.com/fweb/582/Content/FortiWeb/fortiweb-admin/supported_cipher_suites.htm#ssl_414712646_1189301 #: ../../library/ssl.rst:141 msgid "" -"The settings are: :data:`PROTOCOL_TLS_CLIENT` " -"or :data:`PROTOCOL_TLS_SERVER`, :data:`OP_NO_SSLv2`, and :data:`OP_NO_SSLv3` " -"with high encryption cipher suites without RC4 and without unauthenticated " -"cipher suites. Passing :const:`~Purpose.SERVER_AUTH` as *purpose* " -"sets :data:`~SSLContext.verify_mode` to :data:`CERT_REQUIRED` and either " -"loads CA certificates (when at least one of *cafile*, *capath* or *cadata* " -"is given) or uses :meth:`SSLContext.load_default_certs` to load default CA " +"The settings are: :data:`PROTOCOL_TLS_CLIENT` or :data:" +"`PROTOCOL_TLS_SERVER`, :data:`OP_NO_SSLv2`, and :data:`OP_NO_SSLv3` with " +"high encryption cipher suites without RC4 and without unauthenticated cipher " +"suites. Passing :const:`~Purpose.SERVER_AUTH` as *purpose* sets :data:" +"`~SSLContext.verify_mode` to :data:`CERT_REQUIRED` and either loads CA " +"certificates (when at least one of *cafile*, *capath* or *cadata* is given) " +"or uses :meth:`SSLContext.load_default_certs` to load default CA " "certificates." msgstr "" -"這些設定包含::data:`PROTOCOL_TLS_CLIENT` " -"或 :data:`PROTOCOL_TLS_SERVER`、:data:`OP_NO_SSLv2`、以" -"及 :data:`OP_NO_SSLv3`,使用高等加密套件但不包含 RC4 和未經身份驗證的加密套" -"件。如果將 *purpose* 設定為 :const:`~Purpose.SERVER_AUTH`,則會" -"把 :data:`~SSLContext.verify_mode` 設為 :data:`CERT_REQUIRED` 並使用設定的 " -"CA 憑證(當 *cafile*、*capath* 或 *cadata* 其中一個值有被設定時) 或使用預設的 " -"CA 憑證 :meth:`SSLContext.load_default_certs` 。" +"這些設定包含::data:`PROTOCOL_TLS_CLIENT` 或 :data:`PROTOCOL_TLS_SERVER`、:" +"data:`OP_NO_SSLv2`、以及 :data:`OP_NO_SSLv3`,使用高等加密套件但不包含 RC4 和" +"未經身份驗證的加密套件。如果將 *purpose* 設定為 :const:`~Purpose." +"SERVER_AUTH`,則會把 :data:`~SSLContext.verify_mode` 設為 :data:" +"`CERT_REQUIRED` 並使用設定的 CA 憑證(當 *cafile*、*capath* 或 *cadata* 其中一" +"個值有被設定時) 或使用預設的 CA 憑證 :meth:`SSLContext." +"load_default_certs` 。" #: ../../library/ssl.rst:150 msgid "" @@ -279,16 +278,16 @@ msgid "" "variable :envvar:`SSLKEYLOGFILE` is set, :func:`create_default_context` " "enables key logging." msgstr "" -"當系統有支援 :attr:`~SSLContext.keylog_filename` 並且有設定環境變" -"數 :envvar:`SSLKEYLOGFILE` 時 :func:`create_default_context` 會啟用密鑰日誌記" -"錄 (logging)。" +"當系統有支援 :attr:`~SSLContext.keylog_filename` 並且有設定環境變數 :envvar:" +"`SSLKEYLOGFILE` 時 :func:`create_default_context` 會啟用密鑰日誌記錄 " +"(logging)。" #: ../../library/ssl.rst:154 msgid "" -"The default settings for this context " -"include :data:`VERIFY_X509_PARTIAL_CHAIN` and :data:`VERIFY_X509_STRICT`. " -"These make the underlying OpenSSL implementation behave more like a " -"conforming implementation of :rfc:`5280`, in exchange for a small amount of " +"The default settings for this context include :data:" +"`VERIFY_X509_PARTIAL_CHAIN` and :data:`VERIFY_X509_STRICT`. These make the " +"underlying OpenSSL implementation behave more like a conforming " +"implementation of :rfc:`5280`, in exchange for a small amount of " "incompatibility with older X.509 certificates." msgstr "" @@ -303,8 +302,8 @@ msgstr "" #: ../../library/ssl.rst:165 msgid "" -"If your application needs specific settings, you should create " -"a :class:`SSLContext` and apply the settings yourself." +"If your application needs specific settings, you should create a :class:" +"`SSLContext` and apply the settings yourself." msgstr "" "如果你的應用程式需要特殊的設定,你應該要自行建立一個 :class:`SSLContext` 並自" "行調整設定。" @@ -315,9 +314,9 @@ msgid "" "with a :class:`SSLContext` created by this function that they get an error " "stating \"Protocol or cipher suite mismatch\", it may be that they only " "support SSL3.0 which this function excludes using the :data:`OP_NO_SSLv3`. " -"SSL3.0 is widely considered to be `completely broken `_. If you still wish to continue to use this " -"function but still allow SSL 3.0 connections you can re-enable them using::" +"SSL3.0 is widely considered to be `completely broken `_. If you still wish to continue to use this function but " +"still allow SSL 3.0 connections you can re-enable them using::" msgstr "" "如果你發現某些舊的用戶端或伺服器常適用此函式建立的 :class:`SSLContext` 連線" "時,收到 \"Protocol or cipher suite mismatch\" 錯誤,這可能是因為他們的系統僅" @@ -367,17 +366,16 @@ msgstr "增加了 :envvar:`SSLKEYLOGFILE` 對密鑰日誌記錄 (logging) 的支 #: ../../library/ssl.rst:208 msgid "" -"The context now uses :data:`PROTOCOL_TLS_CLIENT` " -"or :data:`PROTOCOL_TLS_SERVER` protocol instead of " -"generic :data:`PROTOCOL_TLS`." +"The context now uses :data:`PROTOCOL_TLS_CLIENT` or :data:" +"`PROTOCOL_TLS_SERVER` protocol instead of generic :data:`PROTOCOL_TLS`." msgstr "" "目前語境使用 :data:`PROTOCOL_TLS_CLIENT` 協定或 :data:`PROTOCOL_TLS_SERVER` " "協定而非通用的 :data:`PROTOCOL_TLS`。" #: ../../library/ssl.rst:214 msgid "" -"The context now uses :data:`VERIFY_X509_PARTIAL_CHAIN` " -"and :data:`VERIFY_X509_STRICT` in its default verify flags." +"The context now uses :data:`VERIFY_X509_PARTIAL_CHAIN` and :data:" +"`VERIFY_X509_STRICT` in its default verify flags." msgstr "" #: ../../library/ssl.rst:219 @@ -394,9 +392,9 @@ msgid "" "OpenSSL library." msgstr "" "引發由底層 SSL 實作(目前由 OpenSSL 函式庫提供)所引發的錯誤訊息。這表示在覆" -"蓋底層網路連線的高階加密和身份驗證層中存在一些問題。這項錯誤" -"是 :exc:`OSError` 的一個子型別。:exc:`SSLError` 實例的錯誤程式代碼和訊息是由 " -"OpenSSL 函式庫提供。" +"蓋底層網路連線的高階加密和身份驗證層中存在一些問題。這項錯誤是 :exc:" +"`OSError` 的一個子型別。:exc:`SSLError` 實例的錯誤程式代碼和訊息是由 OpenSSL " +"函式庫提供。" #: ../../library/ssl.rst:230 msgid ":exc:`SSLError` used to be a subtype of :exc:`socket.error`." @@ -492,16 +490,16 @@ msgstr "隨機產生" #: ../../library/ssl.rst:319 msgid "" -"Return *num* cryptographically strong pseudo-random bytes. Raises " -"an :class:`SSLError` if the PRNG has not been seeded with enough data or if " -"the operation is not supported by the current RAND " -"method. :func:`RAND_status` can be used to check the status of the PRNG " -"and :func:`RAND_add` can be used to seed the PRNG." +"Return *num* cryptographically strong pseudo-random bytes. Raises an :class:" +"`SSLError` if the PRNG has not been seeded with enough data or if the " +"operation is not supported by the current RAND method. :func:`RAND_status` " +"can be used to check the status of the PRNG and :func:`RAND_add` can be used " +"to seed the PRNG." msgstr "" "回傳 *num* 個加密性強的偽隨機位元組。如果 PRNG 未使用足夠的資料做為隨機種子 " -"(seed) 或是目前的 RAND 方法不支持該操作則會導致 :class:`SSLError` 錯" -"誤。:func:`RAND_status` 函式可以用來檢查 PRNG 函式,而 :func:`RAND_add` 則可" -"以用來為 PRNG 設定隨機種子。" +"(seed) 或是目前的 RAND 方法不支持該操作則會導致 :class:`SSLError` 錯誤。:" +"func:`RAND_status` 函式可以用來檢查 PRNG 函式,而 :func:`RAND_add` 則可以用來" +"為 PRNG 設定隨機種子。" #: ../../library/ssl.rst:325 msgid "For almost all applications :func:`os.urandom` is preferable." @@ -514,21 +512,20 @@ msgid "" "Cryptographically_secure_pseudorandom_number_generator>`_, to get the " "requirements of a cryptographically strong generator." msgstr "" -"請閱讀維基百科的\\ `密碼學安全偽隨機數產生器 (CSPRNG) `_\\ 文章來了解密碼學" -"安全偽隨機數產生器的需求。" +"請閱讀維基百科的\\ `密碼學安全偽隨機數產生器 (CSPRNG) `_\\ 文章來了" +"解密碼學安全偽隨機數產生器的需求。" #: ../../library/ssl.rst:336 msgid "" "Return ``True`` if the SSL pseudo-random number generator has been seeded " -"with 'enough' randomness, and ``False`` otherwise. You can " -"use :func:`ssl.RAND_egd` and :func:`ssl.RAND_add` to increase the randomness " -"of the pseudo-random number generator." +"with 'enough' randomness, and ``False`` otherwise. You can use :func:`ssl." +"RAND_egd` and :func:`ssl.RAND_add` to increase the randomness of the pseudo-" +"random number generator." msgstr "" "如果 SSL 偽隨機數產生器已經使用「足夠的」隨機性進行隨機種子生成,則回傳 " -"``True`` ,否則回傳 ``False``。你可以使用 :func:`ssl.RAND_egd` 函式" -"和 :func:`ssl.RAND_add` 函式來增加偽隨機數產生器的隨機性。" +"``True`` ,否則回傳 ``False``。你可以使用 :func:`ssl.RAND_egd` 函式和 :func:" +"`ssl.RAND_add` 函式來增加偽隨機數產生器的隨機性。" #: ../../library/ssl.rst:343 msgid "" @@ -601,19 +598,19 @@ msgid "" "PEM-encoded string. If ``ssl_version`` is specified, uses that version of " "the SSL protocol to attempt to connect to the server. If *ca_certs* is " "specified, it should be a file containing a list of root certificates, the " -"same format as used for the *cafile* parameter " -"in :meth:`SSLContext.load_verify_locations`. The call will attempt to " -"validate the server certificate against that set of root certificates, and " -"will fail if the validation attempt fails. A timeout can be specified with " -"the ``timeout`` parameter." +"same format as used for the *cafile* parameter in :meth:`SSLContext." +"load_verify_locations`. The call will attempt to validate the server " +"certificate against that set of root certificates, and will fail if the " +"validation attempt fails. A timeout can be specified with the ``timeout`` " +"parameter." msgstr "" "輸入使用 SSL 保護的伺服器的地址 ``addr``,輸入形式為一個 pair (*hostname*, " "*port-number*),取得該伺服器的憑證,並以 PEM 編碼字串的形式回傳。如果指定了 " "``ssl_version``,則使用指定的 SSL 協定來嘗試與伺服器連線。如果指定 " -"*ca_certs*,則它應該是一個包含根憑證列表的檔案,並" -"與 :meth:`SSLContext.load_verify_locations` 中的參數 *cafile* 所使用的格式相" -"同。此呼叫將嘗試使用該組根憑證對伺服器憑證進行驗證,如果驗證失敗,呼叫將失" -"敗。可以使用 ``timeout`` 參數指定超時時間。" +"*ca_certs*,則它應該是一個包含根憑證列表的檔案,並與 :meth:`SSLContext." +"load_verify_locations` 中的參數 *cafile* 所使用的格式相同。此呼叫將嘗試使用該" +"組根憑證對伺服器憑證進行驗證,如果驗證失敗,呼叫將失敗。可以使用 ``timeout`` " +"參數指定超時時間。" #: ../../library/ssl.rst:399 msgid "This function is now IPv6-compatible." @@ -621,11 +618,11 @@ msgstr "此函式現在是與 IPv6 相容的。" #: ../../library/ssl.rst:402 msgid "" -"The default *ssl_version* is changed from :data:`PROTOCOL_SSLv3` " -"to :data:`PROTOCOL_TLS` for maximum compatibility with modern servers." +"The default *ssl_version* is changed from :data:`PROTOCOL_SSLv3` to :data:" +"`PROTOCOL_TLS` for maximum compatibility with modern servers." msgstr "" -"預設的 *ssl_version* 已經從 :data:`PROTOCOL_SSLv3` 改" -"為 :data:`PROTOCOL_TLS`,已確保與現今的伺服器有最大的相容性。" +"預設的 *ssl_version* 已經從 :data:`PROTOCOL_SSLv3` 改為 :data:" +"`PROTOCOL_TLS`,已確保與現今的伺服器有最大的相容性。" #: ../../library/ssl.rst:406 msgid "The *timeout* parameter was added." @@ -652,9 +649,9 @@ msgid "" "paths are the same as used by :meth:`SSLContext.set_default_verify_paths`. " "The return value is a :term:`named tuple` ``DefaultVerifyPaths``:" msgstr "" -"回傳一個具有 OpenSSL 的預設 cafile 和 capath 路徑的附名元組。這些路徑" -"與 :meth:`SSLContext.set_default_verify_paths` 使用的相同。回傳值是一" -"個 :term:`named tuple` ``DefaultVerifyPaths``:" +"回傳一個具有 OpenSSL 的預設 cafile 和 capath 路徑的附名元組。這些路徑與 :" +"meth:`SSLContext.set_default_verify_paths` 使用的相同。回傳值是一個 :term:" +"`named tuple` ``DefaultVerifyPaths``:" #: ../../library/ssl.rst:426 msgid "" @@ -700,20 +697,18 @@ msgstr "" #: ../../library/ssl.rst:441 msgid "" "The function returns a list of (cert_bytes, encoding_type, trust) tuples. " -"The encoding_type specifies the encoding of cert_bytes. It is " -"either :const:`x509_asn` for X.509 ASN.1 data or :const:`pkcs_7_asn` for " -"PKCS#7 ASN.1 data. Trust specifies the purpose of the certificate as a set " -"of OIDS or exactly ``True`` if the certificate is trustworthy for all " -"purposes." +"The encoding_type specifies the encoding of cert_bytes. It is either :const:" +"`x509_asn` for X.509 ASN.1 data or :const:`pkcs_7_asn` for PKCS#7 ASN.1 " +"data. Trust specifies the purpose of the certificate as a set of OIDS or " +"exactly ``True`` if the certificate is trustworthy for all purposes." msgstr "" "此函式會回傳一個元組 (cert_bytes, encoding_type, trust) 串列。encoding_type " -"指定了 cert_bytes 的編碼格式。它可以是用來表示 X.509 ASN.1 資料" -"的 :const:`x509_asn` 或是用來表示 PKCS#7 ASN.1 資料的 :const:`pkcs_7_asn`。" -"Trust 通過一組 OIDS 來指定憑證的用途,或是如果憑證對所有用途都可以使用則回傳 " -"``True``。" +"指定了 cert_bytes 的編碼格式。它可以是用來表示 X.509 ASN.1 資料的 :const:" +"`x509_asn` 或是用來表示 PKCS#7 ASN.1 資料的 :const:`pkcs_7_asn`。Trust 通過一" +"組 OIDS 來指定憑證的用途,或是如果憑證對所有用途都可以使用則回傳 ``True``。" #: ../../library/ssl.rst:448 ../../library/ssl.rst:1599 -#: ../../library/ssl.rst:1898 +#: ../../library/ssl.rst:1899 msgid "Example::" msgstr "範例: ::" @@ -738,13 +733,12 @@ msgstr "" #: ../../library/ssl.rst:464 msgid "" "The function returns a list of (cert_bytes, encoding_type, trust) tuples. " -"The encoding_type specifies the encoding of cert_bytes. It is " -"either :const:`x509_asn` for X.509 ASN.1 data or :const:`pkcs_7_asn` for " -"PKCS#7 ASN.1 data." +"The encoding_type specifies the encoding of cert_bytes. It is either :const:" +"`x509_asn` for X.509 ASN.1 data or :const:`pkcs_7_asn` for PKCS#7 ASN.1 data." msgstr "" "此函式會回傳一個元組 (cert_bytes, encoding_type, trust) 串列。encoding_type " -"指定了 cert_bytes 的編碼格式。它可以是用來表示 X.509 ASN.1 資料" -"的 :const:`x509_asn` 或是用來表示 PKCS#7 ASN.1 資料的 :const:`pkcs_7_asn`。" +"指定了 cert_bytes 的編碼格式。它可以是用來表示 X.509 ASN.1 資料的 :const:" +"`x509_asn` 或是用來表示 PKCS#7 ASN.1 資料的 :const:`pkcs_7_asn`。" #: ../../library/ssl.rst:475 msgid "Constants" @@ -759,11 +753,10 @@ msgstr "" #: ../../library/ssl.rst:483 msgid "" -"Possible value for :attr:`SSLContext.verify_mode`. Except " -"for :const:`PROTOCOL_TLS_CLIENT`, it is the default mode. With client-side " -"sockets, just about any cert is accepted. Validation errors, such as " -"untrusted or expired cert, are ignored and do not abort the TLS/SSL " -"handshake." +"Possible value for :attr:`SSLContext.verify_mode`. Except for :const:" +"`PROTOCOL_TLS_CLIENT`, it is the default mode. With client-side sockets, " +"just about any cert is accepted. Validation errors, such as untrusted or " +"expired cert, are ignored and do not abort the TLS/SSL handshake." msgstr "" ":attr:`SSLContext.verify_mode` 可能的值。除了 :attr:`SSLContext.verify_mode` " "外,這是預設的模式。對於用戶端的 sockets,幾乎任何憑證都能被允許。驗證錯誤," @@ -777,20 +770,19 @@ msgstr "" "在伺服器模式下,不會從用戶端請求任何憑證,所以用戶端不用發送任何用於用戶端憑" "證身分驗證的憑證。" -#: ../../library/ssl.rst:492 ../../library/ssl.rst:2400 +#: ../../library/ssl.rst:492 ../../library/ssl.rst:2401 msgid "See the discussion of :ref:`ssl-security` below." msgstr "參閱下方 :ref:`ssl-security` 的討論。" #: ../../library/ssl.rst:496 msgid "" -"Possible value for :attr:`SSLContext.verify_mode`. In client " -"mode, :const:`CERT_OPTIONAL` has the same meaning as :const:`CERT_REQUIRED`. " -"It is recommended to use :const:`CERT_REQUIRED` for client-side sockets " -"instead." +"Possible value for :attr:`SSLContext.verify_mode`. In client mode, :const:" +"`CERT_OPTIONAL` has the same meaning as :const:`CERT_REQUIRED`. It is " +"recommended to use :const:`CERT_REQUIRED` for client-side sockets instead." msgstr "" -":attr:`SSLContext.verify_mode` 可能的值。在用戶端模式" -"下,:const:`CERT_OPTIONAL` 具有與 :const:`CERT_REQUIRED` 相同的含意。對於客戶" -"端 sockets 推薦改用 :const:`CERT_REQUIRED`。" +":attr:`SSLContext.verify_mode` 可能的值。在用戶端模式下,:const:" +"`CERT_OPTIONAL` 具有與 :const:`CERT_REQUIRED` 相同的含意。對於客戶端 sockets " +"推薦改用 :const:`CERT_REQUIRED`。" #: ../../library/ssl.rst:501 msgid "" @@ -806,30 +798,29 @@ msgstr "" #: ../../library/ssl.rst:507 ../../library/ssl.rst:526 msgid "" -"Use of this setting requires a valid set of CA certificates to be passed " -"to :meth:`SSLContext.load_verify_locations`." +"Use of this setting requires a valid set of CA certificates to be passed to :" +"meth:`SSLContext.load_verify_locations`." msgstr "" -"使用此設定需要將一組有效的 CA 憑證傳送" -"給 :meth:`SSLContext.load_verify_locations`。" +"使用此設定需要將一組有效的 CA 憑證傳送給 :meth:`SSLContext." +"load_verify_locations`。" #: ../../library/ssl.rst:512 msgid "" "Possible value for :attr:`SSLContext.verify_mode`. In this mode, " -"certificates are required from the other side of the socket connection; " -"an :class:`SSLError` will be raised if no certificate is provided, or if its " +"certificates are required from the other side of the socket connection; an :" +"class:`SSLError` will be raised if no certificate is provided, or if its " "validation fails. This mode is **not** sufficient to verify a certificate in " -"client mode as it does not match " -"hostnames. :attr:`~SSLContext.check_hostname` must be enabled as well to " -"verify the authenticity of a cert. :const:`PROTOCOL_TLS_CLIENT` " -"uses :const:`CERT_REQUIRED` and enables :attr:`~SSLContext.check_hostname` " -"by default." +"client mode as it does not match hostnames. :attr:`~SSLContext." +"check_hostname` must be enabled as well to verify the authenticity of a " +"cert. :const:`PROTOCOL_TLS_CLIENT` uses :const:`CERT_REQUIRED` and enables :" +"attr:`~SSLContext.check_hostname` by default." msgstr "" ":attr:`SSLContext.verify_mode` 可能的值。在這個模式下,需要從 socket 連線的另" "一端取得憑證;如果未提供憑證或是驗證失敗,則將會導致 :class:`SSLError`。此模" -"式\\ **不能**\\ 在用戶端模式下對憑證進行驗證,因為它無法去配對主機名" -"稱。:attr:`~SSLContext.check_hostname` 也必須被開起來來驗證憑證的真實" -"性。:const:`PROTOCOL_TLS_CLIENT` 會使用 :const:`CERT_REQUIRED` 並預設開" -"啟 :attr:`~SSLContext.check_hostname`。" +"式\\ **不能**\\ 在用戶端模式下對憑證進行驗證,因為它無法去配對主機名稱。:" +"attr:`~SSLContext.check_hostname` 也必須被開起來來驗證憑證的真實性。:const:" +"`PROTOCOL_TLS_CLIENT` 會使用 :const:`CERT_REQUIRED` 並預設開啟 :attr:" +"`~SSLContext.check_hostname`。" #: ../../library/ssl.rst:522 msgid "" @@ -858,8 +849,8 @@ msgid "" "Possible value for :attr:`SSLContext.verify_flags`. In this mode, only the " "peer cert is checked but none of the intermediate CA certificates. The mode " "requires a valid CRL that is signed by the peer cert's issuer (its direct " -"ancestor CA). If no proper CRL has been loaded " -"with :attr:`SSLContext.load_verify_locations`, validation will fail." +"ancestor CA). If no proper CRL has been loaded with :attr:`SSLContext." +"load_verify_locations`, validation will fail." msgstr "" ":attr:`SSLContext.verify_flags` 可能的值。在此模式下,只會檢查同等的憑證而不" "會去檢查中間的 CA 憑證。此模式需要提供由對等憑證發行者 (它的直接上級 CA) 的有" @@ -925,8 +916,8 @@ msgstr "" #: ../../library/ssl.rst:608 msgid "" "TLS clients and servers require different default settings for secure " -"communication. The generic TLS protocol constant is deprecated in favor " -"of :data:`PROTOCOL_TLS_CLIENT` and :data:`PROTOCOL_TLS_SERVER`." +"communication. The generic TLS protocol constant is deprecated in favor of :" +"data:`PROTOCOL_TLS_CLIENT` and :data:`PROTOCOL_TLS_SERVER`." msgstr "" "TLS 的用戶端及伺服器端需要不同的預設值來實現安全通訊。通用的 TLS 協定常數已被" "廢除,並改用 :data:`PROTOCOL_TLS_CLIENT` 和 :data:`PROTOCOL_TLS_SERVER`。" @@ -938,8 +929,8 @@ msgid "" "enables :data:`CERT_REQUIRED` and :attr:`~SSLContext.check_hostname` by " "default." msgstr "" -"自動協商用戶端和伺服器服務器都支援的最高協定版本,並配置用戶端語境連線。該協定預設" -"啟用 :data:`CERT_REQUIRED` 和 :attr:`~SSLContext.check_hostname`。" +"自動協商用戶端和伺服器服務器都支援的最高協定版本,並配置用戶端語境連線。該協" +"定預設啟用 :data:`CERT_REQUIRED` 和 :attr:`~SSLContext.check_hostname`。" #: ../../library/ssl.rst:623 msgid "" @@ -972,13 +963,13 @@ msgstr "第三版的 SSL 是不安全的,強烈建議不要使用。" #: ../../library/ssl.rst:649 msgid "" "OpenSSL has deprecated all version specific protocols. Use the default " -"protocol :data:`PROTOCOL_TLS_SERVER` or :data:`PROTOCOL_TLS_CLIENT` " -"with :attr:`SSLContext.minimum_version` " -"and :attr:`SSLContext.maximum_version` instead." +"protocol :data:`PROTOCOL_TLS_SERVER` or :data:`PROTOCOL_TLS_CLIENT` with :" +"attr:`SSLContext.minimum_version` and :attr:`SSLContext.maximum_version` " +"instead." msgstr "" -"OpenSSL 已經終止了所有特定版本的協定。請改用預設" -"的 :data:`PROTOCOL_TLS_SERVER` 協定或帶有 :attr:`SSLContext.minimum_version` " -"和 :attr:`SSLContext.maximum_version` 的 :data:`PROTOCOL_TLS_CLIENT`。" +"OpenSSL 已經終止了所有特定版本的協定。請改用預設的 :data:" +"`PROTOCOL_TLS_SERVER` 協定或帶有 :attr:`SSLContext.minimum_version` 和 :attr:" +"`SSLContext.maximum_version` 的 :data:`PROTOCOL_TLS_CLIENT`。" #: ../../library/ssl.rst:657 msgid "Selects TLS version 1.0 as the channel encryption protocol." @@ -1051,13 +1042,11 @@ msgstr "" #: ../../library/ssl.rst:725 msgid "" -"The option is deprecated since OpenSSL 1.1.0, use the " -"new :attr:`SSLContext.minimum_version` " -"and :attr:`SSLContext.maximum_version` instead." +"The option is deprecated since OpenSSL 1.1.0, use the new :attr:`SSLContext." +"minimum_version` and :attr:`SSLContext.maximum_version` instead." msgstr "" -"該選項自從 OpenSSL 1.1.0 以後已被棄用,請改用新" -"的 :attr:`SSLContext.minimum_version` 及 :attr:`SSLContext.maximum_version` " -"代替。" +"該選項自從 OpenSSL 1.1.0 以後已被棄用,請改用新的 :attr:`SSLContext." +"minimum_version` 及 :attr:`SSLContext.maximum_version` 代替。" #: ../../library/ssl.rst:732 msgid "" @@ -1207,16 +1196,16 @@ msgid "" "Whether the OpenSSL library has built-in support for the *Application-Layer " "Protocol Negotiation* TLS extension as described in :rfc:`7301`." msgstr "" -"OpenSSL 函式庫是否內建支援 *應用層協定協商* TLS 擴充套件,該擴充套件描述" -"在 :rfc:`7301` 中。" +"OpenSSL 函式庫是否內建支援 *應用層協定協商* TLS 擴充套件,該擴充套件描述在 :" +"rfc:`7301` 中。" #: ../../library/ssl.rst:864 msgid "" "Whether the OpenSSL library has built-in support not checking subject common " "name and :attr:`SSLContext.hostname_checks_common_name` is writeable." msgstr "" -"OpenSSL 函式庫是否內建支援不檢查主題通用名稱" -"及 :attr:`SSLContext.hostname_checks_common_name` 是否可寫。" +"OpenSSL 函式庫是否內建支援不檢查主題通用名稱及 :attr:`SSLContext." +"hostname_checks_common_name` 是否可寫。" #: ../../library/ssl.rst:872 msgid "" @@ -1287,8 +1276,8 @@ msgid "" "List of supported TLS channel binding types. Strings in this list can be " "used as arguments to :meth:`SSLSocket.get_channel_binding`." msgstr "" -"支援的 TLS 通道綁定類型列表。列表中的字串可以作" -"為 :meth:`SSLSocket.get_channel_binding` 的參數。" +"支援的 TLS 通道綁定類型列表。列表中的字串可以作為 :meth:`SSLSocket." +"get_channel_binding` 的參數。" #: ../../library/ssl.rst:946 msgid "The version string of the OpenSSL library loaded by the interpreter::" @@ -1339,14 +1328,14 @@ msgid "" "parameters-6>`_ contains this list and references to the RFCs where their " "meaning is defined." msgstr "" -"來自 :rfc:`5246` 和其他文件的警報描述。`IANA TLS Alert Registry `_ 包含了此列表以及其含義定義所在的 RFC 的引用。" +"來自 :rfc:`5246` 和其他文件的警報描述。`IANA TLS Alert Registry `_ 包" +"含了此列表以及其含義定義所在的 RFC 的引用。" #: ../../library/ssl.rst:982 msgid "" -"Used as the return value of the callback function " -"in :meth:`SSLContext.set_servername_callback`." +"Used as the return value of the callback function in :meth:`SSLContext." +"set_servername_callback`." msgstr "" "被用來做為 :meth:`SSLContext.set_servername_callback` 中回呼函式的回傳值。" @@ -1356,20 +1345,20 @@ msgstr ":class:`enum.IntEnum` 為 ALERT_DESCRIPTION_* 常數中的一個集合 #: ../../library/ssl.rst:995 msgid "" -"Option for :func:`create_default_context` " -"and :meth:`SSLContext.load_default_certs`. This value indicates that the " -"context may be used to authenticate web servers (therefore, it will be used " -"to create client-side sockets)." +"Option for :func:`create_default_context` and :meth:`SSLContext." +"load_default_certs`. This value indicates that the context may be used to " +"authenticate web servers (therefore, it will be used to create client-side " +"sockets)." msgstr "" ":func:`create_default_context` 和 :meth:`SSLContext.load_default_certs` 的選" "項。此值表示該語境可能會用於驗證網頁伺服器 (因此它將用於建立用戶端 socket)。" #: ../../library/ssl.rst:1004 msgid "" -"Option for :func:`create_default_context` " -"and :meth:`SSLContext.load_default_certs`. This value indicates that the " -"context may be used to authenticate web clients (therefore, it will be used " -"to create server-side sockets)." +"Option for :func:`create_default_context` and :meth:`SSLContext." +"load_default_certs`. This value indicates that the context may be used to " +"authenticate web clients (therefore, it will be used to create server-side " +"sockets)." msgstr "" ":func:`create_default_context` 和 :meth:`SSLContext.load_default_certs` 的選" "項。此值表示該語境可能會用於驗證網頁用戶端 (因此,它將用於建立伺服器端的 " @@ -1381,13 +1370,11 @@ msgstr ":class:`enum.IntEnum` 為 SSL_ERROR_* 常數中的一個集合。" #: ../../library/ssl.rst:1019 msgid "" -":class:`enum.IntEnum` collection of SSL and TLS versions " -"for :attr:`SSLContext.maximum_version` " -"and :attr:`SSLContext.minimum_version`." +":class:`enum.IntEnum` collection of SSL and TLS versions for :attr:" +"`SSLContext.maximum_version` and :attr:`SSLContext.minimum_version`." msgstr "" -"用於 :attr:`SSLContext.maximum_version` " -"和 :attr:`SSLContext.minimum_version` 的 SSL 和 TLS 版" -"本 :class:`enum.IntEnum` 集合。" +"用於 :attr:`SSLContext.maximum_version` 和 :attr:`SSLContext." +"minimum_version` 的 SSL 和 TLS 版本 :class:`enum.IntEnum` 集合。" #: ../../library/ssl.rst:1027 msgid "" @@ -1404,11 +1391,11 @@ msgstr "SSL 3.0 到 TLS 1.3。" #: ../../library/ssl.rst:1041 msgid "" -"All :class:`TLSVersion` members except :attr:`TLSVersion.TLSv1_2` " -"and :attr:`TLSVersion.TLSv1_3` are deprecated." +"All :class:`TLSVersion` members except :attr:`TLSVersion.TLSv1_2` and :attr:" +"`TLSVersion.TLSv1_3` are deprecated." msgstr "" -"除了 :attr:`TLSVersion.TLSv1_2` 和 :attr:`TLSVersion.TLSv1_3` 之外,所有" -"的 :class:`TLSVersion` 成員都已被棄用。" +"除了 :attr:`TLSVersion.TLSv1_2` 和 :attr:`TLSVersion.TLSv1_3` 之外,所有的 :" +"class:`TLSVersion` 成員都已被棄用。" #: ../../library/ssl.rst:1046 msgid "SSL Sockets" @@ -1451,8 +1438,12 @@ msgid ":meth:`~socket.socket.getsockopt`, :meth:`~socket.socket.setsockopt`" msgstr ":meth:`~socket.socket.getsockopt`、:meth:`~socket.socket.setsockopt`" #: ../../library/ssl.rst:1060 -msgid ":meth:`~socket.socket.gettimeout`, :meth:`~socket.socket.settimeout`, :meth:`~socket.socket.setblocking`" -msgstr ":meth:`~socket.socket.gettimeout`、:meth:`~socket.socket.settimeout`、:meth:`~socket.socket.setblocking`" +msgid "" +":meth:`~socket.socket.gettimeout`, :meth:`~socket.socket.settimeout`, :meth:" +"`~socket.socket.setblocking`" +msgstr "" +":meth:`~socket.socket.gettimeout`、:meth:`~socket.socket.settimeout`、:meth:" +"`~socket.socket.setblocking`" #: ../../library/ssl.rst:1062 msgid ":meth:`~socket.socket.listen`" @@ -1503,8 +1494,8 @@ msgstr "" #: ../../library/ssl.rst:1077 msgid "" -"Instances of :class:`SSLSocket` must be created using " -"the :meth:`SSLContext.wrap_socket` method." +"Instances of :class:`SSLSocket` must be created using the :meth:`SSLContext." +"wrap_socket` method." msgstr "" ":class:`SSLSocket` 的實例必須使用 :meth:`SSLContext.wrap_socket` 方法建立。" @@ -1523,18 +1514,17 @@ msgstr "" #: ../../library/ssl.rst:1088 msgid "" -"It is deprecated to create a :class:`SSLSocket` instance directly, " -"use :meth:`SSLContext.wrap_socket` to wrap a socket." +"It is deprecated to create a :class:`SSLSocket` instance directly, use :meth:" +"`SSLContext.wrap_socket` to wrap a socket." msgstr "" -"直接建立 :class:`SSLSocket` 實例的方式已被棄用,請使" -"用 :meth:`SSLContext.wrap_socket` 來包裝 socket。" +"直接建立 :class:`SSLSocket` 實例的方式已被棄用,請使用 :meth:`SSLContext." +"wrap_socket` 來包裝 socket。" #: ../../library/ssl.rst:1092 msgid "" -":class:`SSLSocket` instances must to created " -"with :meth:`~SSLContext.wrap_socket`. In earlier versions, it was possible " -"to create instances directly. This was never documented or officially " -"supported." +":class:`SSLSocket` instances must to created with :meth:`~SSLContext." +"wrap_socket`. In earlier versions, it was possible to create instances " +"directly. This was never documented or officially supported." msgstr "" ":class:`SSLSocket` 實例必須使用 :meth:`~SSLContext.wrap_socket` 建立。在較早" "的版本中可以直接建立實例,但這從未被記錄或正式支援。" @@ -1563,12 +1553,11 @@ msgstr "" #: ../../library/ssl.rst:1111 msgid "" -"Raise :exc:`SSLWantReadError` or :exc:`SSLWantWriteError` if the socket " -"is :ref:`non-blocking ` and the read would block." +"Raise :exc:`SSLWantReadError` or :exc:`SSLWantWriteError` if the socket is :" +"ref:`non-blocking ` and the read would block." msgstr "" -"如果 socket 是\\ :ref:`非阻塞的 `\\ 則會引" -"發 :exc:`SSLWantReadError` 或 :exc:`SSLWantWriteError` 並且讀取操作將會被阻" -"塞。" +"如果 socket 是\\ :ref:`非阻塞的 `\\ 則會引發 :exc:" +"`SSLWantReadError` 或 :exc:`SSLWantWriteError` 並且讀取操作將會被阻塞。" #: ../../library/ssl.rst:1114 msgid "" @@ -1600,12 +1589,11 @@ msgstr "" #: ../../library/ssl.rst:1130 msgid "" -"Raise :exc:`SSLWantReadError` or :exc:`SSLWantWriteError` if the socket " -"is :ref:`non-blocking ` and the write would block." +"Raise :exc:`SSLWantReadError` or :exc:`SSLWantWriteError` if the socket is :" +"ref:`non-blocking ` and the write would block." msgstr "" -"如果 socket 是\\ :ref:`非阻塞的 `\\ 則會引" -"發 :exc:`SSLWantReadError` 或 :exc:`SSLWantWriteError` 並且寫入操作將會被阻" -"塞。" +"如果 socket 是\\ :ref:`非阻塞的 `\\ 則會引發 :exc:" +"`SSLWantReadError` 或 :exc:`SSLWantWriteError` 並且寫入操作將會被阻塞。" #: ../../library/ssl.rst:1133 msgid "" @@ -1631,8 +1619,8 @@ msgid "" "The :meth:`~SSLSocket.read` and :meth:`~SSLSocket.write` methods are the low-" "level methods that read and write unencrypted, application-level data and " "decrypt/encrypt it to encrypted, wire-level data. These methods require an " -"active SSL connection, i.e. the handshake was completed " -"and :meth:`SSLSocket.unwrap` was not called." +"active SSL connection, i.e. the handshake was completed and :meth:`SSLSocket." +"unwrap` was not called." msgstr "" ":meth:`~SSLSocket.read` 和 :meth:`~SSLSocket.write` 方法為低階層的方法,負責" "讀取和寫入未加密的應用層資料,並將其加密/解密為加密的寫入層資料。這些方法需要" @@ -1640,9 +1628,8 @@ msgstr "" #: ../../library/ssl.rst:1151 msgid "" -"Normally you should use the socket API methods " -"like :meth:`~socket.socket.recv` and :meth:`~socket.socket.send` instead of " -"these methods." +"Normally you should use the socket API methods like :meth:`~socket.socket." +"recv` and :meth:`~socket.socket.send` instead of these methods." msgstr "" "通常你應該使用像 :meth:`~socket.socket.recv` 和 :meth:`~socket.socket.send` " "這樣的 socket API 方法,而不是直接使用這些方法。" @@ -1653,13 +1640,12 @@ msgstr "執行 SSL 設定握手。" #: ../../library/ssl.rst:1159 msgid "" -"The handshake method also performs :func:`match_hostname` when " -"the :attr:`~SSLContext.check_hostname` attribute of the " -"socket's :attr:`~SSLSocket.context` is true." +"The handshake method also performs :func:`match_hostname` when the :attr:" +"`~SSLContext.check_hostname` attribute of the socket's :attr:`~SSLSocket." +"context` is true." msgstr "" -"當 socket 的 :attr:`~SSLSocket.context` " -"的 :attr:`~SSLContext.check_hostname` 屬性質為 true 時,握手方法也會執" -"行 :func:`match_hostname`。" +"當 socket 的 :attr:`~SSLSocket.context` 的 :attr:`~SSLContext." +"check_hostname` 屬性質為 true 時,握手方法也會執行 :func:`match_hostname`。" #: ../../library/ssl.rst:1164 msgid "" @@ -1671,23 +1657,23 @@ msgstr "" #: ../../library/ssl.rst:1168 msgid "" -"Hostname or IP address is matched by OpenSSL during handshake. The " -"function :func:`match_hostname` is no longer used. In case OpenSSL refuses a " -"hostname or IP address, the handshake is aborted early and a TLS alert " -"message is sent to the peer." +"Hostname or IP address is matched by OpenSSL during handshake. The function :" +"func:`match_hostname` is no longer used. In case OpenSSL refuses a hostname " +"or IP address, the handshake is aborted early and a TLS alert message is " +"sent to the peer." msgstr "" -"在握手過程中,OpenSSL 會去配對主機名稱或 IP 地址。已不再使" -"用 :func:`match_hostname` 函式。如果 OpenSSL 拒絕某個主機名稱或 IP 地址,握手" -"將會提前中止,並向對方發送 TLS 警報訊息。" +"在握手過程中,OpenSSL 會去配對主機名稱或 IP 地址。已不再使用 :func:" +"`match_hostname` 函式。如果 OpenSSL 拒絕某個主機名稱或 IP 地址,握手將會提前" +"中止,並向對方發送 TLS 警報訊息。" #: ../../library/ssl.rst:1176 msgid "" "If there is no certificate for the peer on the other end of the connection, " -"return ``None``. If the SSL handshake hasn't been done yet, " -"raise :exc:`ValueError`." +"return ``None``. If the SSL handshake hasn't been done yet, raise :exc:" +"`ValueError`." msgstr "" -"如果連線端沒有證書,則回傳 ``None``。如果 SSL 握手尚未完成,則引" -"發 :exc:`ValueError`。" +"如果連線端沒有證書,則回傳 ``None``。如果 SSL 握手尚未完成,則引發 :exc:" +"`ValueError`。" #: ../../library/ssl.rst:1180 msgid "" @@ -1768,8 +1754,8 @@ msgid "" "socket's role:" msgstr "" "如果 ``binary_form`` 參數設定為 :const:`True`,且對等提供了證書,則該方法會" -"以 DER 編碼形式 將整個證書以位元組序列形式回傳。如果對等未提供證書,則回" -"傳 :const:`None`。對等是否提供證書取決於 SSL socket 的腳色:" +"以 DER 編碼形式 將整個證書以位元組序列形式回傳。如果對等未提供證書,則回傳 :" +"const:`None`。對等是否提供證書取決於 SSL socket 的腳色:" #: ../../library/ssl.rst:1219 msgid "" @@ -1780,13 +1766,13 @@ msgstr "對於用戶端 SSL socket,伺服器將永遠提供證書,無論是 #: ../../library/ssl.rst:1222 msgid "" "for a server SSL socket, the client will only provide a certificate when " -"requested by the server; therefore :meth:`getpeercert` will " -"return :const:`None` if you used :const:`CERT_NONE` (rather " -"than :const:`CERT_OPTIONAL` or :const:`CERT_REQUIRED`)." +"requested by the server; therefore :meth:`getpeercert` will return :const:" +"`None` if you used :const:`CERT_NONE` (rather than :const:`CERT_OPTIONAL` " +"or :const:`CERT_REQUIRED`)." msgstr "" "對於伺服器 SSL socket,用戶端僅在伺服器要求時才會提供證書;因此,如果你使用的" -"是 :const:`CERT_NONE` (而非 :const:`CERT_OPTIONAL` " -"或 :const:`CERT_REQUIRED`),則 :meth:`getpeercert` 會回傳 :const:`None`。" +"是 :const:`CERT_NONE` (而非 :const:`CERT_OPTIONAL` 或 :const:" +"`CERT_REQUIRED`),則 :meth:`getpeercert` 會回傳 :const:`None`。" #: ../../library/ssl.rst:1227 msgid "See also :attr:`SSLContext.check_hostname`." @@ -1862,18 +1848,17 @@ msgstr "" msgid "" "The *cb_type* parameter allow selection of the desired channel binding type. " "Valid channel binding types are listed in the :data:`CHANNEL_BINDING_TYPES` " -"list. Currently only the 'tls-unique' channel binding, defined " -"by :rfc:`5929`, is supported. :exc:`ValueError` will be raised if an " -"unsupported channel binding type is requested." +"list. Currently only the 'tls-unique' channel binding, defined by :rfc:" +"`5929`, is supported. :exc:`ValueError` will be raised if an unsupported " +"channel binding type is requested." msgstr "" #: ../../library/ssl.rst:1299 msgid "" -"Return the protocol that was selected during the TLS handshake. " -"If :meth:`SSLContext.set_alpn_protocols` was not called, if the other party " -"does not support ALPN, if this socket does not support any of the client's " -"proposed protocols, or if the handshake has not happened yet, ``None`` is " -"returned." +"Return the protocol that was selected during the TLS handshake. If :meth:" +"`SSLContext.set_alpn_protocols` was not called, if the other party does not " +"support ALPN, if this socket does not support any of the client's proposed " +"protocols, or if the handshake has not happened yet, ``None`` is returned." msgstr "" #: ../../library/ssl.rst:1309 @@ -1901,8 +1886,8 @@ msgstr "" msgid "" "Requests post-handshake authentication (PHA) from a TLS 1.3 client. PHA can " "only be initiated for a TLS 1.3 connection from a server-side socket, after " -"the initial TLS handshake and with PHA enabled on both sides, " -"see :attr:`SSLContext.post_handshake_auth`." +"the initial TLS handshake and with PHA enabled on both sides, see :attr:" +"`SSLContext.post_handshake_auth`." msgstr "" #: ../../library/ssl.rst:1335 @@ -1914,8 +1899,8 @@ msgstr "" #: ../../library/ssl.rst:1339 msgid "" -"If any precondition isn't met (e.g. not TLS 1.3, PHA not enabled), " -"an :exc:`SSLError` is raised." +"If any precondition isn't met (e.g. not TLS 1.3, PHA not enabled), an :exc:" +"`SSLError` is raised." msgstr "" #: ../../library/ssl.rst:1343 @@ -1959,16 +1944,16 @@ msgstr "" msgid "" "The attribute is now always ASCII text. When ``server_hostname`` is an " "internationalized domain name (IDN), this attribute now stores the A-label " -"form (``\"xn--pythn-mua.org\"``), rather than the U-label form " -"(``\"pythön.org\"``)." +"form (``\"xn--pythn-mua.org\"``), rather than the U-label form (``\"pythön." +"org\"``)." msgstr "" #: ../../library/ssl.rst:1391 msgid "" "The :class:`SSLSession` for this SSL connection. The session is available " "for client and server side sockets after the TLS handshake has been " -"performed. For client sockets the session can be set " -"before :meth:`~SSLSocket.do_handshake` has been called to reuse a session." +"performed. For client sockets the session can be set before :meth:" +"`~SSLSocket.do_handshake` has been called to reuse a session." msgstr "" #: ../../library/ssl.rst:1404 @@ -2098,27 +2083,28 @@ msgstr "" #: ../../library/ssl.rst:1453 msgid "" -"The context is created with secure default values. The " -"options :data:`OP_NO_COMPRESSION`, :data:`OP_CIPHER_SERVER_PREFERENCE`, :data:`OP_SINGLE_DH_USE`, :data:`OP_SINGLE_ECDH_USE`, :data:`OP_NO_SSLv2`, " -"and :data:`OP_NO_SSLv3` (except for :data:`PROTOCOL_SSLv3`) are set by " -"default. The initial cipher suite list contains only ``HIGH`` ciphers, no " -"``NULL`` ciphers and no ``MD5`` ciphers." +"The context is created with secure default values. The options :data:" +"`OP_NO_COMPRESSION`, :data:`OP_CIPHER_SERVER_PREFERENCE`, :data:" +"`OP_SINGLE_DH_USE`, :data:`OP_SINGLE_ECDH_USE`, :data:`OP_NO_SSLv2`, and :" +"data:`OP_NO_SSLv3` (except for :data:`PROTOCOL_SSLv3`) are set by default. " +"The initial cipher suite list contains only ``HIGH`` ciphers, no ``NULL`` " +"ciphers and no ``MD5`` ciphers." msgstr "" #: ../../library/ssl.rst:1463 msgid "" ":class:`SSLContext` without protocol argument is deprecated. The context " -"class will either require :data:`PROTOCOL_TLS_CLIENT` " -"or :data:`PROTOCOL_TLS_SERVER` protocol in the future." +"class will either require :data:`PROTOCOL_TLS_CLIENT` or :data:" +"`PROTOCOL_TLS_SERVER` protocol in the future." msgstr "" #: ../../library/ssl.rst:1469 msgid "" "The default cipher suites now include only secure AES and ChaCha20 ciphers " "with forward secrecy and security level 2. RSA and DH keys with less than " -"2048 bits and ECC keys with less than 224 bits are " -"prohibited. :data:`PROTOCOL_TLS`, :data:`PROTOCOL_TLS_CLIENT`, " -"and :data:`PROTOCOL_TLS_SERVER` use TLS 1.2 as minimum TLS version." +"2048 bits and ECC keys with less than 224 bits are prohibited. :data:" +"`PROTOCOL_TLS`, :data:`PROTOCOL_TLS_CLIENT`, and :data:`PROTOCOL_TLS_SERVER` " +"use TLS 1.2 as minimum TLS version." msgstr "" #: ../../library/ssl.rst:1477 @@ -2203,9 +2189,9 @@ msgstr "" msgid "" "Load a set of default \"certification authority\" (CA) certificates from " "default locations. On Windows it loads CA certs from the ``CA`` and ``ROOT`` " -"system stores. On all systems it " -"calls :meth:`SSLContext.set_default_verify_paths`. In the future the method " -"may load CA certificates from other locations, too." +"system stores. On all systems it calls :meth:`SSLContext." +"set_default_verify_paths`. In the future the method may load CA certificates " +"from other locations, too." msgstr "" #: ../../library/ssl.rst:1543 @@ -2220,9 +2206,8 @@ msgstr "" #: ../../library/ssl.rst:1553 msgid "" "Load a set of \"certification authority\" (CA) certificates used to validate " -"other peers' certificates when :data:`verify_mode` is other " -"than :data:`CERT_NONE`. At least one of *cafile* or *capath* must be " -"specified." +"other peers' certificates when :data:`verify_mode` is other than :data:" +"`CERT_NONE`. At least one of *cafile* or *capath* must be specified." msgstr "" #: ../../library/ssl.rst:1557 @@ -2276,8 +2261,8 @@ msgstr "" #: ../../library/ssl.rst:1596 msgid "" -"Get a list of enabled ciphers. The list is in order of cipher priority. " -"See :meth:`SSLContext.set_ciphers`." +"Get a list of enabled ciphers. The list is in order of cipher priority. See :" +"meth:`SSLContext.set_ciphers`." msgstr "" #: ../../library/ssl.rst:1601 @@ -2365,16 +2350,16 @@ msgstr "" #: ../../library/ssl.rst:1653 msgid "" -"TLS 1.3 cipher suites cannot be disabled " -"with :meth:`~SSLContext.set_ciphers`." +"TLS 1.3 cipher suites cannot be disabled with :meth:`~SSLContext." +"set_ciphers`." msgstr "" #: ../../library/ssl.rst:1658 msgid "" "Specify which protocols the socket should advertise during the SSL/TLS " -"handshake. It should be a list of ASCII strings, like ``['http/1.1', 'spdy/" -"2']``, ordered by preference. The selection of a protocol will happen during " -"the handshake, and will play out according to :rfc:`7301`. After a " +"handshake. It should be a list of ASCII strings, like ``['http/1.1', " +"'spdy/2']``, ordered by preference. The selection of a protocol will happen " +"during the handshake, and will play out according to :rfc:`7301`. After a " "successful handshake, the :meth:`SSLSocket.selected_alpn_protocol` method " "will return the agreed-upon protocol." msgstr "" @@ -2392,9 +2377,9 @@ msgid "" "ordered by preference. The selection of a protocol will happen during the " "handshake, and will play out according to the `Application Layer Protocol " "Negotiation `_. After a successful handshake, " -"the :meth:`SSLSocket.selected_npn_protocol` method will return the agreed-" -"upon protocol." +"Layer_Protocol_Negotiation>`_. After a successful handshake, the :meth:" +"`SSLSocket.selected_npn_protocol` method will return the agreed-upon " +"protocol." msgstr "" #: ../../library/ssl.rst:1680 @@ -2431,37 +2416,37 @@ msgstr "" #: ../../library/ssl.rst:1708 msgid "" -"A typical use of this callback is to change " -"the :class:`ssl.SSLSocket`'s :attr:`SSLSocket.context` attribute to a new " -"object of type :class:`SSLContext` representing a certificate chain that " -"matches the server name." +"A typical use of this callback is to change the :class:`ssl.SSLSocket`'s :" +"attr:`SSLSocket.context` attribute to a new object of type :class:" +"`SSLContext` representing a certificate chain that matches the server name." msgstr "" #: ../../library/ssl.rst:1713 msgid "" "Due to the early negotiation phase of the TLS connection, only limited " -"methods and attributes are usable " -"like :meth:`SSLSocket.selected_alpn_protocol` and :attr:`SSLSocket.context`. " -"The :meth:`SSLSocket.getpeercert`, :meth:`SSLSocket.get_verified_chain`, :meth:`SSLSocket.get_unverified_chain` :meth:`SSLSocket.cipher` " -"and :meth:`SSLSocket.compression` methods require that the TLS connection " -"has progressed beyond the TLS Client Hello and therefore will not return " -"meaningful values nor can they be called safely." +"methods and attributes are usable like :meth:`SSLSocket." +"selected_alpn_protocol` and :attr:`SSLSocket.context`. The :meth:`SSLSocket." +"getpeercert`, :meth:`SSLSocket.get_verified_chain`, :meth:`SSLSocket." +"get_unverified_chain` :meth:`SSLSocket.cipher` and :meth:`SSLSocket." +"compression` methods require that the TLS connection has progressed beyond " +"the TLS Client Hello and therefore will not return meaningful values nor can " +"they be called safely." msgstr "" #: ../../library/ssl.rst:1722 msgid "" "The *sni_callback* function must return ``None`` to allow the TLS " -"negotiation to continue. If a TLS failure is required, a " -"constant :const:`ALERT_DESCRIPTION_* ` can " -"be returned. Other return values will result in a TLS fatal error " -"with :const:`ALERT_DESCRIPTION_INTERNAL_ERROR`." +"negotiation to continue. If a TLS failure is required, a constant :const:" +"`ALERT_DESCRIPTION_* ` can be returned. " +"Other return values will result in a TLS fatal error with :const:" +"`ALERT_DESCRIPTION_INTERNAL_ERROR`." msgstr "" #: ../../library/ssl.rst:1728 msgid "" "If an exception is raised from the *sni_callback* function the TLS " -"connection will terminate with a fatal TLS alert " -"message :const:`ALERT_DESCRIPTION_HANDSHAKE_FAILURE`." +"connection will terminate with a fatal TLS alert message :const:" +"`ALERT_DESCRIPTION_HANDSHAKE_FAILURE`." msgstr "" #: ../../library/ssl.rst:1732 @@ -2497,8 +2482,8 @@ msgstr "" #: ../../library/ssl.rst:1759 msgid "" -"This setting doesn't apply to client sockets. You can also use " -"the :data:`OP_SINGLE_DH_USE` option to further improve security." +"This setting doesn't apply to client sockets. You can also use the :data:" +"`OP_SINGLE_DH_USE` option to further improve security." msgstr "" #: ../../library/ssl.rst:1766 @@ -2512,8 +2497,8 @@ msgstr "" #: ../../library/ssl.rst:1772 msgid "" -"This setting doesn't apply to client sockets. You can also use " -"the :data:`OP_SINGLE_ECDH_USE` option to further improve security." +"This setting doesn't apply to client sockets. You can also use the :data:" +"`OP_SINGLE_ECDH_USE` option to further improve security." msgstr "" #: ../../library/ssl.rst:1775 @@ -2532,11 +2517,10 @@ msgstr "" #: ../../library/ssl.rst:1787 msgid "" -"Wrap an existing Python socket *sock* and return an instance " -"of :attr:`SSLContext.sslsocket_class` (default :class:`SSLSocket`). The " -"returned SSL socket is tied to the context, its settings and certificates. " -"*sock* must be a :const:`~socket.SOCK_STREAM` socket; other socket types are " -"unsupported." +"Wrap an existing Python socket *sock* and return an instance of :attr:" +"`SSLContext.sslsocket_class` (default :class:`SSLSocket`). The returned SSL " +"socket is tied to the context, its settings and certificates. *sock* must be " +"a :const:`~socket.SOCK_STREAM` socket; other socket types are unsupported." msgstr "" #: ../../library/ssl.rst:1793 @@ -2552,8 +2536,8 @@ msgid "" "after :meth:`connect` is called on the socket. For server-side sockets, if " "the socket has no remote peer, it is assumed to be a listening socket, and " "the server-side SSL wrapping is automatically performed on client " -"connections accepted via the :meth:`accept` method. The method may " -"raise :exc:`SSLError`." +"connections accepted via the :meth:`accept` method. The method may raise :" +"exc:`SSLError`." msgstr "" #: ../../library/ssl.rst:1804 @@ -2569,20 +2553,20 @@ msgstr "" msgid "" "The parameter ``do_handshake_on_connect`` specifies whether to do the SSL " "handshake automatically after doing a :meth:`socket.connect`, or whether the " -"application program will call it explicitly, by invoking " -"the :meth:`SSLSocket.do_handshake` method. " -"Calling :meth:`SSLSocket.do_handshake` explicitly gives the program control " -"over the blocking behavior of the socket I/O involved in the handshake." +"application program will call it explicitly, by invoking the :meth:" +"`SSLSocket.do_handshake` method. Calling :meth:`SSLSocket.do_handshake` " +"explicitly gives the program control over the blocking behavior of the " +"socket I/O involved in the handshake." msgstr "" #: ../../library/ssl.rst:1817 msgid "" -"The parameter ``suppress_ragged_eofs`` specifies how " -"the :meth:`SSLSocket.recv` method should signal unexpected EOF from the " -"other end of the connection. If specified as :const:`True` (the default), " -"it returns a normal EOF (an empty bytes object) in response to unexpected " -"EOF errors raised from the underlying socket; if :const:`False`, it will " -"raise the exceptions back to the caller." +"The parameter ``suppress_ragged_eofs`` specifies how the :meth:`SSLSocket." +"recv` method should signal unexpected EOF from the other end of the " +"connection. If specified as :const:`True` (the default), it returns a " +"normal EOF (an empty bytes object) in response to unexpected EOF errors " +"raised from the underlying socket; if :const:`False`, it will raise the " +"exceptions back to the caller." msgstr "" #: ../../library/ssl.rst:1824 @@ -2591,8 +2575,8 @@ msgstr "" #: ../../library/ssl.rst:1826 msgid "" -"To wrap an :class:`SSLSocket` in another :class:`SSLSocket`, " -"use :meth:`SSLContext.wrap_bio`." +"To wrap an :class:`SSLSocket` in another :class:`SSLSocket`, use :meth:" +"`SSLContext.wrap_bio`." msgstr "" #: ../../library/ssl.rst:1829 @@ -2601,7 +2585,7 @@ msgid "" "SNI." msgstr "" -#: ../../library/ssl.rst:1833 ../../library/ssl.rst:1859 +#: ../../library/ssl.rst:1833 ../../library/ssl.rst:1860 msgid "*session* argument was added." msgstr "新增 *session* 引數。" @@ -2613,39 +2597,39 @@ msgstr "" #: ../../library/ssl.rst:1842 msgid "" -"The return type of :meth:`SSLContext.wrap_socket`, defaults " -"to :class:`SSLSocket`. The attribute can be overridden on instance of class " -"in order to return a custom subclass of :class:`SSLSocket`." +"The return type of :meth:`SSLContext.wrap_socket`, defaults to :class:" +"`SSLSocket`. The attribute can be assigned to on instances of :class:" +"`SSLContext` in order to return a custom subclass of :class:`SSLSocket`." msgstr "" -#: ../../library/ssl.rst:1851 +#: ../../library/ssl.rst:1852 msgid "" -"Wrap the BIO objects *incoming* and *outgoing* and return an instance " -"of :attr:`SSLContext.sslobject_class` (default :class:`SSLObject`). The SSL " +"Wrap the BIO objects *incoming* and *outgoing* and return an instance of :" +"attr:`SSLContext.sslobject_class` (default :class:`SSLObject`). The SSL " "routines will read input data from the incoming BIO and write data to the " "outgoing BIO." msgstr "" -#: ../../library/ssl.rst:1856 +#: ../../library/ssl.rst:1857 msgid "" "The *server_side*, *server_hostname* and *session* parameters have the same " "meaning as in :meth:`SSLContext.wrap_socket`." msgstr "" -#: ../../library/ssl.rst:1862 +#: ../../library/ssl.rst:1863 msgid "" "The method returns an instance of :attr:`SSLContext.sslobject_class` instead " "of hard-coded :class:`SSLObject`." msgstr "" -#: ../../library/ssl.rst:1868 +#: ../../library/ssl.rst:1869 msgid "" -"The return type of :meth:`SSLContext.wrap_bio`, defaults " -"to :class:`SSLObject`. The attribute can be overridden on instance of class " -"in order to return a custom subclass of :class:`SSLObject`." +"The return type of :meth:`SSLContext.wrap_bio`, defaults to :class:" +"`SSLObject`. The attribute can be overridden on instance of class in order " +"to return a custom subclass of :class:`SSLObject`." msgstr "" -#: ../../library/ssl.rst:1876 +#: ../../library/ssl.rst:1877 msgid "" "Get statistics about the SSL sessions created or managed by this context. A " "dictionary is returned which maps the names of each `piece of information " @@ -2654,7 +2638,7 @@ msgid "" "the session cache since the context was created::" msgstr "" -#: ../../library/ssl.rst:1881 +#: ../../library/ssl.rst:1882 msgid "" ">>> stats = context.session_stats()\n" ">>> stats['hits'], stats['misses']\n" @@ -2664,21 +2648,20 @@ msgstr "" ">>> stats['hits'], stats['misses']\n" "(0, 0)" -#: ../../library/ssl.rst:1887 +#: ../../library/ssl.rst:1888 msgid "" "Whether to match the peer cert's hostname in :meth:`SSLSocket.do_handshake`. " -"The context's :attr:`~SSLContext.verify_mode` must be set " -"to :data:`CERT_OPTIONAL` or :data:`CERT_REQUIRED`, and you must pass " +"The context's :attr:`~SSLContext.verify_mode` must be set to :data:" +"`CERT_OPTIONAL` or :data:`CERT_REQUIRED`, and you must pass " "*server_hostname* to :meth:`~SSLContext.wrap_socket` in order to match the " -"hostname. Enabling hostname checking automatically " -"sets :attr:`~SSLContext.verify_mode` from :data:`CERT_NONE` " -"to :data:`CERT_REQUIRED`. It cannot be set back to :data:`CERT_NONE` as " -"long as hostname checking is enabled. The :data:`PROTOCOL_TLS_CLIENT` " -"protocol enables hostname checking by default. With other protocols, " -"hostname checking must be enabled explicitly." +"hostname. Enabling hostname checking automatically sets :attr:`~SSLContext." +"verify_mode` from :data:`CERT_NONE` to :data:`CERT_REQUIRED`. It cannot be " +"set back to :data:`CERT_NONE` as long as hostname checking is enabled. The :" +"data:`PROTOCOL_TLS_CLIENT` protocol enables hostname checking by default. " +"With other protocols, hostname checking must be enabled explicitly." msgstr "" -#: ../../library/ssl.rst:1900 +#: ../../library/ssl.rst:1901 msgid "" "import socket, ssl\n" "\n" @@ -2702,15 +2685,15 @@ msgstr "" "ssl_sock = context.wrap_socket(s, server_hostname='www.verisign.com')\n" "ssl_sock.connect(('www.verisign.com', 443))" -#: ../../library/ssl.rst:1915 +#: ../../library/ssl.rst:1916 msgid "" -":attr:`~SSLContext.verify_mode` is now automatically changed " -"to :data:`CERT_REQUIRED` when hostname checking is enabled " -"and :attr:`~SSLContext.verify_mode` is :data:`CERT_NONE`. Previously the " -"same operation would have failed with a :exc:`ValueError`." +":attr:`~SSLContext.verify_mode` is now automatically changed to :data:" +"`CERT_REQUIRED` when hostname checking is enabled and :attr:`~SSLContext." +"verify_mode` is :data:`CERT_NONE`. Previously the same operation would have " +"failed with a :exc:`ValueError`." msgstr "" -#: ../../library/ssl.rst:1922 +#: ../../library/ssl.rst:1923 msgid "" "Write TLS keys to a keylog file, whenever key material is generated or " "received. The keylog file is designed for debugging purposes only. The file " @@ -2719,58 +2702,56 @@ msgid "" "synchronized between threads, but not between processes." msgstr "" -#: ../../library/ssl.rst:1932 +#: ../../library/ssl.rst:1933 msgid "" "A :class:`TLSVersion` enum member representing the highest supported TLS " "version. The value defaults to :attr:`TLSVersion.MAXIMUM_SUPPORTED`. The " -"attribute is read-only for protocols other " -"than :const:`PROTOCOL_TLS`, :const:`PROTOCOL_TLS_CLIENT`, " -"and :const:`PROTOCOL_TLS_SERVER`." +"attribute is read-only for protocols other than :const:`PROTOCOL_TLS`, :" +"const:`PROTOCOL_TLS_CLIENT`, and :const:`PROTOCOL_TLS_SERVER`." msgstr "" -#: ../../library/ssl.rst:1937 +#: ../../library/ssl.rst:1938 msgid "" -"The " -"attributes :attr:`~SSLContext.maximum_version`, :attr:`~SSLContext.minimum_version` " -"and :attr:`SSLContext.options` all affect the supported SSL and TLS versions " -"of the context. The implementation does not prevent invalid combination. For " -"example a context with :attr:`OP_NO_TLSv1_2` in :attr:`~SSLContext.options` " -"and :attr:`~SSLContext.maximum_version` set to :attr:`TLSVersion.TLSv1_2` " -"will not be able to establish a TLS 1.2 connection." +"The attributes :attr:`~SSLContext.maximum_version`, :attr:`~SSLContext." +"minimum_version` and :attr:`SSLContext.options` all affect the supported SSL " +"and TLS versions of the context. The implementation does not prevent invalid " +"combination. For example a context with :attr:`OP_NO_TLSv1_2` in :attr:" +"`~SSLContext.options` and :attr:`~SSLContext.maximum_version` set to :attr:" +"`TLSVersion.TLSv1_2` will not be able to establish a TLS 1.2 connection." msgstr "" -#: ../../library/ssl.rst:1950 +#: ../../library/ssl.rst:1951 msgid "" "Like :attr:`SSLContext.maximum_version` except it is the lowest supported " "version or :attr:`TLSVersion.MINIMUM_SUPPORTED`." msgstr "" -#: ../../library/ssl.rst:1957 +#: ../../library/ssl.rst:1958 msgid "" -"Control the number of TLS 1.3 session tickets of " -"a :const:`PROTOCOL_TLS_SERVER` context. The setting has no impact on TLS 1.0 " -"to 1.2 connections." +"Control the number of TLS 1.3 session tickets of a :const:" +"`PROTOCOL_TLS_SERVER` context. The setting has no impact on TLS 1.0 to 1.2 " +"connections." msgstr "" -#: ../../library/ssl.rst:1965 +#: ../../library/ssl.rst:1966 msgid "" "An integer representing the set of SSL options enabled on this context. The " -"default value is :data:`OP_ALL`, but you can specify other options such " -"as :data:`OP_NO_SSLv2` by ORing them together." +"default value is :data:`OP_ALL`, but you can specify other options such as :" +"data:`OP_NO_SSLv2` by ORing them together." msgstr "" -#: ../../library/ssl.rst:1969 +#: ../../library/ssl.rst:1970 msgid ":attr:`SSLContext.options` returns :class:`Options` flags:" msgstr "" -#: ../../library/ssl.rst:1977 +#: ../../library/ssl.rst:1978 msgid "" "All ``OP_NO_SSL*`` and ``OP_NO_TLS*`` options have been deprecated since " -"Python 3.7. Use :attr:`SSLContext.minimum_version` " -"and :attr:`SSLContext.maximum_version` instead." +"Python 3.7. Use :attr:`SSLContext.minimum_version` and :attr:`SSLContext." +"maximum_version` instead." msgstr "" -#: ../../library/ssl.rst:1983 +#: ../../library/ssl.rst:1984 msgid "" "Enable TLS 1.3 post-handshake client authentication. Post-handshake auth is " "disabled by default and a server can only request a TLS client certificate " @@ -2778,81 +2759,80 @@ msgid "" "client certificate at any time after the handshake." msgstr "" -#: ../../library/ssl.rst:1988 +#: ../../library/ssl.rst:1989 msgid "" "When enabled on client-side sockets, the client signals the server that it " "supports post-handshake authentication." msgstr "" -#: ../../library/ssl.rst:1991 +#: ../../library/ssl.rst:1992 msgid "" "When enabled on server-side sockets, :attr:`SSLContext.verify_mode` must be " "set to :data:`CERT_OPTIONAL` or :data:`CERT_REQUIRED`, too. The actual " -"client cert exchange is delayed " -"until :meth:`SSLSocket.verify_client_post_handshake` is called and some I/O " -"is performed." +"client cert exchange is delayed until :meth:`SSLSocket." +"verify_client_post_handshake` is called and some I/O is performed." msgstr "" -#: ../../library/ssl.rst:2001 +#: ../../library/ssl.rst:2002 msgid "" "The protocol version chosen when constructing the context. This attribute " "is read-only." msgstr "" -#: ../../library/ssl.rst:2006 +#: ../../library/ssl.rst:2007 msgid "" "Whether :attr:`~SSLContext.check_hostname` falls back to verify the cert's " "subject common name in the absence of a subject alternative name extension " "(default: true)." msgstr "" -#: ../../library/ssl.rst:2014 +#: ../../library/ssl.rst:2015 msgid "" "The flag had no effect with OpenSSL before version 1.1.1l. Python 3.8.9, " "3.9.3, and 3.10 include workarounds for previous versions." msgstr "" -#: ../../library/ssl.rst:2019 +#: ../../library/ssl.rst:2020 msgid "" "An integer representing the `security level `_ for the context. This attribute is read-" "only." msgstr "" -#: ../../library/ssl.rst:2027 +#: ../../library/ssl.rst:2028 msgid "" -"The flags for certificate verification operations. You can set flags " -"like :data:`VERIFY_CRL_CHECK_LEAF` by ORing them together. By default " -"OpenSSL does neither require nor verify certificate revocation lists (CRLs)." +"The flags for certificate verification operations. You can set flags like :" +"data:`VERIFY_CRL_CHECK_LEAF` by ORing them together. By default OpenSSL does " +"neither require nor verify certificate revocation lists (CRLs)." msgstr "" -#: ../../library/ssl.rst:2033 +#: ../../library/ssl.rst:2034 msgid ":attr:`SSLContext.verify_flags` returns :class:`VerifyFlags` flags:" msgstr "" -#: ../../library/ssl.rst:2041 +#: ../../library/ssl.rst:2042 msgid "" "Whether to try to verify other peers' certificates and how to behave if " -"verification fails. This attribute must be one " -"of :data:`CERT_NONE`, :data:`CERT_OPTIONAL` or :data:`CERT_REQUIRED`." +"verification fails. This attribute must be one of :data:`CERT_NONE`, :data:" +"`CERT_OPTIONAL` or :data:`CERT_REQUIRED`." msgstr "" -#: ../../library/ssl.rst:2045 +#: ../../library/ssl.rst:2046 msgid ":attr:`SSLContext.verify_mode` returns :class:`VerifyMode` enum:" msgstr "" -#: ../../library/ssl.rst:2053 +#: ../../library/ssl.rst:2054 msgid "" "Enables TLS-PSK (pre-shared key) authentication on a client-side connection." msgstr "" -#: ../../library/ssl.rst:2055 ../../library/ssl.rst:2104 +#: ../../library/ssl.rst:2056 ../../library/ssl.rst:2105 msgid "" "In general, certificate based authentication should be preferred over this " "method." msgstr "" -#: ../../library/ssl.rst:2057 +#: ../../library/ssl.rst:2058 msgid "" "The parameter ``callback`` is a callable object with the signature: ``def " "callback(hint: str | None) -> tuple[str | None, bytes]``. The ``hint`` " @@ -2864,27 +2844,27 @@ msgid "" "shared key. Return a zero length PSK to reject the connection." msgstr "" -#: ../../library/ssl.rst:2067 ../../library/ssl.rst:2113 +#: ../../library/ssl.rst:2068 ../../library/ssl.rst:2114 msgid "Setting ``callback`` to :const:`None` removes any existing callback." msgstr "" -#: ../../library/ssl.rst:2070 +#: ../../library/ssl.rst:2071 msgid "When using TLS 1.3:" msgstr "" -#: ../../library/ssl.rst:2072 +#: ../../library/ssl.rst:2073 msgid "the ``hint`` parameter is always :const:`None`." msgstr "" -#: ../../library/ssl.rst:2073 +#: ../../library/ssl.rst:2074 msgid "client-identity must be a non-empty string." msgstr "" -#: ../../library/ssl.rst:2075 ../../library/ssl.rst:2122 +#: ../../library/ssl.rst:2076 ../../library/ssl.rst:2123 msgid "Example usage::" msgstr "範例用法: ::" -#: ../../library/ssl.rst:2077 +#: ../../library/ssl.rst:2078 msgid "" "context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n" "context.check_hostname = False\n" @@ -2905,18 +2885,18 @@ msgid "" "context.set_psk_client_callback(callback)" msgstr "" -#: ../../library/ssl.rst:2095 ../../library/ssl.rst:2140 +#: ../../library/ssl.rst:2096 ../../library/ssl.rst:2141 msgid "" "This method will raise :exc:`NotImplementedError` if :data:`HAS_PSK` is " "``False``." msgstr "" -#: ../../library/ssl.rst:2102 +#: ../../library/ssl.rst:2103 msgid "" "Enables TLS-PSK (pre-shared key) authentication on a server-side connection." msgstr "" -#: ../../library/ssl.rst:2106 +#: ../../library/ssl.rst:2107 msgid "" "The parameter ``callback`` is a callable object with the signature: ``def " "callback(identity: str | None) -> bytes``. The ``identity`` parameter is an " @@ -2926,19 +2906,19 @@ msgid "" "connection." msgstr "" -#: ../../library/ssl.rst:2115 +#: ../../library/ssl.rst:2116 msgid "" "The parameter ``identity_hint`` is an optional identity hint string sent to " "the client. The string must be less than or equal to ``256`` octets when " "UTF-8 encoded." msgstr "" -#: ../../library/ssl.rst:2120 +#: ../../library/ssl.rst:2121 msgid "" "When using TLS 1.3 the ``identity_hint`` parameter is not sent to the client." msgstr "" -#: ../../library/ssl.rst:2124 +#: ../../library/ssl.rst:2125 msgid "" "context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)\n" "context.maximum_version = ssl.TLSVersion.TLSv1_2\n" @@ -2957,11 +2937,11 @@ msgid "" "context.set_psk_server_callback(callback, 'ServerId_1')" msgstr "" -#: ../../library/ssl.rst:2152 +#: ../../library/ssl.rst:2153 msgid "Certificates" msgstr "" -#: ../../library/ssl.rst:2154 +#: ../../library/ssl.rst:2155 msgid "" "Certificates in general are part of a public-key / private-key system. In " "this system, each *principal*, (which may be a machine, or a person, or an " @@ -2972,7 +2952,7 @@ msgid "" "other part, and **only** with the other part." msgstr "" -#: ../../library/ssl.rst:2162 +#: ../../library/ssl.rst:2163 msgid "" "A certificate contains information about two principals. It contains the " "name of a *subject*, and the subject's public key. It also contains a " @@ -2986,7 +2966,7 @@ msgid "" "as two fields, called \"notBefore\" and \"notAfter\"." msgstr "" -#: ../../library/ssl.rst:2172 +#: ../../library/ssl.rst:2173 msgid "" "In the Python use of certificates, a client or server can use a certificate " "to prove who they are. The other side of a network connection can also be " @@ -2999,14 +2979,14 @@ msgid "" "take place." msgstr "" -#: ../../library/ssl.rst:2182 +#: ../../library/ssl.rst:2183 msgid "" "Python uses files to contain certificates. They should be formatted as " "\"PEM\" (see :rfc:`1422`), which is a base-64 encoded form wrapped with a " "header line and a footer line::" msgstr "" -#: ../../library/ssl.rst:2186 +#: ../../library/ssl.rst:2187 msgid "" "-----BEGIN CERTIFICATE-----\n" "... (certificate in base64 PEM encoding) ...\n" @@ -3016,11 +2996,11 @@ msgstr "" "... (certificate in base64 PEM encoding) ...\n" "-----END CERTIFICATE-----" -#: ../../library/ssl.rst:2191 +#: ../../library/ssl.rst:2192 msgid "Certificate chains" msgstr "" -#: ../../library/ssl.rst:2193 +#: ../../library/ssl.rst:2194 msgid "" "The Python files which contain certificates can contain a sequence of " "certificates, sometimes called a *certificate chain*. This chain should " @@ -3036,7 +3016,7 @@ msgid "" "agency which issued the certification authority's certificate::" msgstr "" -#: ../../library/ssl.rst:2206 +#: ../../library/ssl.rst:2207 msgid "" "-----BEGIN CERTIFICATE-----\n" "... (certificate for your server)...\n" @@ -3058,27 +3038,27 @@ msgstr "" "... (the root certificate for the CA's issuer)...\n" "-----END CERTIFICATE-----" -#: ../../library/ssl.rst:2217 +#: ../../library/ssl.rst:2218 msgid "CA certificates" msgstr "" -#: ../../library/ssl.rst:2219 +#: ../../library/ssl.rst:2220 msgid "" "If you are going to require validation of the other side of the connection's " "certificate, you need to provide a \"CA certs\" file, filled with the " "certificate chains for each issuer you are willing to trust. Again, this " "file just contains these chains concatenated together. For validation, " "Python will use the first chain it finds in the file which matches. The " -"platform's certificates file can be used by " -"calling :meth:`SSLContext.load_default_certs`, this is done automatically " -"with :func:`.create_default_context`." +"platform's certificates file can be used by calling :meth:`SSLContext." +"load_default_certs`, this is done automatically with :func:`." +"create_default_context`." msgstr "" -#: ../../library/ssl.rst:2228 +#: ../../library/ssl.rst:2229 msgid "Combined key and certificate" msgstr "" -#: ../../library/ssl.rst:2230 +#: ../../library/ssl.rst:2231 msgid "" "Often the private key is stored in the same file as the certificate; in this " "case, only the ``certfile`` parameter to :meth:`SSLContext.load_cert_chain` " @@ -3086,7 +3066,7 @@ msgid "" "should come before the first certificate in the certificate chain::" msgstr "" -#: ../../library/ssl.rst:2236 +#: ../../library/ssl.rst:2237 msgid "" "-----BEGIN RSA PRIVATE KEY-----\n" "... (private key in base64 encoding) ...\n" @@ -3102,11 +3082,11 @@ msgstr "" "... (certificate in base64 PEM encoding) ...\n" "-----END CERTIFICATE-----" -#: ../../library/ssl.rst:2244 +#: ../../library/ssl.rst:2245 msgid "Self-signed certificates" msgstr "" -#: ../../library/ssl.rst:2246 +#: ../../library/ssl.rst:2247 msgid "" "If you are going to create a server that provides SSL-encrypted connection " "services, you will need to acquire a certificate for that service. There " @@ -3116,7 +3096,7 @@ msgid "" "package, using something like the following::" msgstr "" -#: ../../library/ssl.rst:2253 +#: ../../library/ssl.rst:2254 msgid "" "% openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem\n" "Generating a 1024 bit RSA private key\n" @@ -3142,28 +3122,28 @@ msgid "" "%" msgstr "" -#: ../../library/ssl.rst:2275 +#: ../../library/ssl.rst:2276 msgid "" "The disadvantage of a self-signed certificate is that it is its own root " "certificate, and no one else will have it in their cache of known (and " "trusted) root certificates." msgstr "" -#: ../../library/ssl.rst:2281 +#: ../../library/ssl.rst:2282 msgid "Examples" msgstr "範例" -#: ../../library/ssl.rst:2284 +#: ../../library/ssl.rst:2285 msgid "Testing for SSL support" msgstr "" -#: ../../library/ssl.rst:2286 +#: ../../library/ssl.rst:2287 msgid "" "To test for the presence of SSL support in a Python installation, user code " "should use the following idiom::" msgstr "" -#: ../../library/ssl.rst:2289 +#: ../../library/ssl.rst:2290 msgid "" "try:\n" " import ssl\n" @@ -3173,27 +3153,27 @@ msgid "" " ... # do something that requires SSL support" msgstr "" -#: ../../library/ssl.rst:2297 +#: ../../library/ssl.rst:2298 msgid "Client-side operation" msgstr "" -#: ../../library/ssl.rst:2299 +#: ../../library/ssl.rst:2300 msgid "" "This example creates a SSL context with the recommended security settings " "for client sockets, including automatic certificate verification::" msgstr "" -#: ../../library/ssl.rst:2302 +#: ../../library/ssl.rst:2303 msgid ">>> context = ssl.create_default_context()" msgstr ">>> context = ssl.create_default_context()" -#: ../../library/ssl.rst:2304 +#: ../../library/ssl.rst:2305 msgid "" "If you prefer to tune security settings yourself, you might create a context " "from scratch (but beware that you might not get the settings right)::" msgstr "" -#: ../../library/ssl.rst:2308 +#: ../../library/ssl.rst:2309 msgid "" ">>> context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n" ">>> context.load_verify_locations(\"/etc/ssl/certs/ca-bundle.crt\")" @@ -3201,14 +3181,14 @@ msgstr "" ">>> context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n" ">>> context.load_verify_locations(\"/etc/ssl/certs/ca-bundle.crt\")" -#: ../../library/ssl.rst:2311 +#: ../../library/ssl.rst:2312 msgid "" "(this snippet assumes your operating system places a bundle of all CA " "certificates in ``/etc/ssl/certs/ca-bundle.crt``; if not, you'll get an " "error and have to adjust the location)" msgstr "" -#: ../../library/ssl.rst:2315 +#: ../../library/ssl.rst:2316 msgid "" "The :data:`PROTOCOL_TLS_CLIENT` protocol configures the context for cert " "validation and hostname verification. :attr:`~SSLContext.verify_mode` is set " @@ -3216,16 +3196,16 @@ msgid "" "``True``. All other protocols create SSL contexts with insecure defaults." msgstr "" -#: ../../library/ssl.rst:2320 +#: ../../library/ssl.rst:2321 msgid "" -"When you use the context to connect to a server, :const:`CERT_REQUIRED` " -"and :attr:`~SSLContext.check_hostname` validate the server certificate: it " +"When you use the context to connect to a server, :const:`CERT_REQUIRED` and :" +"attr:`~SSLContext.check_hostname` validate the server certificate: it " "ensures that the server certificate was signed with one of the CA " "certificates, checks the signature for correctness, and verifies other " "properties like validity and identity of the hostname::" msgstr "" -#: ../../library/ssl.rst:2326 +#: ../../library/ssl.rst:2327 msgid "" ">>> conn = context.wrap_socket(socket.socket(socket.AF_INET),\n" "... server_hostname=\"www.python.org\")\n" @@ -3235,30 +3215,30 @@ msgstr "" "... server_hostname=\"www.python.org\")\n" ">>> conn.connect((\"www.python.org\", 443))" -#: ../../library/ssl.rst:2330 +#: ../../library/ssl.rst:2331 msgid "You may then fetch the certificate::" msgstr "" -#: ../../library/ssl.rst:2332 +#: ../../library/ssl.rst:2333 msgid ">>> cert = conn.getpeercert()" msgstr ">>> cert = conn.getpeercert()" -#: ../../library/ssl.rst:2334 +#: ../../library/ssl.rst:2335 msgid "" "Visual inspection shows that the certificate does identify the desired " "service (that is, the HTTPS host ``www.python.org``)::" msgstr "" -#: ../../library/ssl.rst:2337 +#: ../../library/ssl.rst:2338 msgid "" ">>> pprint.pprint(cert)\n" "{'OCSP': ('http://ocsp.digicert.com',),\n" " 'caIssuers': ('http://cacerts.digicert.com/" "DigiCertSHA2ExtendedValidationServerCA.crt',),\n" -" 'crlDistributionPoints': ('http://crl3.digicert.com/sha2-ev-server-" -"g1.crl',\n" -" 'http://crl4.digicert.com/sha2-ev-server-" -"g1.crl'),\n" +" 'crlDistributionPoints': ('http://crl3.digicert.com/sha2-ev-server-g1." +"crl',\n" +" 'http://crl4.digicert.com/sha2-ev-server-g1." +"crl'),\n" " 'issuer': ((('countryName', 'US'),),\n" " (('organizationName', 'DigiCert Inc'),),\n" " (('organizationalUnitName', 'www.digicert.com'),),\n" @@ -3299,10 +3279,10 @@ msgstr "" "{'OCSP': ('http://ocsp.digicert.com',),\n" " 'caIssuers': ('http://cacerts.digicert.com/" "DigiCertSHA2ExtendedValidationServerCA.crt',),\n" -" 'crlDistributionPoints': ('http://crl3.digicert.com/sha2-ev-server-" -"g1.crl',\n" -" 'http://crl4.digicert.com/sha2-ev-server-" -"g1.crl'),\n" +" 'crlDistributionPoints': ('http://crl3.digicert.com/sha2-ev-server-g1." +"crl',\n" +" 'http://crl4.digicert.com/sha2-ev-server-g1." +"crl'),\n" " 'issuer': ((('countryName', 'US'),),\n" " (('organizationName', 'DigiCert Inc'),),\n" " (('organizationalUnitName', 'www.digicert.com'),),\n" @@ -3339,13 +3319,13 @@ msgstr "" " ('DNS', 'id.python.org')),\n" " 'version': 3}" -#: ../../library/ssl.rst:2377 +#: ../../library/ssl.rst:2378 msgid "" "Now the SSL channel is established and the certificate verified, you can " "proceed to talk with the server::" msgstr "" -#: ../../library/ssl.rst:2380 +#: ../../library/ssl.rst:2381 msgid "" ">>> conn.sendall(b\"HEAD / HTTP/1.0\\r\\nHost: linuxfr.org\\r\\n\\r\\n\")\n" ">>> pprint.pprint(conn.recv(1024).split(b\"\\r\\n\"))\n" @@ -3387,11 +3367,11 @@ msgstr "" " b'',\n" " b'']" -#: ../../library/ssl.rst:2404 +#: ../../library/ssl.rst:2405 msgid "Server-side operation" msgstr "" -#: ../../library/ssl.rst:2406 +#: ../../library/ssl.rst:2407 msgid "" "For server operation, typically you'll need to have a server certificate, " "and private key, each in a file. You'll first create a context holding the " @@ -3400,7 +3380,7 @@ msgid "" "start waiting for clients to connect::" msgstr "" -#: ../../library/ssl.rst:2412 +#: ../../library/ssl.rst:2413 msgid "" "import socket, ssl\n" "\n" @@ -3420,15 +3400,14 @@ msgstr "" "bindsocket.bind(('myaddr.example.com', 10023))\n" "bindsocket.listen(5)" -#: ../../library/ssl.rst:2421 +#: ../../library/ssl.rst:2422 msgid "" "When a client connects, you'll call :meth:`accept` on the socket to get the " -"new socket from the other end, and use the " -"context's :meth:`SSLContext.wrap_socket` method to create a server-side SSL " -"socket for the connection::" +"new socket from the other end, and use the context's :meth:`SSLContext." +"wrap_socket` method to create a server-side SSL socket for the connection::" msgstr "" -#: ../../library/ssl.rst:2425 +#: ../../library/ssl.rst:2426 msgid "" "while True:\n" " newsocket, fromaddr = bindsocket.accept()\n" @@ -3448,13 +3427,13 @@ msgstr "" " connstream.shutdown(socket.SHUT_RDWR)\n" " connstream.close()" -#: ../../library/ssl.rst:2434 +#: ../../library/ssl.rst:2435 msgid "" "Then you'll read data from the ``connstream`` and do something with it till " "you are finished with the client (or the client is finished with you)::" msgstr "" -#: ../../library/ssl.rst:2437 +#: ../../library/ssl.rst:2438 msgid "" "def deal_with_client(connstream):\n" " data = connstream.recv(1024)\n" @@ -3468,7 +3447,7 @@ msgid "" " # finished with client" msgstr "" -#: ../../library/ssl.rst:2448 +#: ../../library/ssl.rst:2449 msgid "" "And go back to listening for new client connections (of course, a real " "server would probably handle each client connection in a separate thread, or " @@ -3476,46 +3455,46 @@ msgid "" "event loop)." msgstr "" -#: ../../library/ssl.rst:2456 +#: ../../library/ssl.rst:2457 msgid "Notes on non-blocking sockets" msgstr "" -#: ../../library/ssl.rst:2458 +#: ../../library/ssl.rst:2459 msgid "" "SSL sockets behave slightly different than regular sockets in non-blocking " "mode. When working with non-blocking sockets, there are thus several things " "you need to be aware of:" msgstr "" -#: ../../library/ssl.rst:2462 +#: ../../library/ssl.rst:2463 msgid "" "Most :class:`SSLSocket` methods will raise either :exc:`SSLWantWriteError` " "or :exc:`SSLWantReadError` instead of :exc:`BlockingIOError` if an I/O " "operation would block. :exc:`SSLWantReadError` will be raised if a read " -"operation on the underlying socket is necessary, " -"and :exc:`SSLWantWriteError` for a write operation on the underlying socket. " -"Note that attempts to *write* to an SSL socket may require *reading* from " -"the underlying socket first, and attempts to *read* from the SSL socket may " +"operation on the underlying socket is necessary, and :exc:" +"`SSLWantWriteError` for a write operation on the underlying socket. Note " +"that attempts to *write* to an SSL socket may require *reading* from the " +"underlying socket first, and attempts to *read* from the SSL socket may " "require a prior *write* to the underlying socket." msgstr "" -#: ../../library/ssl.rst:2474 +#: ../../library/ssl.rst:2475 msgid "" "In earlier Python versions, the :meth:`!SSLSocket.send` method returned zero " "instead of raising :exc:`SSLWantWriteError` or :exc:`SSLWantReadError`." msgstr "" -#: ../../library/ssl.rst:2478 +#: ../../library/ssl.rst:2479 msgid "" "Calling :func:`~select.select` tells you that the OS-level socket can be " "read from (or written to), but it does not imply that there is sufficient " "data at the upper SSL layer. For example, only part of an SSL frame might " "have arrived. Therefore, you must be ready to handle :meth:`SSLSocket.recv` " -"and :meth:`SSLSocket.send` failures, and retry after another call " -"to :func:`~select.select`." +"and :meth:`SSLSocket.send` failures, and retry after another call to :func:" +"`~select.select`." msgstr "" -#: ../../library/ssl.rst:2485 +#: ../../library/ssl.rst:2486 msgid "" "Conversely, since the SSL layer has its own framing, a SSL socket may still " "have data available for reading without :func:`~select.select` being aware " @@ -3524,21 +3503,21 @@ msgid "" "call if still necessary." msgstr "" -#: ../../library/ssl.rst:2491 +#: ../../library/ssl.rst:2492 msgid "" -"(of course, similar provisions apply when using other primitives such " -"as :func:`~select.poll`, or those in the :mod:`selectors` module)" +"(of course, similar provisions apply when using other primitives such as :" +"func:`~select.poll`, or those in the :mod:`selectors` module)" msgstr "" -#: ../../library/ssl.rst:2494 +#: ../../library/ssl.rst:2495 msgid "" -"The SSL handshake itself will be non-blocking: " -"the :meth:`SSLSocket.do_handshake` method has to be retried until it returns " -"successfully. Here is a synopsis using :func:`~select.select` to wait for " -"the socket's readiness::" +"The SSL handshake itself will be non-blocking: the :meth:`SSLSocket." +"do_handshake` method has to be retried until it returns successfully. Here " +"is a synopsis using :func:`~select.select` to wait for the socket's " +"readiness::" msgstr "" -#: ../../library/ssl.rst:2499 +#: ../../library/ssl.rst:2500 msgid "" "while True:\n" " try:\n" @@ -3558,36 +3537,36 @@ msgstr "" " except ssl.SSLWantWriteError:\n" " select.select([], [sock], [])" -#: ../../library/ssl.rst:2510 +#: ../../library/ssl.rst:2511 msgid "" "The :mod:`asyncio` module supports :ref:`non-blocking SSL sockets ` and provides a higher level :ref:`Streams API `. It polls for events using the :mod:`selectors` module and " -"handles :exc:`SSLWantWriteError`, :exc:`SSLWantReadError` " -"and :exc:`BlockingIOError` exceptions. It runs the SSL handshake " -"asynchronously as well." +"handles :exc:`SSLWantWriteError`, :exc:`SSLWantReadError` and :exc:" +"`BlockingIOError` exceptions. It runs the SSL handshake asynchronously as " +"well." msgstr "" -#: ../../library/ssl.rst:2519 +#: ../../library/ssl.rst:2520 msgid "Memory BIO Support" msgstr "" -#: ../../library/ssl.rst:2523 +#: ../../library/ssl.rst:2524 msgid "" -"Ever since the SSL module was introduced in Python 2.6, " -"the :class:`SSLSocket` class has provided two related but distinct areas of " +"Ever since the SSL module was introduced in Python 2.6, the :class:" +"`SSLSocket` class has provided two related but distinct areas of " "functionality:" msgstr "" -#: ../../library/ssl.rst:2526 +#: ../../library/ssl.rst:2527 msgid "SSL protocol handling" msgstr "" -#: ../../library/ssl.rst:2527 +#: ../../library/ssl.rst:2528 msgid "Network IO" msgstr "" -#: ../../library/ssl.rst:2529 +#: ../../library/ssl.rst:2530 msgid "" "The network IO API is identical to that provided by :class:`socket.socket`, " "from which :class:`SSLSocket` also inherits. This allows an SSL socket to be " @@ -3595,19 +3574,19 @@ msgid "" "add SSL support to an existing application." msgstr "" -#: ../../library/ssl.rst:2534 +#: ../../library/ssl.rst:2535 msgid "" "Combining SSL protocol handling and network IO usually works well, but there " "are some cases where it doesn't. An example is async IO frameworks that want " "to use a different IO multiplexing model than the \"select/poll on a file " -"descriptor\" (readiness based) model that is assumed " -"by :class:`socket.socket` and by the internal OpenSSL socket IO routines. " -"This is mostly relevant for platforms like Windows where this model is not " -"efficient. For this purpose, a reduced scope variant of :class:`SSLSocket` " -"called :class:`SSLObject` is provided." +"descriptor\" (readiness based) model that is assumed by :class:`socket." +"socket` and by the internal OpenSSL socket IO routines. This is mostly " +"relevant for platforms like Windows where this model is not efficient. For " +"this purpose, a reduced scope variant of :class:`SSLSocket` called :class:" +"`SSLObject` is provided." msgstr "" -#: ../../library/ssl.rst:2545 +#: ../../library/ssl.rst:2546 msgid "" "A reduced-scope variant of :class:`SSLSocket` representing an SSL protocol " "instance that does not contain any network IO methods. This class is " @@ -3615,7 +3594,7 @@ msgid "" "for SSL through memory buffers." msgstr "" -#: ../../library/ssl.rst:2550 +#: ../../library/ssl.rst:2551 msgid "" "This class implements an interface on top of a low-level SSL object as " "implemented by OpenSSL. This object captures the state of an SSL connection " @@ -3623,7 +3602,7 @@ msgid "" "separate \"BIO\" objects which are OpenSSL's IO abstraction layer." msgstr "" -#: ../../library/ssl.rst:2555 +#: ../../library/ssl.rst:2556 msgid "" "This class has no public constructor. An :class:`SSLObject` instance must " "be created using the :meth:`~SSLContext.wrap_bio` method. This method will " @@ -3632,232 +3611,231 @@ msgid "" "instance, while the *outgoing* BIO is used to pass data the other way around." msgstr "" -#: ../../library/ssl.rst:2562 +#: ../../library/ssl.rst:2563 msgid "The following methods are available:" msgstr "" -#: ../../library/ssl.rst:2564 +#: ../../library/ssl.rst:2565 msgid ":attr:`~SSLSocket.context`" msgstr ":attr:`~SSLSocket.context`" -#: ../../library/ssl.rst:2565 +#: ../../library/ssl.rst:2566 msgid ":attr:`~SSLSocket.server_side`" msgstr ":attr:`~SSLSocket.server_side`" -#: ../../library/ssl.rst:2566 +#: ../../library/ssl.rst:2567 msgid ":attr:`~SSLSocket.server_hostname`" msgstr ":attr:`~SSLSocket.server_hostname`" -#: ../../library/ssl.rst:2567 +#: ../../library/ssl.rst:2568 msgid ":attr:`~SSLSocket.session`" msgstr ":attr:`~SSLSocket.session`" -#: ../../library/ssl.rst:2568 +#: ../../library/ssl.rst:2569 msgid ":attr:`~SSLSocket.session_reused`" msgstr ":attr:`~SSLSocket.session_reused`" -#: ../../library/ssl.rst:2569 +#: ../../library/ssl.rst:2570 msgid ":meth:`~SSLSocket.read`" msgstr ":meth:`~SSLSocket.read`" -#: ../../library/ssl.rst:2570 +#: ../../library/ssl.rst:2571 msgid ":meth:`~SSLSocket.write`" msgstr ":meth:`~SSLSocket.write`" -#: ../../library/ssl.rst:2571 +#: ../../library/ssl.rst:2572 msgid ":meth:`~SSLSocket.getpeercert`" msgstr ":meth:`~SSLSocket.getpeercert`" -#: ../../library/ssl.rst:2572 +#: ../../library/ssl.rst:2573 msgid ":meth:`~SSLSocket.get_verified_chain`" msgstr ":meth:`~SSLSocket.get_verified_chain`" -#: ../../library/ssl.rst:2573 +#: ../../library/ssl.rst:2574 msgid ":meth:`~SSLSocket.get_unverified_chain`" msgstr ":meth:`~SSLSocket.get_unverified_chain`" -#: ../../library/ssl.rst:2574 +#: ../../library/ssl.rst:2575 msgid ":meth:`~SSLSocket.selected_alpn_protocol`" msgstr ":meth:`~SSLSocket.selected_alpn_protocol`" -#: ../../library/ssl.rst:2575 +#: ../../library/ssl.rst:2576 msgid ":meth:`~SSLSocket.selected_npn_protocol`" msgstr ":meth:`~SSLSocket.selected_npn_protocol`" -#: ../../library/ssl.rst:2576 +#: ../../library/ssl.rst:2577 msgid ":meth:`~SSLSocket.cipher`" msgstr ":meth:`~SSLSocket.cipher`" -#: ../../library/ssl.rst:2577 +#: ../../library/ssl.rst:2578 msgid ":meth:`~SSLSocket.shared_ciphers`" msgstr ":meth:`~SSLSocket.shared_ciphers`" -#: ../../library/ssl.rst:2578 +#: ../../library/ssl.rst:2579 msgid ":meth:`~SSLSocket.compression`" msgstr ":meth:`~SSLSocket.compression`" -#: ../../library/ssl.rst:2579 +#: ../../library/ssl.rst:2580 msgid ":meth:`~SSLSocket.pending`" msgstr ":meth:`~SSLSocket.pending`" -#: ../../library/ssl.rst:2580 +#: ../../library/ssl.rst:2581 msgid ":meth:`~SSLSocket.do_handshake`" msgstr ":meth:`~SSLSocket.do_handshake`" -#: ../../library/ssl.rst:2581 +#: ../../library/ssl.rst:2582 msgid ":meth:`~SSLSocket.verify_client_post_handshake`" msgstr ":meth:`~SSLSocket.verify_client_post_handshake`" -#: ../../library/ssl.rst:2582 +#: ../../library/ssl.rst:2583 msgid ":meth:`~SSLSocket.unwrap`" msgstr ":meth:`~SSLSocket.unwrap`" -#: ../../library/ssl.rst:2583 +#: ../../library/ssl.rst:2584 msgid ":meth:`~SSLSocket.get_channel_binding`" msgstr ":meth:`~SSLSocket.get_channel_binding`" -#: ../../library/ssl.rst:2584 +#: ../../library/ssl.rst:2585 msgid ":meth:`~SSLSocket.version`" msgstr ":meth:`~SSLSocket.version`" -#: ../../library/ssl.rst:2586 +#: ../../library/ssl.rst:2587 msgid "" "When compared to :class:`SSLSocket`, this object lacks the following " "features:" msgstr "" -#: ../../library/ssl.rst:2589 +#: ../../library/ssl.rst:2590 msgid "" "Any form of network IO; ``recv()`` and ``send()`` read and write only to the " "underlying :class:`MemoryBIO` buffers." msgstr "" -#: ../../library/ssl.rst:2592 +#: ../../library/ssl.rst:2593 msgid "" "There is no *do_handshake_on_connect* machinery. You must always manually " "call :meth:`~SSLSocket.do_handshake` to start the handshake." msgstr "" -#: ../../library/ssl.rst:2595 +#: ../../library/ssl.rst:2596 msgid "" "There is no handling of *suppress_ragged_eofs*. All end-of-file conditions " -"that are in violation of the protocol are reported via " -"the :exc:`SSLEOFError` exception." +"that are in violation of the protocol are reported via the :exc:" +"`SSLEOFError` exception." msgstr "" -#: ../../library/ssl.rst:2599 +#: ../../library/ssl.rst:2600 msgid "" "The method :meth:`~SSLSocket.unwrap` call does not return anything, unlike " "for an SSL socket where it returns the underlying socket." msgstr "" -#: ../../library/ssl.rst:2602 +#: ../../library/ssl.rst:2603 msgid "" -"The *server_name_callback* callback passed " -"to :meth:`SSLContext.set_servername_callback` will get an :class:`SSLObject` " -"instance instead of a :class:`SSLSocket` instance as its first parameter." +"The *server_name_callback* callback passed to :meth:`SSLContext." +"set_servername_callback` will get an :class:`SSLObject` instance instead of " +"a :class:`SSLSocket` instance as its first parameter." msgstr "" -#: ../../library/ssl.rst:2606 +#: ../../library/ssl.rst:2607 msgid "Some notes related to the use of :class:`SSLObject`:" msgstr "" -#: ../../library/ssl.rst:2608 +#: ../../library/ssl.rst:2609 msgid "" "All IO on an :class:`SSLObject` is :ref:`non-blocking `. " -"This means that for example :meth:`~SSLSocket.read` will raise " -"an :exc:`SSLWantReadError` if it needs more data than the incoming BIO has " -"available." +"This means that for example :meth:`~SSLSocket.read` will raise an :exc:" +"`SSLWantReadError` if it needs more data than the incoming BIO has available." msgstr "" -#: ../../library/ssl.rst:2613 +#: ../../library/ssl.rst:2614 msgid "" -":class:`SSLObject` instances must be created " -"with :meth:`~SSLContext.wrap_bio`. In earlier versions, it was possible to " -"create instances directly. This was never documented or officially supported." +":class:`SSLObject` instances must be created with :meth:`~SSLContext." +"wrap_bio`. In earlier versions, it was possible to create instances " +"directly. This was never documented or officially supported." msgstr "" -#: ../../library/ssl.rst:2619 +#: ../../library/ssl.rst:2620 msgid "" "An SSLObject communicates with the outside world using memory buffers. The " "class :class:`MemoryBIO` provides a memory buffer that can be used for this " "purpose. It wraps an OpenSSL memory BIO (Basic IO) object:" msgstr "" -#: ../../library/ssl.rst:2625 +#: ../../library/ssl.rst:2626 msgid "" "A memory buffer that can be used to pass data between Python and an SSL " "protocol instance." msgstr "" -#: ../../library/ssl.rst:2630 +#: ../../library/ssl.rst:2631 msgid "Return the number of bytes currently in the memory buffer." msgstr "" -#: ../../library/ssl.rst:2634 +#: ../../library/ssl.rst:2635 msgid "" "A boolean indicating whether the memory BIO is current at the end-of-file " "position." msgstr "" -#: ../../library/ssl.rst:2639 +#: ../../library/ssl.rst:2640 msgid "" "Read up to *n* bytes from the memory buffer. If *n* is not specified or " "negative, all bytes are returned." msgstr "" -#: ../../library/ssl.rst:2644 +#: ../../library/ssl.rst:2645 msgid "" "Write the bytes from *buf* to the memory BIO. The *buf* argument must be an " "object supporting the buffer protocol." msgstr "" -#: ../../library/ssl.rst:2647 +#: ../../library/ssl.rst:2648 msgid "" "The return value is the number of bytes written, which is always equal to " "the length of *buf*." msgstr "" -#: ../../library/ssl.rst:2652 +#: ../../library/ssl.rst:2653 msgid "" "Write an EOF marker to the memory BIO. After this method has been called, it " "is illegal to call :meth:`~MemoryBIO.write`. The attribute :attr:`eof` will " "become true after all data currently in the buffer has been read." msgstr "" -#: ../../library/ssl.rst:2658 +#: ../../library/ssl.rst:2659 msgid "SSL session" msgstr "" -#: ../../library/ssl.rst:2664 +#: ../../library/ssl.rst:2665 msgid "Session object used by :attr:`~SSLSocket.session`." msgstr "" -#: ../../library/ssl.rst:2676 +#: ../../library/ssl.rst:2677 msgid "Security considerations" msgstr "" -#: ../../library/ssl.rst:2679 +#: ../../library/ssl.rst:2680 msgid "Best defaults" msgstr "" -#: ../../library/ssl.rst:2681 +#: ../../library/ssl.rst:2682 msgid "" "For **client use**, if you don't have any special requirements for your " -"security policy, it is highly recommended that you use " -"the :func:`create_default_context` function to create your SSL context. It " -"will load the system's trusted CA certificates, enable certificate " -"validation and hostname checking, and try to choose reasonably secure " -"protocol and cipher settings." +"security policy, it is highly recommended that you use the :func:" +"`create_default_context` function to create your SSL context. It will load " +"the system's trusted CA certificates, enable certificate validation and " +"hostname checking, and try to choose reasonably secure protocol and cipher " +"settings." msgstr "" -#: ../../library/ssl.rst:2688 +#: ../../library/ssl.rst:2689 msgid "" "For example, here is how you would use the :class:`smtplib.SMTP` class to " "create a trusted, secure connection to a SMTP server::" msgstr "" -#: ../../library/ssl.rst:2691 +#: ../../library/ssl.rst:2692 msgid "" ">>> import ssl, smtplib\n" ">>> smtp = smtplib.SMTP(\"mail.python.org\", port=587)\n" @@ -3871,50 +3849,50 @@ msgstr "" ">>> smtp.starttls(context=context)\n" "(220, b'2.0.0 Ready to start TLS')" -#: ../../library/ssl.rst:2697 +#: ../../library/ssl.rst:2698 msgid "" -"If a client certificate is needed for the connection, it can be added " -"with :meth:`SSLContext.load_cert_chain`." +"If a client certificate is needed for the connection, it can be added with :" +"meth:`SSLContext.load_cert_chain`." msgstr "" -#: ../../library/ssl.rst:2700 +#: ../../library/ssl.rst:2701 msgid "" -"By contrast, if you create the SSL context by calling " -"the :class:`SSLContext` constructor yourself, it will not have certificate " -"validation nor hostname checking enabled by default. If you do so, please " -"read the paragraphs below to achieve a good security level." +"By contrast, if you create the SSL context by calling the :class:" +"`SSLContext` constructor yourself, it will not have certificate validation " +"nor hostname checking enabled by default. If you do so, please read the " +"paragraphs below to achieve a good security level." msgstr "" -#: ../../library/ssl.rst:2706 +#: ../../library/ssl.rst:2707 msgid "Manual settings" msgstr "手動設定" -#: ../../library/ssl.rst:2709 +#: ../../library/ssl.rst:2710 msgid "Verifying certificates" msgstr "驗證憑證" -#: ../../library/ssl.rst:2711 +#: ../../library/ssl.rst:2712 msgid "" -"When calling the :class:`SSLContext` constructor " -"directly, :const:`CERT_NONE` is the default. Since it does not authenticate " -"the other peer, it can be insecure, especially in client mode where most of " -"the time you would like to ensure the authenticity of the server you're " -"talking to. Therefore, when in client mode, it is highly recommended to " -"use :const:`CERT_REQUIRED`. However, it is in itself not sufficient; you " -"also have to check that the server certificate, which can be obtained by " -"calling :meth:`SSLSocket.getpeercert`, matches the desired service. For " -"many protocols and applications, the service can be identified by the " -"hostname. This common check is automatically performed " -"when :attr:`SSLContext.check_hostname` is enabled." +"When calling the :class:`SSLContext` constructor directly, :const:" +"`CERT_NONE` is the default. Since it does not authenticate the other peer, " +"it can be insecure, especially in client mode where most of the time you " +"would like to ensure the authenticity of the server you're talking to. " +"Therefore, when in client mode, it is highly recommended to use :const:" +"`CERT_REQUIRED`. However, it is in itself not sufficient; you also have to " +"check that the server certificate, which can be obtained by calling :meth:" +"`SSLSocket.getpeercert`, matches the desired service. For many protocols " +"and applications, the service can be identified by the hostname. This common " +"check is automatically performed when :attr:`SSLContext.check_hostname` is " +"enabled." msgstr "" -#: ../../library/ssl.rst:2723 +#: ../../library/ssl.rst:2724 msgid "" -"Hostname matchings is now performed by OpenSSL. Python no longer " -"uses :func:`match_hostname`." +"Hostname matchings is now performed by OpenSSL. Python no longer uses :func:" +"`match_hostname`." msgstr "" -#: ../../library/ssl.rst:2727 +#: ../../library/ssl.rst:2728 msgid "" "In server mode, if you want to authenticate your clients using the SSL layer " "(rather than using a higher-level authentication mechanism), you'll also " @@ -3922,20 +3900,20 @@ msgid "" "certificate." msgstr "" -#: ../../library/ssl.rst:2733 +#: ../../library/ssl.rst:2734 msgid "Protocol versions" msgstr "協定版本" -#: ../../library/ssl.rst:2735 +#: ../../library/ssl.rst:2736 msgid "" "SSL versions 2 and 3 are considered insecure and are therefore dangerous to " "use. If you want maximum compatibility between clients and servers, it is " -"recommended to use :const:`PROTOCOL_TLS_CLIENT` " -"or :const:`PROTOCOL_TLS_SERVER` as the protocol version. SSLv2 and SSLv3 are " -"disabled by default." +"recommended to use :const:`PROTOCOL_TLS_CLIENT` or :const:" +"`PROTOCOL_TLS_SERVER` as the protocol version. SSLv2 and SSLv3 are disabled " +"by default." msgstr "" -#: ../../library/ssl.rst:2743 +#: ../../library/ssl.rst:2744 msgid "" ">>> client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n" ">>> client_context.minimum_version = ssl.TLSVersion.TLSv1_3\n" @@ -3945,36 +3923,36 @@ msgstr "" ">>> client_context.minimum_version = ssl.TLSVersion.TLSv1_3\n" ">>> client_context.maximum_version = ssl.TLSVersion.TLSv1_3" -#: ../../library/ssl.rst:2748 +#: ../../library/ssl.rst:2749 msgid "" "The SSL context created above will only allow TLSv1.3 and later (if " -"supported by your system) connections to a " -"server. :const:`PROTOCOL_TLS_CLIENT` implies certificate validation and " -"hostname checks by default. You have to load certificates into the context." +"supported by your system) connections to a server. :const:" +"`PROTOCOL_TLS_CLIENT` implies certificate validation and hostname checks by " +"default. You have to load certificates into the context." msgstr "" -#: ../../library/ssl.rst:2755 +#: ../../library/ssl.rst:2756 msgid "Cipher selection" msgstr "" -#: ../../library/ssl.rst:2757 +#: ../../library/ssl.rst:2758 msgid "" "If you have advanced security requirements, fine-tuning of the ciphers " -"enabled when negotiating a SSL session is possible through " -"the :meth:`SSLContext.set_ciphers` method. Starting from Python 3.2.3, the " -"ssl module disables certain weak ciphers by default, but you may want to " -"further restrict the cipher choice. Be sure to read OpenSSL's documentation " -"about the `cipher list format `_. If you want to check which ciphers are enabled by a " -"given cipher list, use :meth:`SSLContext.get_ciphers` or the ``openssl " -"ciphers`` command on your system." +"enabled when negotiating a SSL session is possible through the :meth:" +"`SSLContext.set_ciphers` method. Starting from Python 3.2.3, the ssl module " +"disables certain weak ciphers by default, but you may want to further " +"restrict the cipher choice. Be sure to read OpenSSL's documentation about " +"the `cipher list format `_. If you want to check which ciphers are enabled by a given " +"cipher list, use :meth:`SSLContext.get_ciphers` or the ``openssl ciphers`` " +"command on your system." msgstr "" -#: ../../library/ssl.rst:2768 +#: ../../library/ssl.rst:2769 msgid "Multi-processing" msgstr "" -#: ../../library/ssl.rst:2770 +#: ../../library/ssl.rst:2771 msgid "" "If using this module as part of a multi-processed application (using, for " "example the :mod:`multiprocessing` or :mod:`concurrent.futures` modules), be " @@ -3985,32 +3963,32 @@ msgid "" "sufficient." msgstr "" -#: ../../library/ssl.rst:2782 +#: ../../library/ssl.rst:2783 msgid "TLS 1.3" msgstr "TLS 1.3" -#: ../../library/ssl.rst:2786 +#: ../../library/ssl.rst:2787 msgid "" "The TLS 1.3 protocol behaves slightly differently than previous version of " "TLS/SSL. Some new TLS 1.3 features are not yet available." msgstr "" -#: ../../library/ssl.rst:2789 +#: ../../library/ssl.rst:2790 msgid "" "TLS 1.3 uses a disjunct set of cipher suites. All AES-GCM and ChaCha20 " -"cipher suites are enabled by default. The " -"method :meth:`SSLContext.set_ciphers` cannot enable or disable any TLS 1.3 " -"ciphers yet, but :meth:`SSLContext.get_ciphers` returns them." +"cipher suites are enabled by default. The method :meth:`SSLContext." +"set_ciphers` cannot enable or disable any TLS 1.3 ciphers yet, but :meth:" +"`SSLContext.get_ciphers` returns them." msgstr "" -#: ../../library/ssl.rst:2793 +#: ../../library/ssl.rst:2794 msgid "" "Session tickets are no longer sent as part of the initial handshake and are " "handled differently. :attr:`SSLSocket.session` and :class:`SSLSession` are " "not compatible with TLS 1.3." msgstr "" -#: ../../library/ssl.rst:2796 +#: ../../library/ssl.rst:2797 msgid "" "Client-side certificates are also no longer verified during the initial " "handshake. A server can request a certificate at any time. Clients process " @@ -4018,21 +3996,21 @@ msgid "" "server." msgstr "" -#: ../../library/ssl.rst:2800 +#: ../../library/ssl.rst:2801 msgid "" "TLS 1.3 features like early data, deferred TLS client cert request, " "signature algorithm configuration, and rekeying are not supported yet." msgstr "" -#: ../../library/ssl.rst:2806 +#: ../../library/ssl.rst:2807 msgid "Class :class:`socket.socket`" msgstr ":class:`socket.socket` 類別" -#: ../../library/ssl.rst:2807 +#: ../../library/ssl.rst:2808 msgid "Documentation of underlying :mod:`socket` class" msgstr "底層 :mod:`socket` 類別的文件" -#: ../../library/ssl.rst:2809 +#: ../../library/ssl.rst:2810 msgid "" "`SSL/TLS Strong Encryption: An Introduction `_" @@ -4040,11 +4018,11 @@ msgstr "" "`SSL/TLS Strong Encryption: An Introduction `_" -#: ../../library/ssl.rst:2810 +#: ../../library/ssl.rst:2811 msgid "Intro from the Apache HTTP Server documentation" msgstr "Apache HTTP Server 文件的介紹" -#: ../../library/ssl.rst:2812 +#: ../../library/ssl.rst:2813 msgid "" ":rfc:`RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: " "Certificate-Based Key Management <1422>`" @@ -4052,19 +4030,19 @@ msgstr "" ":rfc:`RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: " "Certificate-Based Key Management <1422>`" -#: ../../library/ssl.rst:2813 +#: ../../library/ssl.rst:2814 msgid "Steve Kent" msgstr "Steve Kent" -#: ../../library/ssl.rst:2815 +#: ../../library/ssl.rst:2816 msgid ":rfc:`RFC 4086: Randomness Requirements for Security <4086>`" msgstr ":rfc:`RFC 4086: Randomness Requirements for Security <4086>`" -#: ../../library/ssl.rst:2816 +#: ../../library/ssl.rst:2817 msgid "Donald E., Jeffrey I. Schiller" msgstr "Donald E., Jeffrey I. Schiller" -#: ../../library/ssl.rst:2818 +#: ../../library/ssl.rst:2819 msgid "" ":rfc:`RFC 5280: Internet X.509 Public Key Infrastructure Certificate and " "Certificate Revocation List (CRL) Profile <5280>`" @@ -4072,11 +4050,11 @@ msgstr "" ":rfc:`RFC 5280: Internet X.509 Public Key Infrastructure Certificate and " "Certificate Revocation List (CRL) Profile <5280>`" -#: ../../library/ssl.rst:2819 +#: ../../library/ssl.rst:2820 msgid "D. Cooper" msgstr "D. Cooper" -#: ../../library/ssl.rst:2821 +#: ../../library/ssl.rst:2822 msgid "" ":rfc:`RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2 " "<5246>`" @@ -4084,19 +4062,19 @@ msgstr "" ":rfc:`RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2 " "<5246>`" -#: ../../library/ssl.rst:2822 +#: ../../library/ssl.rst:2823 msgid "T. Dierks et. al." msgstr "T. Dierks et. al." -#: ../../library/ssl.rst:2824 +#: ../../library/ssl.rst:2825 msgid ":rfc:`RFC 6066: Transport Layer Security (TLS) Extensions <6066>`" msgstr ":rfc:`RFC 6066: Transport Layer Security (TLS) Extensions <6066>`" -#: ../../library/ssl.rst:2825 +#: ../../library/ssl.rst:2826 msgid "D. Eastlake" msgstr "D. Eastlake" -#: ../../library/ssl.rst:2827 +#: ../../library/ssl.rst:2828 msgid "" "`IANA TLS: Transport Layer Security (TLS) Parameters `_" @@ -4104,11 +4082,11 @@ msgstr "" "`IANA TLS: Transport Layer Security (TLS) Parameters `_" -#: ../../library/ssl.rst:2828 +#: ../../library/ssl.rst:2829 msgid "IANA" msgstr "IANA" -#: ../../library/ssl.rst:2830 +#: ../../library/ssl.rst:2831 msgid "" ":rfc:`RFC 7525: Recommendations for Secure Use of Transport Layer Security " "(TLS) and Datagram Transport Layer Security (DTLS) <7525>`" @@ -4116,11 +4094,11 @@ msgstr "" ":rfc:`RFC 7525: Recommendations for Secure Use of Transport Layer Security " "(TLS) and Datagram Transport Layer Security (DTLS) <7525>`" -#: ../../library/ssl.rst:2831 +#: ../../library/ssl.rst:2832 msgid "IETF" msgstr "IETF" -#: ../../library/ssl.rst:2833 +#: ../../library/ssl.rst:2834 msgid "" "`Mozilla's Server Side TLS recommendations `_" @@ -4128,7 +4106,7 @@ msgstr "" "`Mozilla's Server Side TLS recommendations `_" -#: ../../library/ssl.rst:2834 +#: ../../library/ssl.rst:2835 msgid "Mozilla" msgstr "Mozilla" @@ -4156,10 +4134,10 @@ msgstr "Transport Layer Security(傳輸層安全)" msgid "Secure Sockets Layer" msgstr "Secure Sockets Layer(安全 socket 層)" -#: ../../library/ssl.rst:2145 +#: ../../library/ssl.rst:2146 msgid "certificates" msgstr "certificates(憑證)" -#: ../../library/ssl.rst:2147 +#: ../../library/ssl.rst:2148 msgid "X509 certificate" msgstr "X509 certificate(X509 憑證)" diff --git a/whatsnew/3.13.po b/whatsnew/3.13.po index 8b558be690..7bdbfa7ed2 100644 --- a/whatsnew/3.13.po +++ b/whatsnew/3.13.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-03 00:17+0000\n" +"POT-Creation-Date: 2025-08-20 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1305,9 +1305,9 @@ msgstr "" #: ../../whatsnew/3.13.rst:845 msgid "" -"Allow removing all items from the database through the new :meth:`.gdbm." -"clear` and :meth:`.ndbm.clear` methods. (Contributed by Donghee Na in :gh:" -"`107122`.)" +"Allow removing all items from the database through the new :meth:`!clear` " +"methods of the GDBM and NDBM database objects. (Contributed by Donghee Na " +"in :gh:`107122`.)" msgstr "" #: ../../whatsnew/3.13.rst:851 From 38b914c0e6e79781958e6d09ff74eecea64626fd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 21 Aug 2025 00:16:24 +0000 Subject: [PATCH 20/23] sync with cpython c04b3de5 --- library/dataclasses.po | 264 +++++++++++++++++++++-------------------- library/logging.po | 4 +- 2 files changed, 138 insertions(+), 130 deletions(-) diff --git a/library/dataclasses.po b/library/dataclasses.po index b1863227bc..9faa4efe7b 100644 --- a/library/dataclasses.po +++ b/library/dataclasses.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-21 00:15+0000\n" "PO-Revision-Date: 2023-02-11 15:02+0800\n" "Last-Translator: \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -331,15 +331,23 @@ msgstr "" #, fuzzy msgid "" "*frozen*: If true (the default is ``False``), assigning to fields will " -"generate an exception. This emulates read-only frozen instances. If :meth:" -"`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the " -"class, then :exc:`TypeError` is raised. See the discussion below." +"generate an exception. This emulates read-only frozen instances. See the :" +"ref:`discussion ` below." msgstr "" "*frozen*:如果為真(預設為 ``False``),分配給欄位將產生例外。這模擬了只讀的" "凍結實例。如果 :meth:`~object.__setattr__` 或 :meth:`~object.__delattr__` 在" "類別中定義,則 :exc:`TypeError` 被引發。請參閱下面的討論。" -#: ../../library/dataclasses.rst:168 +#: ../../library/dataclasses.rst:167 +#, fuzzy +msgid "" +"If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in " +"the class and *frozen* is true, then :exc:`TypeError` is raised." +msgstr "" +"當在使用 frozen=True 定義的資料類別上呼叫隱式定義的 :meth:`__setattr__` 或 :" +"meth:`__delattr__` 時引發。它是 :exc:`AttributeError` 的子類別。" + +#: ../../library/dataclasses.rst:170 #, fuzzy msgid "" "*match_args*: If true (the default is ``True``), the :attr:`~object." @@ -354,7 +362,7 @@ msgstr "" "成,見上文)。如果為 false,或者類別中已經定義了 :attr:`!__match_args__`,則" "不會生成 :attr:`!__match_args__`。" -#: ../../library/dataclasses.rst:177 +#: ../../library/dataclasses.rst:179 #, fuzzy msgid "" "*kw_only*: If true (the default value is ``False``), then all fields will be " @@ -370,11 +378,11 @@ msgstr "" "類別的任何其他方面都沒有影響。有關詳細資訊,請參閱 :term:`parameter` 詞彙表條" "目。另請參閱 :const:`KW_ONLY` 部分。" -#: ../../library/dataclasses.rst:185 +#: ../../library/dataclasses.rst:187 msgid "Keyword-only fields are not included in :attr:`!__match_args__`." msgstr "" -#: ../../library/dataclasses.rst:189 +#: ../../library/dataclasses.rst:191 #, fuzzy msgid "" "*slots*: If true (the default is ``False``), :attr:`~object.__slots__` " @@ -386,7 +394,7 @@ msgstr "" "屬性並回傳新類別而不是原始類別。如果 :attr:`!__slots__` 已經在類別中定義," "則 :exc:`TypeError` 被引發。" -#: ../../library/dataclasses.rst:195 +#: ../../library/dataclasses.rst:197 #, fuzzy msgid "" "Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result " @@ -398,7 +406,7 @@ msgstr "" "屬性並回傳新類別而不是原始類別。如果 :attr:`!__slots__` 已經在類別中定義," "則 :exc:`TypeError` 被引發。" -#: ../../library/dataclasses.rst:202 +#: ../../library/dataclasses.rst:204 msgid "" "Passing parameters to a base class :meth:`~object.__init_subclass__` when " "using ``slots=True`` will result in a :exc:`TypeError`. Either use " @@ -406,7 +414,7 @@ msgid "" "workaround. See :gh:`91126` for full details." msgstr "" -#: ../../library/dataclasses.rst:210 +#: ../../library/dataclasses.rst:212 #, fuzzy msgid "" "If a field name is already included in the :attr:`!__slots__` of a base " @@ -422,7 +430,7 @@ msgstr "" "夠確定繼承的插槽,基底類別 :attr:`!__slots__` 可以是任何可疊代的,但*不是*疊" "代器。" -#: ../../library/dataclasses.rst:220 +#: ../../library/dataclasses.rst:222 #, fuzzy msgid "" "*weakref_slot*: If true (the default is ``False``), add a slot named " @@ -434,14 +442,14 @@ msgstr "" "插槽,這是使實例可弱引用所必需的。在沒有指定 ``slots=True`` 的情況下指定 " "``weakref_slot=True`` 是錯誤的。" -#: ../../library/dataclasses.rst:228 +#: ../../library/dataclasses.rst:230 #, fuzzy msgid "" "``field``\\s may optionally specify a default value, using normal Python " "syntax::" msgstr "``field``\\s 可以選擇指定一個預設值,使用普通的 Python 語法: ::" -#: ../../library/dataclasses.rst:231 +#: ../../library/dataclasses.rst:233 msgid "" "@dataclass\n" "class C:\n" @@ -449,7 +457,7 @@ msgid "" " b: int = 0 # assign a default value for 'b'" msgstr "" -#: ../../library/dataclasses.rst:236 +#: ../../library/dataclasses.rst:238 #, fuzzy msgid "" "In this example, both :attr:`!a` and :attr:`!b` will be included in the " @@ -458,11 +466,11 @@ msgstr "" "在此示例中,:attr:`!a` 和 :attr:`!b` 都將包含在新增的 :meth:`~object." "__init__` 方法中,該方法將定義為: ::" -#: ../../library/dataclasses.rst:239 +#: ../../library/dataclasses.rst:241 msgid "def __init__(self, a: int, b: int = 0):" msgstr "def __init__(self, a: int, b: int = 0):" -#: ../../library/dataclasses.rst:241 +#: ../../library/dataclasses.rst:243 #, fuzzy msgid "" ":exc:`TypeError` will be raised if a field without a default value follows a " @@ -472,7 +480,7 @@ msgstr "" ":exc:`TypeError` 如果沒有預設值的欄位跟在具有預設值的欄位之後,將引發。無論這" "發生在單個類別中還是作為類別繼承的結果,都是如此。" -#: ../../library/dataclasses.rst:247 +#: ../../library/dataclasses.rst:249 #, fuzzy msgid "" "For common and simple use cases, no other functionality is required. There " @@ -485,7 +493,7 @@ msgstr "" "位資訊。為了滿足這種對附加資訊的需求,你可以通過呼叫提供的 :func:`!field` 函" "式來替換預設欄位值。例如: ::" -#: ../../library/dataclasses.rst:253 +#: ../../library/dataclasses.rst:255 msgid "" "@dataclass\n" "class C:\n" @@ -501,7 +509,7 @@ msgstr "" "c = C()\n" "c.mylist += [1, 2, 3]" -#: ../../library/dataclasses.rst:260 +#: ../../library/dataclasses.rst:262 #, fuzzy msgid "" "As shown above, the :const:`MISSING` value is a sentinel object used to " @@ -513,11 +521,11 @@ msgstr "" "供。使用此標記是因為 ``None`` 對於某些具有不同含義的參數是有效值。任何程式碼" "都不應直接使用 :const:`MISSING` 值。" -#: ../../library/dataclasses.rst:265 +#: ../../library/dataclasses.rst:267 msgid "The parameters to :func:`!field` are:" msgstr ":func:`!field` 的參數是:" -#: ../../library/dataclasses.rst:267 +#: ../../library/dataclasses.rst:269 #, fuzzy msgid "" "*default*: If provided, this will be the default value for this field. This " @@ -527,7 +535,7 @@ msgstr "" "*default*:如果提供,這將是該欄位的預設值。這是必需的,因為 :meth:`!field` 呼" "叫本身會替換預設值的正常位置。" -#: ../../library/dataclasses.rst:271 +#: ../../library/dataclasses.rst:273 #, fuzzy msgid "" "*default_factory*: If provided, it must be a zero-argument callable that " @@ -540,7 +548,7 @@ msgstr "" "時將被呼叫。除其他用途外,這可用於指定具有可變預設值的欄位,如下所述。同時指" "定 *default* 和 *default_factory* 是錯誤的。" -#: ../../library/dataclasses.rst:277 +#: ../../library/dataclasses.rst:279 #, fuzzy msgid "" "*init*: If true (the default), this field is included as a parameter to the " @@ -549,7 +557,7 @@ msgstr "" "*init*:如果為 true(預設值),則此欄位將作為生成的 :meth:`~object.__init__` " "方法的參數包含在內。" -#: ../../library/dataclasses.rst:280 +#: ../../library/dataclasses.rst:282 #, fuzzy msgid "" "*repr*: If true (the default), this field is included in the string returned " @@ -558,7 +566,7 @@ msgstr "" "*repr*:如果為真(預設值),則此欄位包含在生成的 :meth:`~object.__repr__` 方" "法回傳的字串中。" -#: ../../library/dataclasses.rst:283 +#: ../../library/dataclasses.rst:285 #, fuzzy msgid "" "*hash*: This can be a bool or ``None``. If true, this field is included in " @@ -574,7 +582,7 @@ msgstr "" "是預期的行為。如果一個欄位用於比較,則應在雜湊中考慮該欄位。不鼓勵將此值設定" "為 ``None`` 以外的任何值。" -#: ../../library/dataclasses.rst:291 +#: ../../library/dataclasses.rst:293 #, fuzzy msgid "" "One possible reason to set ``hash=False`` but ``compare=True`` would be if a " @@ -587,7 +595,7 @@ msgstr "" "湊值的成本很高,則需要該欄位進行相等性測試,並且還有其他欄位有助於型別的雜湊" "值。即使一個欄位被排除在雜湊之外,它仍然會被用於比較。" -#: ../../library/dataclasses.rst:297 +#: ../../library/dataclasses.rst:299 #, fuzzy msgid "" "*compare*: If true (the default), this field is included in the generated " @@ -597,7 +605,7 @@ msgstr "" "*compare*:如果為真(預設值),則此欄位包含在生成的相等和比較方法中(:meth:" "`~object.__eq__`、:meth:`~object.__gt__` 等)。" -#: ../../library/dataclasses.rst:301 +#: ../../library/dataclasses.rst:303 #, fuzzy msgid "" "*metadata*: This can be a mapping or ``None``. ``None`` is treated as an " @@ -612,7 +620,7 @@ msgstr "" "不被資料類別使用,而是作為第三方擴充機制提供的。多個第三方可以各自擁有自己的" "密鑰,用作元資料中的命名空間。" -#: ../../library/dataclasses.rst:309 +#: ../../library/dataclasses.rst:311 #, fuzzy msgid "" "*kw_only*: If true, this field will be marked as keyword-only. This is used " @@ -621,11 +629,11 @@ msgstr "" "*kw_only*:如果為真,該欄位將被標記為僅限關鍵字。這在計算生成的 :meth:" "`~object.__init__` 方法的參數時使用。" -#: ../../library/dataclasses.rst:313 +#: ../../library/dataclasses.rst:315 msgid "Keyword-only fields are also not included in :attr:`!__match_args__`." msgstr "" -#: ../../library/dataclasses.rst:317 +#: ../../library/dataclasses.rst:319 #, fuzzy msgid "" "If the default value of a field is specified by a call to :func:`!field`, " @@ -641,7 +649,7 @@ msgstr "" "在 :func:`@dataclass ` 裝飾器運行後,類別屬性將全部包含欄位的預設" "值,就像預設值本身已指定一樣。例如,在: ::" -#: ../../library/dataclasses.rst:326 +#: ../../library/dataclasses.rst:328 msgid "" "@dataclass\n" "class C:\n" @@ -657,7 +665,7 @@ msgstr "" " z: int = field(repr=False, default=10)\n" " t: int = 20" -#: ../../library/dataclasses.rst:333 +#: ../../library/dataclasses.rst:335 #, fuzzy msgid "" "The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!" @@ -667,7 +675,7 @@ msgstr "" "類別屬性 :attr:`!C.z` 將為 ``10``,類別屬性 :attr:`!C.t` 將為 ``20``,類別屬" "性 :attr:`!C.x` 和 :attr:`!C.y` 將不會放。" -#: ../../library/dataclasses.rst:339 +#: ../../library/dataclasses.rst:341 #, fuzzy msgid "" ":class:`!Field` objects describe each defined field. These objects are " @@ -679,15 +687,15 @@ msgstr "" "`fields` 模組級方法回傳(見下文)。使用者不應該直接實例化 :class:`!Field` 物" "件。它記錄的屬性是:" -#: ../../library/dataclasses.rst:344 +#: ../../library/dataclasses.rst:346 msgid ":attr:`!name`: The name of the field." msgstr ":attr:`!name`:欄位的名稱。" -#: ../../library/dataclasses.rst:345 +#: ../../library/dataclasses.rst:347 msgid ":attr:`!type`: The type of the field." msgstr ":attr:`!type`:欄位的型別。" -#: ../../library/dataclasses.rst:346 +#: ../../library/dataclasses.rst:348 #, fuzzy msgid "" ":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :" @@ -698,14 +706,14 @@ msgstr "" "attr:`!hash`、:attr:`!compare`, :attr:`!metadata` 和 :attr:`!kw_only` 有與它" "們在 :func:`field` 函式中的含義和值相同。" -#: ../../library/dataclasses.rst:350 +#: ../../library/dataclasses.rst:352 #, fuzzy msgid "" "Other attributes may exist, but they are private and must not be inspected " "or relied on." msgstr "可能存在其他屬性,但它們是私有的,不得檢查或依賴。" -#: ../../library/dataclasses.rst:355 +#: ../../library/dataclasses.rst:357 msgid "" "``InitVar[T]`` type annotations describe variables that are :ref:`init-only " "`. Fields annotated with :class:`!InitVar` " @@ -714,7 +722,7 @@ msgid "" "meth:`~object.__init__` and an optional :meth:`__post_init__`." msgstr "" -#: ../../library/dataclasses.rst:364 +#: ../../library/dataclasses.rst:366 #, fuzzy msgid "" "Returns a tuple of :class:`Field` objects that define the fields for this " @@ -726,7 +734,7 @@ msgstr "" "實例。如果未傳遞資料類別或其中一個實例,則引發 :exc:`TypeError`。不回傳 " "``ClassVar`` 或 ``InitVar`` 的偽欄位。" -#: ../../library/dataclasses.rst:371 +#: ../../library/dataclasses.rst:373 #, fuzzy msgid "" "Converts the dataclass *obj* to a dict (by using the factory function " @@ -738,12 +746,12 @@ msgstr "" "都被轉換為其欄位的字典,作為 ``name: value`` 對。資料類別、字典、列表和元組被" "遞迴到。其他物件使用 :func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:377 +#: ../../library/dataclasses.rst:379 #, fuzzy msgid "Example of using :func:`!asdict` on nested dataclasses::" msgstr "在嵌套資料類別上使用 :func:`!asdict` 的範例: ::" -#: ../../library/dataclasses.rst:379 +#: ../../library/dataclasses.rst:381 msgid "" "@dataclass\n" "class Point:\n" @@ -775,22 +783,22 @@ msgstr "" "c = C([Point(0, 0), Point(10, 4)])\n" "assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}" -#: ../../library/dataclasses.rst:394 ../../library/dataclasses.rst:414 +#: ../../library/dataclasses.rst:396 ../../library/dataclasses.rst:416 #, fuzzy msgid "To create a shallow copy, the following workaround may be used::" msgstr "要建立淺複製,可以使用以下解決方法:" -#: ../../library/dataclasses.rst:396 +#: ../../library/dataclasses.rst:398 msgid "{field.name: getattr(obj, field.name) for field in fields(obj)}" msgstr "" -#: ../../library/dataclasses.rst:398 +#: ../../library/dataclasses.rst:400 #, fuzzy msgid "" ":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance." msgstr ":func:`!asdict` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:403 +#: ../../library/dataclasses.rst:405 #, fuzzy msgid "" "Converts the dataclass *obj* to a tuple (by using the factory function " @@ -802,11 +810,11 @@ msgstr "" "都被轉換為其欄位值的元組。資料類別、字典、列表和元組被遞迴到。其他物件使用 :" "func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:409 +#: ../../library/dataclasses.rst:411 msgid "Continuing from the previous example::" msgstr "從前面的例子繼續: ::" -#: ../../library/dataclasses.rst:411 +#: ../../library/dataclasses.rst:413 msgid "" "assert astuple(p) == (10, 20)\n" "assert astuple(c) == ([(0, 0), (10, 4)],)" @@ -814,11 +822,11 @@ msgstr "" "assert astuple(p) == (10, 20)\n" "assert astuple(c) == ([(0, 0), (10, 4)],)" -#: ../../library/dataclasses.rst:416 +#: ../../library/dataclasses.rst:418 msgid "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" msgstr "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" -#: ../../library/dataclasses.rst:418 +#: ../../library/dataclasses.rst:420 #, fuzzy msgid "" ":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass " @@ -826,7 +834,7 @@ msgid "" msgstr "" ":func:`!astuple` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:423 +#: ../../library/dataclasses.rst:425 #, fuzzy msgid "" "Creates a new dataclass with name *cls_name*, fields as defined in *fields*, " @@ -846,13 +854,13 @@ msgstr "" "``kw_only`` 的值, ``slots`` 和 ``weakref_slot`` 與它們在 :func:`dataclass` 中" "的含義相同。" -#: ../../library/dataclasses.rst:433 +#: ../../library/dataclasses.rst:435 msgid "" "If *module* is defined, the :attr:`!__module__` attribute of the dataclass " "is set to that value. By default, it is set to the module name of the caller." msgstr "" -#: ../../library/dataclasses.rst:437 +#: ../../library/dataclasses.rst:439 #, fuzzy msgid "" "This function is not strictly required, because any Python mechanism for " @@ -864,7 +872,7 @@ msgstr "" "機制都可以應用 :func:`dataclass` 函式將該類別轉換為資料類別。提供此功能是為了" "方便。例如: ::" -#: ../../library/dataclasses.rst:443 +#: ../../library/dataclasses.rst:445 msgid "" "C = make_dataclass('C',\n" " [('x', int),\n" @@ -878,11 +886,11 @@ msgstr "" " ('z', int, field(default=5))],\n" " namespace={'add_one': lambda self: self.x + 1})" -#: ../../library/dataclasses.rst:449 +#: ../../library/dataclasses.rst:451 msgid "Is equivalent to::" msgstr "相當於: ::" -#: ../../library/dataclasses.rst:451 +#: ../../library/dataclasses.rst:453 msgid "" "@dataclass\n" "class C:\n" @@ -894,7 +902,7 @@ msgid "" " return self.x + 1" msgstr "" -#: ../../library/dataclasses.rst:462 +#: ../../library/dataclasses.rst:464 #, fuzzy msgid "" "Creates a new object of the same type as *obj*, replacing fields with values " @@ -906,7 +914,7 @@ msgstr "" "``obj`` 不是資料類別,則引發 :exc:`TypeError`。如果 ``changes`` 中的值未指定" "欄位,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:467 +#: ../../library/dataclasses.rst:469 #, fuzzy msgid "" "The newly returned object is created by calling the :meth:`~object.__init__` " @@ -916,7 +924,7 @@ msgstr "" "新回傳的對像是通過呼叫資料類別的 :meth:`~object.__init__` 方法建立的。這確" "保 :meth:`__post_init__`(如果存在)也被呼叫。" -#: ../../library/dataclasses.rst:471 +#: ../../library/dataclasses.rst:473 #, fuzzy msgid "" "Init-only variables without default values, if any exist, must be specified " @@ -926,7 +934,7 @@ msgstr "" "沒有預設值的僅初始化變數(如果存在)必須在呼叫 :func:`replace` 時指定,以便它" "們可以傳遞給 :meth:`__init__` 和 :meth:`__post_init__`。" -#: ../../library/dataclasses.rst:475 +#: ../../library/dataclasses.rst:477 #, fuzzy msgid "" "It is an error for *changes* to contain any fields that are defined as " @@ -935,7 +943,7 @@ msgstr "" "*changes* 包含任何定義為具有 ``init=False`` 的欄位是錯誤的。在這種情況下將引" "發 :exc:`ValueError`。" -#: ../../library/dataclasses.rst:479 +#: ../../library/dataclasses.rst:481 #, fuzzy msgid "" "Be forewarned about how ``init=False`` fields work during a call to :func:`!" @@ -952,13 +960,13 @@ msgstr "" "建構函式可能是明智的,或者可能是處理實例複製的自定義:func:`!replace` (或類似" "命名的)方法。" -#: ../../library/dataclasses.rst:488 +#: ../../library/dataclasses.rst:490 msgid "" "Dataclass instances are also supported by generic function :func:`copy." "replace`." msgstr "" -#: ../../library/dataclasses.rst:492 +#: ../../library/dataclasses.rst:494 #, fuzzy msgid "" "Return ``True`` if its parameter is a dataclass (including subclasses of a " @@ -966,7 +974,7 @@ msgid "" msgstr "" "如果它的參數是一個資料類別或一個實例,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/dataclasses.rst:495 +#: ../../library/dataclasses.rst:497 #, fuzzy msgid "" "If you need to know if a class is an instance of a dataclass (and not a " @@ -976,18 +984,18 @@ msgstr "" "如果你需要知道一個類別是否是資料類別的實例(而不是資料類別本身),那麼新增一" "個進一步的檢查 ``not isinstance(obj, type)``: ::" -#: ../../library/dataclasses.rst:499 +#: ../../library/dataclasses.rst:501 msgid "" "def is_dataclass_instance(obj):\n" " return is_dataclass(obj) and not isinstance(obj, type)" msgstr "" -#: ../../library/dataclasses.rst:504 +#: ../../library/dataclasses.rst:506 #, fuzzy msgid "A sentinel value signifying a missing default or default_factory." msgstr "表示缺少 default 或 default_factory 的標記值。" -#: ../../library/dataclasses.rst:508 +#: ../../library/dataclasses.rst:510 #, fuzzy msgid "" "A sentinel value used as a type annotation. Any fields after a pseudo-field " @@ -1003,14 +1011,14 @@ msgstr "" "類欄位的名稱。按照慣例,名稱 ``_`` 用於 :const:`!KW_ONLY` 欄位。僅關鍵字欄位" "表示 :meth:`~object.__init__` 參數,在實例化類別時必須將其指定為關鍵字。" -#: ../../library/dataclasses.rst:517 +#: ../../library/dataclasses.rst:519 #, fuzzy msgid "" "In this example, the fields ``y`` and ``z`` will be marked as keyword-only " "fields::" msgstr "在此示例中,欄位 ``y`` 和 ``z`` 將被標記為僅關鍵字欄位: ::" -#: ../../library/dataclasses.rst:519 +#: ../../library/dataclasses.rst:521 msgid "" "@dataclass\n" "class Point:\n" @@ -1030,14 +1038,14 @@ msgstr "" "\n" "p = Point(0, y=1.5, z=2.0)" -#: ../../library/dataclasses.rst:528 +#: ../../library/dataclasses.rst:530 #, fuzzy msgid "" "In a single dataclass, it is an error to specify more than one field whose " "type is :const:`!KW_ONLY`." msgstr "在單個資料類別中,指定多個型別為 :const:`!KW_ONLY` 的欄位是錯誤的。" -#: ../../library/dataclasses.rst:535 +#: ../../library/dataclasses.rst:537 #, fuzzy msgid "" "Raised when an implicitly defined :meth:`~object.__setattr__` or :meth:" @@ -1047,12 +1055,12 @@ msgstr "" "當在使用 frozen=True 定義的資料類別上呼叫隱式定義的 :meth:`__setattr__` 或 :" "meth:`__delattr__` 時引發。它是 :exc:`AttributeError` 的子類別。" -#: ../../library/dataclasses.rst:542 +#: ../../library/dataclasses.rst:544 #, fuzzy msgid "Post-init processing" msgstr "初始化後處理" -#: ../../library/dataclasses.rst:546 +#: ../../library/dataclasses.rst:548 #, fuzzy msgid "" "When defined on the class, it will be called by the generated :meth:`~object." @@ -1068,14 +1076,14 @@ msgstr "" "將按照它們在類別中定義的順序傳遞給 :meth:`!__post_init__` 。如果沒有生成 :" "meth:`!__init__` 方法,那麼 :meth:`!__post_init__` 將不會被自動呼叫。" -#: ../../library/dataclasses.rst:553 +#: ../../library/dataclasses.rst:555 #, fuzzy msgid "" "Among other uses, this allows for initializing field values that depend on " "one or more other fields. For example::" msgstr "在其他用途中,這允許初始化依賴於一個或多個其他欄位的欄位值。例如: ::" -#: ../../library/dataclasses.rst:556 +#: ../../library/dataclasses.rst:558 msgid "" "@dataclass\n" "class C:\n" @@ -1095,7 +1103,7 @@ msgstr "" " def __post_init__(self):\n" " self.c = self.a + self.b" -#: ../../library/dataclasses.rst:565 +#: ../../library/dataclasses.rst:567 #, fuzzy msgid "" "The :meth:`~object.__init__` method generated by :func:`@dataclass " @@ -1107,7 +1115,7 @@ msgstr "" "類別 :meth:`!__init__` 方法。如果基底類別有一個必須呼叫的 :meth:`!__init__` " "方法,通常在 :meth:`__post_init__` 方法中呼叫此方法: ::" -#: ../../library/dataclasses.rst:570 +#: ../../library/dataclasses.rst:572 msgid "" "class Rectangle:\n" " def __init__(self, height, width):\n" @@ -1133,7 +1141,7 @@ msgstr "" " def __post_init__(self):\n" " super().__init__(self.side, self.side)" -#: ../../library/dataclasses.rst:582 +#: ../../library/dataclasses.rst:584 #, fuzzy msgid "" "Note, however, that in general the dataclass-generated :meth:`!__init__` " @@ -1143,7 +1151,7 @@ msgstr "" "但是請注意,通常不需要呼叫資料類別生成的 :meth:`!__init__` 方法,因為衍生資料" "類別將負責初始化作為資料類別本身的任何基底類別的所有欄位。" -#: ../../library/dataclasses.rst:586 +#: ../../library/dataclasses.rst:588 #, fuzzy msgid "" "See the section below on init-only variables for ways to pass parameters to :" @@ -1153,11 +1161,11 @@ msgstr "" "請參閱下面有關僅初始化變數的部分,了解將參數傳遞給 :meth:`!__post_init__` 的" "方法。另請參閱有關 :func:`replace` 如何處理 ``init=False`` 欄位的警告。" -#: ../../library/dataclasses.rst:593 +#: ../../library/dataclasses.rst:595 msgid "Class variables" msgstr "類別變數" -#: ../../library/dataclasses.rst:595 +#: ../../library/dataclasses.rst:597 #, fuzzy msgid "" "One of the few places where :func:`@dataclass ` actually inspects " @@ -1174,12 +1182,12 @@ msgstr "" "外,並被資料類別機制忽略。模組級 :func:`fields` 函式不會回傳此類別 " "``ClassVar`` 偽欄位。" -#: ../../library/dataclasses.rst:606 +#: ../../library/dataclasses.rst:608 #, fuzzy msgid "Init-only variables" msgstr "僅初始化變數" -#: ../../library/dataclasses.rst:608 +#: ../../library/dataclasses.rst:610 #, fuzzy msgid "" "Another place where :func:`@dataclass ` inspects a type " @@ -1199,14 +1207,14 @@ msgstr "" "的 :meth:`~object.__init__` 方法,並傳遞給可選的 :meth:`__post_init__` 方法。" "它們不被資料類別使用。" -#: ../../library/dataclasses.rst:618 +#: ../../library/dataclasses.rst:620 #, fuzzy msgid "" "For example, suppose a field will be initialized from a database, if a value " "is not provided when creating the class::" msgstr "例如,假設一個欄位將從資料庫中初始化,如果在建立類別時沒有提供值: ::" -#: ../../library/dataclasses.rst:621 +#: ../../library/dataclasses.rst:623 msgid "" "@dataclass\n" "class C:\n" @@ -1232,7 +1240,7 @@ msgstr "" "\n" "c = C(10, database=my_database)" -#: ../../library/dataclasses.rst:633 +#: ../../library/dataclasses.rst:635 #, fuzzy msgid "" "In this case, :func:`fields` will return :class:`Field` objects for :attr:`!" @@ -1241,11 +1249,11 @@ msgstr "" "在這種情況下,:func:`fields` 將為 :attr:`!i` 和 :attr:`!j` 回傳 :class:" "`Field` 物件,但不會為 :attr:`!database` 回傳。" -#: ../../library/dataclasses.rst:639 +#: ../../library/dataclasses.rst:641 msgid "Frozen instances" msgstr "凍結實例" -#: ../../library/dataclasses.rst:641 +#: ../../library/dataclasses.rst:643 #, fuzzy msgid "" "It is not possible to create truly immutable Python objects. However, by " @@ -1259,7 +1267,7 @@ msgstr "" "別將向類別新增 :meth:`~object.__setattr__` 和 :meth:`~object.__delattr__` 方" "法。這些方法在叫用時會引發 :exc:`FrozenInstanceError`。" -#: ../../library/dataclasses.rst:647 +#: ../../library/dataclasses.rst:649 #, fuzzy msgid "" "There is a tiny performance penalty when using ``frozen=True``: :meth:" @@ -1269,11 +1277,11 @@ msgstr "" "使用 ``frozen=True`` 時有一個微小的性能損失::meth:`~object.__init__` 不能使" "用簡單賦值來初始化欄位,必須使用 :meth:`!object.__setattr__`。" -#: ../../library/dataclasses.rst:656 +#: ../../library/dataclasses.rst:658 msgid "Inheritance" msgstr "繼承" -#: ../../library/dataclasses.rst:658 +#: ../../library/dataclasses.rst:660 #, fuzzy msgid "" "When the dataclass is being created by the :func:`@dataclass ` " @@ -1291,7 +1299,7 @@ msgstr "" "將自己的欄位新增到有序對映中。所有生成的方法都將使用這種組合的、計算的有序欄" "位對映。因為欄位是按插入順序排列的,所以衍生類別會覆蓋基底類別。一個例子: ::" -#: ../../library/dataclasses.rst:668 +#: ../../library/dataclasses.rst:670 msgid "" "@dataclass\n" "class Base:\n" @@ -1313,7 +1321,7 @@ msgstr "" " z: int = 10\n" " x: int = 15" -#: ../../library/dataclasses.rst:678 +#: ../../library/dataclasses.rst:680 #, fuzzy msgid "" "The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. " @@ -1323,23 +1331,23 @@ msgstr "" "最終的欄位列表按順序為 :attr:`!x`、:attr:`!y`、:attr:`!z`。:attr:`!x` 的最終" "型別是 :class:`int`,如類別 :class:`!C` 中指定的那樣。" -#: ../../library/dataclasses.rst:681 +#: ../../library/dataclasses.rst:683 #, fuzzy msgid "" "The generated :meth:`~object.__init__` method for :class:`!C` will look " "like::" msgstr "為 :class:`!C` 生成的 :meth:`~object.__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:683 +#: ../../library/dataclasses.rst:685 msgid "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" msgstr "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" -#: ../../library/dataclasses.rst:686 +#: ../../library/dataclasses.rst:688 #, fuzzy msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`" msgstr ":meth:`!__init__` 中僅關鍵字參數的重新排序" -#: ../../library/dataclasses.rst:688 +#: ../../library/dataclasses.rst:690 #, fuzzy msgid "" "After the parameters needed for :meth:`~object.__init__` are computed, any " @@ -1351,7 +1359,7 @@ msgstr "" "僅關鍵字)參數之後。這是如何在 Python 中實作僅關鍵字參數的要求:它們必須位於" "非僅關鍵字參數之後。" -#: ../../library/dataclasses.rst:694 +#: ../../library/dataclasses.rst:696 #, fuzzy msgid "" "In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are " @@ -1361,7 +1369,7 @@ msgstr "" "在此示例中,:attr:`!Base.y`、:attr:`!Base.w` 和 :attr:`!D.t` 是僅限關鍵字的欄" "位,:attr:`!Base.x` 和 :attr:`!D.z` 是常規欄位: ::" -#: ../../library/dataclasses.rst:697 +#: ../../library/dataclasses.rst:699 msgid "" "@dataclass\n" "class Base:\n" @@ -1387,12 +1395,12 @@ msgstr "" " z: int = 10\n" " t: int = field(kw_only=True, default=0)" -#: ../../library/dataclasses.rst:709 +#: ../../library/dataclasses.rst:711 #, fuzzy msgid "The generated :meth:`!__init__` method for :class:`!D` will look like::" msgstr "為 :class:`!D` 生成的 :meth:`!__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:711 +#: ../../library/dataclasses.rst:713 msgid "" "def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " "int = 0):" @@ -1400,7 +1408,7 @@ msgstr "" "def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " "int = 0):" -#: ../../library/dataclasses.rst:713 +#: ../../library/dataclasses.rst:715 #, fuzzy msgid "" "Note that the parameters have been re-ordered from how they appear in the " @@ -1410,18 +1418,18 @@ msgstr "" "請注意,參數已根據它們在欄位列表中的顯示方式重新排序:從常規欄位衍生的參數後" "跟從僅關鍵字欄位衍生的參數。" -#: ../../library/dataclasses.rst:717 +#: ../../library/dataclasses.rst:719 #, fuzzy msgid "" "The relative ordering of keyword-only parameters is maintained in the re-" "ordered :meth:`!__init__` parameter list." msgstr "僅關鍵字參數的相對順序在重新排序的 :meth:`!__init__` 參數列表中維護。" -#: ../../library/dataclasses.rst:722 +#: ../../library/dataclasses.rst:724 msgid "Default factory functions" msgstr "預設工廠函式" -#: ../../library/dataclasses.rst:724 +#: ../../library/dataclasses.rst:726 #, fuzzy msgid "" "If a :func:`field` specifies a *default_factory*, it is called with zero " @@ -1431,11 +1439,11 @@ msgstr "" "如果 :func:`field` 指定了 *default_factory*,當需要該欄位的預設值時,它會以零" "引數呼叫。例如,要建立列表的新實例,請使用: ::" -#: ../../library/dataclasses.rst:728 +#: ../../library/dataclasses.rst:730 msgid "mylist: list = field(default_factory=list)" msgstr "mylist: list = field(default_factory=list)" -#: ../../library/dataclasses.rst:730 +#: ../../library/dataclasses.rst:732 #, fuzzy msgid "" "If a field is excluded from :meth:`~object.__init__` (using ``init=False``) " @@ -1448,11 +1456,11 @@ msgstr "" "位還指定了 ``default_factory``,那麼預設工廠函式將始終從生成的 :meth:" "`__init__ 中呼叫`功能。發生這種情況是因為沒有其他方法可以為該欄位賦予初始值。" -#: ../../library/dataclasses.rst:737 +#: ../../library/dataclasses.rst:739 msgid "Mutable default values" msgstr "可變預設值" -#: ../../library/dataclasses.rst:739 +#: ../../library/dataclasses.rst:741 #, fuzzy msgid "" "Python stores default member variable values in class attributes. Consider " @@ -1460,7 +1468,7 @@ msgid "" msgstr "" "Python 將預設成員變數值儲存在類別屬性中。考慮這個例子,不使用資料類別: ::" -#: ../../library/dataclasses.rst:742 +#: ../../library/dataclasses.rst:744 msgid "" "class C:\n" " x = []\n" @@ -1486,7 +1494,7 @@ msgstr "" "assert o1.x == [1, 2]\n" "assert o1.x is o2.x" -#: ../../library/dataclasses.rst:754 +#: ../../library/dataclasses.rst:756 #, fuzzy msgid "" "Note that the two instances of class :class:`!C` share the same class " @@ -1495,12 +1503,12 @@ msgstr "" "請注意,類別 :class:`!C` 的兩個實例共享同一個類別變數 :attr:`!x`,正如預期的" "那樣。" -#: ../../library/dataclasses.rst:757 +#: ../../library/dataclasses.rst:759 #, fuzzy msgid "Using dataclasses, *if* this code was valid::" msgstr "使用資料類別,*如果*此程式碼有效: ::" -#: ../../library/dataclasses.rst:759 +#: ../../library/dataclasses.rst:761 msgid "" "@dataclass\n" "class D:\n" @@ -1514,11 +1522,11 @@ msgstr "" " def add(self, element):\n" " self.x.append(element)" -#: ../../library/dataclasses.rst:765 +#: ../../library/dataclasses.rst:767 msgid "it would generate code similar to::" msgstr "它會生成類似的程式碼: ::" -#: ../../library/dataclasses.rst:767 +#: ../../library/dataclasses.rst:769 msgid "" "class D:\n" " x = []\n" @@ -1538,7 +1546,7 @@ msgstr "" "\n" "assert D().x is D().x" -#: ../../library/dataclasses.rst:776 +#: ../../library/dataclasses.rst:778 #, fuzzy msgid "" "This has the same issue as the original example using class :class:`!C`. " @@ -1558,14 +1566,14 @@ msgstr "" "檢測到不可散列的預設參數,它將引發 :exc:`TypeError`。假設是如果一個值是不可散" "列的,那麼它就是可變的。這是一個部分解決方案,但它確實可以防止許多常見錯誤。" -#: ../../library/dataclasses.rst:787 +#: ../../library/dataclasses.rst:789 #, fuzzy msgid "" "Using default factory functions is a way to create new instances of mutable " "types as default values for fields::" msgstr "使用預設工廠函式是一種建立可變型別的新實例作為欄位預設值的方法: ::" -#: ../../library/dataclasses.rst:790 +#: ../../library/dataclasses.rst:792 msgid "" "@dataclass\n" "class D:\n" @@ -1579,7 +1587,7 @@ msgstr "" "\n" "assert D().x is not D().x" -#: ../../library/dataclasses.rst:796 +#: ../../library/dataclasses.rst:798 #, fuzzy msgid "" "Instead of looking for and disallowing objects of type :class:`list`, :class:" @@ -1589,12 +1597,12 @@ msgstr "" "不再查找和禁止型別為 :class:`list`、:class:`dict` 或 :class:`set` 的物件,現" "在不允許使用不可散列的對像作為預設值。不可散列性用於近似可變性。" -#: ../../library/dataclasses.rst:803 +#: ../../library/dataclasses.rst:805 #, fuzzy msgid "Descriptor-typed fields" msgstr "描述器型別的欄位" -#: ../../library/dataclasses.rst:805 +#: ../../library/dataclasses.rst:807 #, fuzzy msgid "" "Fields that are assigned :ref:`descriptor objects ` as their " @@ -1602,7 +1610,7 @@ msgid "" msgstr "" "指定為\\ :ref:`描述器物件 `\\ 作為預設值的欄位具有以下特殊行為:" -#: ../../library/dataclasses.rst:808 +#: ../../library/dataclasses.rst:810 #, fuzzy msgid "" "The value for the field passed to the dataclass's :meth:`~object.__init__` " @@ -1612,7 +1620,7 @@ msgstr "" "傳遞給資料類別的 :meth:`~object.__init__` 方法的欄位值被傳遞給描述器的 :meth:" "`~object.__set__` 方法,而不是覆蓋描述器物件。" -#: ../../library/dataclasses.rst:812 +#: ../../library/dataclasses.rst:814 #, fuzzy msgid "" "Similarly, when getting or setting the field, the descriptor's :meth:" @@ -1622,7 +1630,7 @@ msgstr "" "同樣,在取得或設定欄位時,將呼叫描述器的 :meth:`~object.__get__` 或 :meth:`!" "__set__` 方法,而不是回傳或覆蓋描述器物件。" -#: ../../library/dataclasses.rst:816 +#: ../../library/dataclasses.rst:818 #, fuzzy msgid "" "To determine whether a field contains a default value, :func:`@dataclass " @@ -1638,7 +1646,7 @@ msgstr "" "面,如果描述器在這種情況下引發 :exc:`AttributeError`,則不會為該欄位提供預設" "值。" -#: ../../library/dataclasses.rst:826 +#: ../../library/dataclasses.rst:828 msgid "" "class IntConversionDescriptor:\n" " def __init__(self, *, default):\n" @@ -1692,7 +1700,7 @@ msgstr "" "i.quantity_on_hand = 2.5 # 以 2.5 呼叫 __set__\n" "print(i.quantity_on_hand) # 2" -#: ../../library/dataclasses.rst:851 +#: ../../library/dataclasses.rst:853 #, fuzzy msgid "" "Note that if a field is annotated with a descriptor type, but is not " diff --git a/library/logging.po b/library/logging.po index b1f72fc580..2d4e380831 100644 --- a/library/logging.po +++ b/library/logging.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-25 00:14+0000\n" +"POT-Creation-Date: 2025-08-21 00:15+0000\n" "PO-Revision-Date: 2024-03-28 22:40+0800\n" "Last-Translator: RockLeon \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1684,7 +1684,7 @@ msgstr "執行緒安全" #: ../../library/logging.rst:1139 msgid "" "The logging module is intended to be thread-safe without any special work " -"needing to be done by its clients. It achieves this though using threading " +"needing to be done by its clients. It achieves this through using threading " "locks; there is one lock to serialize access to the module's shared data, " "and each handler also creates a lock to serialize access to its underlying I/" "O." From b44f59acef3e6cdbce2faed9fdbb4d3a0601bc5b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 22 Aug 2025 00:17:26 +0000 Subject: [PATCH 21/23] sync with cpython 41c2c8f0 --- tutorial/classes.po | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tutorial/classes.po b/tutorial/classes.po index c1284d3f93..09a3b5bd12 100644 --- a/tutorial/classes.po +++ b/tutorial/classes.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-27 00:14+0000\n" +"POT-Creation-Date: 2025-08-22 00:16+0000\n" "PO-Revision-Date: 2022-12-26 23:12+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -721,8 +721,9 @@ msgid "x.f()" msgstr "x.f()" #: ../../tutorial/classes.rst:362 +#, fuzzy msgid "" -"In the :class:`!MyClass` example, this will return the string ``'hello " +"If ``x = MyClass()``, as above, this will return the string ``'hello " "world'``. However, it is not necessary to call a method right away: ``x.f`` " "is a method object, and can be stored away and called at a later time. For " "example::" From 41499a2599cf191cddf514108e54bac109ede37e Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Fri, 22 Aug 2025 22:04:28 +0800 Subject: [PATCH 22/23] fix: resolve fuzzy entries --- c-api/code.po | 43 ++++---- c-api/hash.po | 2 +- c-api/init.po | 26 ++++- extending/extending.po | 28 +++--- glossary.po | 8 +- howto/a-conceptual-overview-of-asyncio.po | 117 ++++++++++++++++++++-- howto/index.po | 11 +- library/__future__.po | 40 ++------ library/array.po | 44 ++++---- library/asyncio-sync.po | 3 +- library/asyncio.po | 4 +- library/cmdlinelibs.po | 3 +- library/concurrent.futures.po | 7 +- library/constants.po | 10 +- library/dataclasses.po | 20 ++-- library/dbm.po | 20 ++-- library/doctest.po | 32 +++--- library/enum.po | 29 +++--- library/frameworks.po | 23 +---- library/functions.po | 8 +- library/numbers.po | 6 +- library/ssl.po | 1 - library/time.po | 5 +- library/tk.po | 3 +- library/typing.po | 112 +++++++++++++++++++-- library/unittest.mock.po | 3 +- library/unix.po | 3 +- library/urllib.request.po | 50 ++------- library/warnings.po | 6 +- tutorial/appendix.po | 3 +- tutorial/classes.po | 3 +- 31 files changed, 391 insertions(+), 282 deletions(-) diff --git a/c-api/code.po b/c-api/code.po index 65d8572ff6..89118a2635 100644 --- a/c-api/code.po +++ b/c-api/code.po @@ -145,7 +145,7 @@ msgstr "" #: ../../c-api/code.rst:110 msgid "Returns ``1`` if the function succeeds and 0 otherwise." -msgstr "" +msgstr "如果函式成功則回傳 ``1``,否則回傳 ``0``。" #: ../../c-api/code.rst:116 msgid "" @@ -253,9 +253,8 @@ msgid "" msgstr "" #: ../../c-api/code.rst:217 -#, fuzzy msgid "Code Object Flags" -msgstr "程式碼物件" +msgstr "程式碼物件旗標" #: ../../c-api/code.rst:219 msgid "" @@ -281,79 +280,79 @@ msgstr "" #: ../../c-api/code.rst:238 msgid "Flag" -msgstr "" +msgstr "旗標" #: ../../c-api/code.rst:239 msgid "Meaning" -msgstr "" +msgstr "意義" #: ../../c-api/code.rst:241 msgid ":py:data:`inspect.CO_OPTIMIZED`" -msgstr "" +msgstr ":py:data:`inspect.CO_OPTIMIZED`" #: ../../c-api/code.rst:243 msgid ":py:data:`inspect.CO_NEWLOCALS`" -msgstr "" +msgstr ":py:data:`inspect.CO_NEWLOCALS`" #: ../../c-api/code.rst:245 msgid ":py:data:`inspect.CO_VARARGS`" -msgstr "" +msgstr ":py:data:`inspect.CO_VARARGS`" #: ../../c-api/code.rst:247 msgid ":py:data:`inspect.CO_VARKEYWORDS`" -msgstr "" +msgstr ":py:data:`inspect.CO_VARKEYWORDS`" #: ../../c-api/code.rst:249 msgid ":py:data:`inspect.CO_NESTED`" -msgstr "" +msgstr ":py:data:`inspect.CO_NESTED`" #: ../../c-api/code.rst:251 msgid ":py:data:`inspect.CO_GENERATOR`" -msgstr "" +msgstr ":py:data:`inspect.CO_GENERATOR`" #: ../../c-api/code.rst:253 msgid ":py:data:`inspect.CO_COROUTINE`" -msgstr "" +msgstr ":py:data:`inspect.CO_COROUTINE`" #: ../../c-api/code.rst:255 msgid ":py:data:`inspect.CO_ITERABLE_COROUTINE`" -msgstr "" +msgstr ":py:data:`inspect.CO_ITERABLE_COROUTINE`" #: ../../c-api/code.rst:257 msgid ":py:data:`inspect.CO_ASYNC_GENERATOR`" -msgstr "" +msgstr ":py:data:`inspect.CO_ASYNC_GENERATOR`" #: ../../c-api/code.rst:260 msgid "no effect (:py:data:`__future__.division`)" -msgstr "" +msgstr "無效果(:py:data:`__future__.division`)" #: ../../c-api/code.rst:262 msgid "no effect (:py:data:`__future__.absolute_import`)" -msgstr "" +msgstr "無效果(:py:data:`__future__.absolute_import`)" #: ../../c-api/code.rst:264 msgid "no effect (:py:data:`__future__.with_statement`)" -msgstr "" +msgstr "無效果(:py:data:`__future__.with_statement`)" #: ../../c-api/code.rst:266 msgid "no effect (:py:data:`__future__.print_function`)" -msgstr "" +msgstr "無效果(:py:data:`__future__.print_function`)" #: ../../c-api/code.rst:268 msgid "no effect (:py:data:`__future__.unicode_literals`)" -msgstr "" +msgstr "無效果(:py:data:`__future__.unicode_literals`)" #: ../../c-api/code.rst:270 msgid "no effect (:py:data:`__future__.generator_stop`)" -msgstr "" +msgstr "無效果(:py:data:`__future__.generator_stop`)" #: ../../c-api/code.rst:272 msgid ":py:data:`__future__.annotations`" -msgstr "" +msgstr ":py:data:`__future__.annotations`" #: ../../c-api/code.rst:276 msgid "Extra information" -msgstr "" +msgstr "額外資訊" #: ../../c-api/code.rst:278 msgid "" diff --git a/c-api/hash.po b/c-api/hash.po index d3322bf338..bd50f539c2 100644 --- a/c-api/hash.po +++ b/c-api/hash.po @@ -64,7 +64,7 @@ msgstr ":c:func:`PyHash_GetFuncDef` 所使用的雜湊函式定義。" #: ../../c-api/hash.rst:56 msgid "Hash function." -msgstr "" +msgstr "雜湊函式。" #: ../../c-api/hash.rst:60 msgid "Hash function name (UTF-8 encoded string)." diff --git a/c-api/init.po b/c-api/init.po index 9b1b2d581b..d6bebdf113 100644 --- a/c-api/init.po +++ b/c-api/init.po @@ -21,7 +21,7 @@ msgstr "" #: ../../c-api/init.rst:8 msgid "Initialization, Finalization, and Threads" -msgstr "" +msgstr "初始化、終結化與執行緒" #: ../../c-api/init.rst:10 msgid "" @@ -2372,7 +2372,7 @@ msgstr "" #: ../../c-api/init.rst:1970 msgid "Value of *what*" -msgstr "" +msgstr "*what* 的值" #: ../../c-api/init.rst:1970 msgid "Meaning of *arg*" @@ -2831,7 +2831,7 @@ msgstr "" #: ../../c-api/init.rst:2360 msgid "PyMutex mutex = {0};" -msgstr "" +msgstr "PyMutex mutex = {0};" #: ../../c-api/init.rst:2362 msgid "" @@ -2901,7 +2901,7 @@ msgstr "" #: ../../c-api/init.rst:2419 msgid "Example usage::" -msgstr "" +msgstr "範例用法: ::" #: ../../c-api/init.rst:2421 msgid "" @@ -2914,6 +2914,14 @@ msgid "" " Py_RETURN_NONE;\n" "}" msgstr "" +"static PyObject *\n" +"set_field(MyObject *self, PyObject *value)\n" +"{\n" +" Py_BEGIN_CRITICAL_SECTION(self);\n" +" Py_SETREF(self->field, Py_XNewRef(value));\n" +" Py_END_CRITICAL_SECTION();\n" +" Py_RETURN_NONE;\n" +"}" #: ../../c-api/init.rst:2430 msgid "" @@ -2942,6 +2950,9 @@ msgid "" " PyCriticalSection _py_cs;\n" " PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))" msgstr "" +"{\n" +" PyCriticalSection _py_cs;\n" +" PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))" #: ../../c-api/init.rst:2447 ../../c-api/init.rst:2476 msgid "In the default build, this macro expands to ``{``." @@ -2956,6 +2967,8 @@ msgid "" " PyCriticalSection_End(&_py_cs);\n" "}" msgstr "" +" PyCriticalSection_End(&_py_cs);\n" +"}" #: ../../c-api/init.rst:2460 ../../c-api/init.rst:2489 msgid "In the default build, this macro expands to ``}``." @@ -2974,6 +2987,9 @@ msgid "" " PyCriticalSection2 _py_cs2;\n" " PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))" msgstr "" +"{\n" +" PyCriticalSection2 _py_cs2;\n" +" PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))" #: ../../c-api/init.rst:2482 msgid "Ends the critical section and releases the per-object locks." @@ -2984,6 +3000,8 @@ msgid "" " PyCriticalSection2_End(&_py_cs2);\n" "}" msgstr "" +" PyCriticalSection2_End(&_py_cs2);\n" +"}" #: ../../c-api/init.rst:350 msgid "PyEval_InitThreads()" diff --git a/extending/extending.po b/extending/extending.po index b8532c668c..81aee7cf27 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -165,35 +165,35 @@ msgstr "" #: ../../extending/extending.rst:87 msgid "````" -msgstr "" +msgstr "````" #: ../../extending/extending.rst:88 msgid "```` (on Windows)" -msgstr "" +msgstr "````\\ (在 Windows 上)" #: ../../extending/extending.rst:89 msgid "````" -msgstr "" +msgstr "````" #: ../../extending/extending.rst:90 msgid "````" -msgstr "" +msgstr "````" #: ../../extending/extending.rst:91 msgid "````" -msgstr "" +msgstr "````" #: ../../extending/extending.rst:92 msgid "````" -msgstr "" +msgstr "````" #: ../../extending/extending.rst:93 msgid "````" -msgstr "" +msgstr "````" #: ../../extending/extending.rst:94 msgid "```` (if present)" -msgstr "" +msgstr "````\\ (如果存在)" #: ../../extending/extending.rst:96 msgid "" @@ -203,11 +203,11 @@ msgstr "" #: ../../extending/extending.rst:99 msgid "````" -msgstr "" +msgstr "````" #: ../../extending/extending.rst:100 msgid "```` (on POSIX)" -msgstr "" +msgstr "````\\ (在 POSIX 上)" #: ../../extending/extending.rst:102 msgid "" @@ -217,19 +217,19 @@ msgstr "" #: ../../extending/extending.rst:105 msgid "````" -msgstr "" +msgstr "````" #: ../../extending/extending.rst:106 msgid "````" -msgstr "" +msgstr "````" #: ../../extending/extending.rst:107 msgid "````" -msgstr "" +msgstr "````" #: ../../extending/extending.rst:108 msgid "````" -msgstr "" +msgstr "````" #: ../../extending/extending.rst:110 msgid "" diff --git a/glossary.po b/glossary.po index 9002348c19..fa1699332a 100644 --- a/glossary.po +++ b/glossary.po @@ -924,9 +924,8 @@ msgstr "" "風格。" #: ../../glossary.rst:404 -#, fuzzy msgid "dunder" -msgstr "finder(尋檢器)" +msgstr "dunder(雙底線)" #: ../../glossary.rst:406 msgid "" @@ -934,6 +933,8 @@ msgid "" "term:`special method`. For example, ``__init__`` is often pronounced " "\"dunder init\"." msgstr "" +"一個非正式的縮寫,代表「雙底線 (double underscore)」,當談論到\\ :term:`特殊方法" +" `\\ 時使用。例如,``__init__`` 通常被叫做 \"dunder init\"。" #: ../../glossary.rst:409 msgid "EAFP" @@ -3217,9 +3218,8 @@ msgstr "" "`bytecode`\\ (位元組碼)編譯器所發出的位元組碼。" #: ../../glossary.rst:1406 -#, fuzzy msgid "walrus operator" -msgstr "asynchronous iterator(非同步疊代器)" +msgstr "walrus operator(海象運算子)" #: ../../glossary.rst:1408 msgid "" diff --git a/howto/a-conceptual-overview-of-asyncio.po b/howto/a-conceptual-overview-of-asyncio.po index 16c9752003..ce462ac5e7 100644 --- a/howto/a-conceptual-overview-of-asyncio.po +++ b/howto/a-conceptual-overview-of-asyncio.po @@ -1,4 +1,3 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. @@ -19,7 +18,7 @@ msgstr "" #: ../../howto/a-conceptual-overview-of-asyncio.rst:5 msgid "A Conceptual Overview of :mod:`!asyncio`" -msgstr "" +msgstr ":mod:`!asyncio` 的概念性總覽" #: ../../howto/a-conceptual-overview-of-asyncio.rst:7 msgid "" @@ -84,7 +83,7 @@ msgstr "" #: ../../howto/a-conceptual-overview-of-asyncio.rst:42 msgid "Event Loop" -msgstr "" +msgstr "事件迴圈" #: ../../howto/a-conceptual-overview-of-asyncio.rst:44 msgid "" @@ -130,11 +129,11 @@ msgstr "" #: ../../howto/a-conceptual-overview-of-asyncio.rst:80 msgid "Asynchronous functions and coroutines" -msgstr "" +msgstr "非同步函式與協程" #: ../../howto/a-conceptual-overview-of-asyncio.rst:82 msgid "This is a basic, boring Python function::" -msgstr "" +msgstr "這是一個基本的、無聊的 Python 函式:" #: ../../howto/a-conceptual-overview-of-asyncio.rst:84 msgid "" @@ -145,6 +144,12 @@ msgid "" " \"partner in crime.\"\n" " )" msgstr "" +"def hello_printer():\n" +" print(\n" +" \"Hi, I am a lowly, simple printer, though I have all I \"\n" +" \"need in life -- \\nfresh paper and my dearly beloved octopus \"\n" +" \"partner in crime.\"\n" +" )" #: ../../howto/a-conceptual-overview-of-asyncio.rst:91 msgid "Calling a regular function invokes its logic or body::" @@ -156,6 +161,9 @@ msgid "" "Hi, I am a lowly, simple printer, though I have all I need in life --\n" "fresh paper and my dearly beloved octopus partner in crime." msgstr "" +">>> hello_printer()\n" +"Hi, I am a lowly, simple printer, though I have all I need in life --\n" +"fresh paper and my dearly beloved octopus partner in crime." #: ../../howto/a-conceptual-overview-of-asyncio.rst:97 msgid "" @@ -173,6 +181,12 @@ msgid "" " f\"By the way, my lucky number is: {magic_number}.\"\n" " )" msgstr "" +"async def loudmouth_penguin(magic_number: int):\n" +" print(\n" +" \"I am a super special talking penguin. Far cooler than that printer. " +"\"\n" +" f\"By the way, my lucky number is: {magic_number}.\"\n" +" )" #: ../../howto/a-conceptual-overview-of-asyncio.rst:109 msgid "" @@ -185,6 +199,8 @@ msgid "" ">>> loudmouth_penguin(magic_number=3)\n" "" msgstr "" +">>> loudmouth_penguin(magic_number=3)\n" +"" #: ../../howto/a-conceptual-overview-of-asyncio.rst:115 msgid "" @@ -225,6 +241,15 @@ msgid "" " yield 4\n" " ..." msgstr "" +"def get_random_number():\n" +" # 這是個很爛的隨機數產生器!\n" +" print(\"Hi\")\n" +" yield 1\n" +" print(\"Hello\")\n" +" yield 7\n" +" print(\"Howdy\")\n" +" yield 4\n" +" ..." #: ../../howto/a-conceptual-overview-of-asyncio.rst:147 msgid "" @@ -237,6 +262,8 @@ msgid "" ">>> get_random_number()\n" "" msgstr "" +">>> get_random_number()\n" +"" #: ../../howto/a-conceptual-overview-of-asyncio.rst:153 msgid "" @@ -255,6 +282,13 @@ msgid "" "Hello\n" "7" msgstr "" +">>> generator = get_random_number()\n" +">>> next(generator)\n" +"Hi\n" +"1\n" +">>> next(generator)\n" +"Hello\n" +"7" #: ../../howto/a-conceptual-overview-of-asyncio.rst:168 msgid "Tasks" @@ -353,7 +387,7 @@ msgstr "" #: ../../howto/a-conceptual-overview-of-asyncio.rst:243 msgid "await" -msgstr "" +msgstr "await" #: ../../howto/a-conceptual-overview-of-asyncio.rst:245 msgid "" @@ -366,6 +400,8 @@ msgid "" "await task\n" "await coroutine" msgstr "" +"await task\n" +"await coroutine" #: ../../howto/a-conceptual-overview-of-asyncio.rst:251 msgid "" @@ -444,6 +480,22 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"async def coro_a():\n" +" print(\"I am coro_a(). Hi!\")\n" +"\n" +"async def coro_b():\n" +" print(\"I am coro_b(). I sure hope no one hogs the event loop...\")\n" +"\n" +"async def main():\n" +" task_b = asyncio.create_task(coro_b())\n" +" num_repeats = 3\n" +" for _ in range(num_repeats):\n" +" await coro_a()\n" +" await task_b\n" +"\n" +"asyncio.run(main())" #: ../../howto/a-conceptual-overview-of-asyncio.rst:310 msgid "" @@ -461,6 +513,10 @@ msgid "" "I am coro_a(). Hi!\n" "I am coro_b(). I sure hope no one hogs the event loop..." msgstr "" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_b(). I sure hope no one hogs the event loop..." #: ../../howto/a-conceptual-overview-of-asyncio.rst:323 msgid "" @@ -478,6 +534,10 @@ msgid "" "I am coro_a(). Hi!\n" "I am coro_a(). Hi!" msgstr "" +"I am coro_b(). I sure hope no one hogs the event loop...\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!" #: ../../howto/a-conceptual-overview-of-asyncio.rst:337 msgid "" @@ -556,6 +616,31 @@ msgid "" " returned_value = e.value\n" "print(f\"Coroutine main() finished and provided value: {returned_value}.\")" msgstr "" +"class Rock:\n" +" def __await__(self):\n" +" value_sent_in = yield 7\n" +" print(f\"Rock.__await__ resuming with value: {value_sent_in}.\")\n" +" return value_sent_in\n" +"\n" +"async def main():\n" +" print(\"Beginning coroutine main().\")\n" +" rock = Rock()\n" +" print(\"Awaiting rock...\")\n" +" value_from_rock = await rock\n" +" print(f\"Coroutine received value: {value_from_rock} from rock.\")\n" +" return 23\n" +"\n" +"coroutine = main()\n" +"intermediate_result = coroutine.send(None)\n" +"print(f\"Coroutine paused and returned intermediate value: " +"{intermediate_result}.\")\n" +"\n" +"print(f\"Resuming coroutine and sending in value: 42.\")\n" +"try:\n" +" coroutine.send(42)\n" +"except StopIteration as e:\n" +" returned_value = e.value\n" +"print(f\"Coroutine main() finished and provided value: {returned_value}.\")" #: ../../howto/a-conceptual-overview-of-asyncio.rst:406 msgid "" @@ -591,6 +676,13 @@ msgid "" "Coroutine received value: 42 from rock.\n" "Coroutine main() finished and provided value: 23." msgstr "" +"Beginning coroutine main().\n" +"Awaiting rock...\n" +"Coroutine paused and returned intermediate value: 7.\n" +"Resuming coroutine and sending in value: 42.\n" +"Rock.__await__ resuming with value: 42.\n" +"Coroutine received value: 42 from rock.\n" +"Coroutine main() finished and provided value: 23." #: ../../howto/a-conceptual-overview-of-asyncio.rst:434 msgid "" @@ -782,6 +874,12 @@ msgid "" "I like work. Work work.\n" "Done asynchronous sleep at time: 14:52:25." msgstr "" +"$ python custom-async-sleep.py\n" +"Beginning asynchronous sleep at time: 14:52:22.\n" +"I like work. Work work.\n" +"I like work. Work work.\n" +"I like work. Work work.\n" +"Done asynchronous sleep at time: 14:52:25." #: ../../howto/a-conceptual-overview-of-asyncio.rst:589 msgid "" @@ -802,6 +900,13 @@ msgid "" " else:\n" " await YieldToEventLoop()" msgstr "" +"async def simpler_async_sleep(seconds):\n" +" time_to_wake = time.time() + seconds\n" +" while True:\n" +" if time.time() >= time_to_wake:\n" +" return\n" +" else:\n" +" await YieldToEventLoop()" #: ../../howto/a-conceptual-overview-of-asyncio.rst:604 msgid "" diff --git a/howto/index.po b/howto/index.po index 76a2da176b..1405805e94 100644 --- a/howto/index.po +++ b/howto/index.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -37,11 +36,11 @@ msgstr "" #: ../../howto/index.rst:41 msgid "General:" -msgstr "" +msgstr "一般:" #: ../../howto/index.rst:43 msgid ":ref:`a-conceptual-overview-of-asyncio`" -msgstr "" +msgstr ":ref:`a-conceptual-overview-of-asyncio`" #: ../../howto/index.rst:44 msgid ":ref:`annotations-howto`" @@ -93,7 +92,7 @@ msgstr ":ref:`urllib-howto`" #: ../../howto/index.rst:57 msgid "Advanced development:" -msgstr "" +msgstr "進階開發:" #: ../../howto/index.rst:59 msgid ":ref:`curses-howto`" @@ -129,7 +128,7 @@ msgstr ":ref:`cporting-howto`" #: ../../howto/index.rst:68 msgid "Debugging and profiling:" -msgstr "" +msgstr "偵錯與效能分析:" #: ../../howto/index.rst:70 msgid ":ref:`gdb`" diff --git a/library/__future__.po b/library/__future__.po index 762845fc30..30cc1abfa5 100644 --- a/library/__future__.po +++ b/library/__future__.po @@ -156,7 +156,6 @@ msgid "2.6" msgstr "2.6" #: ../../library/__future__.rst:68 -#, fuzzy msgid ":pep:`343`: *The “with” Statement*" msgstr ":pep:`343`: *\"with\" 陳述式 (The \"with\" Statement)*" @@ -193,7 +192,7 @@ msgstr "3.7.0b1" #: ../../library/__future__.rst:83 msgid "Never [1]_" -msgstr "" +msgstr "從未 [1]_" #: ../../library/__future__.rst:84 msgid ":pep:`563`: *Postponed evaluation of annotations*" @@ -229,6 +228,13 @@ msgid "" " PY_RELEASE_SERIAL # the 3; an int\n" ")" msgstr "" +"(PY_MAJOR_VERSION, # 2.1.0a3 裡面的 2;為一整數\n" +" PY_MINOR_VERSION, # 1;為一整數\n" +" PY_MICRO_VERSION, # 0;為一整數\n" +" PY_RELEASE_LEVEL, # \"alpha\"、\"beta\"、\"candidate\" 或 \"final\"; " +";為一字串\n" +" PY_RELEASE_SERIAL # 3;為一整數\n" +")" #: ../../library/__future__.rst:109 msgid "" @@ -307,33 +313,3 @@ msgstr ":pep:`236` - 回到 __future__" #: ../../library/__future__.rst:146 msgid "The original proposal for the __future__ mechanism." msgstr "__future__ 機制的原始提案。" - -#~ msgid "nested_scopes" -#~ msgstr "nested_scopes" - -#~ msgid "generators" -#~ msgstr "generators" - -#~ msgid "division" -#~ msgstr "division" - -#~ msgid "absolute_import" -#~ msgstr "absolute_import" - -#~ msgid "with_statement" -#~ msgstr "with_statement" - -#~ msgid "print_function" -#~ msgstr "print_function" - -#~ msgid "unicode_literals" -#~ msgstr "unicode_literals" - -#~ msgid "generator_stop" -#~ msgstr "generator_stop" - -#~ msgid "annotations" -#~ msgstr "annotations" - -#~ msgid "TBD [1]_" -#~ msgstr "TBD [1]_" diff --git a/library/array.po b/library/array.po index 746000dca2..feccab889a 100644 --- a/library/array.po +++ b/library/array.po @@ -125,7 +125,7 @@ msgstr "4" #: ../../library/array.rst:27 msgid "\\(2)" -msgstr "" +msgstr "\\(2)" #: ../../library/array.rst:29 msgid "``'h'``" @@ -232,7 +232,7 @@ msgstr "" #: ../../library/array.rst:60 msgid "Please migrate to ``'w'`` typecode." -msgstr "" +msgstr "請改用 ``'w'`` typecode。" #: ../../library/array.rst:67 msgid "" @@ -361,9 +361,10 @@ msgstr "回傳 *x* 在陣列中出現了幾次。" #: ../../library/array.rst:154 msgid "" "Append items from *iterable* to the end of the array. If *iterable* is " -"another array, it must have *exactly* the same type code; if not, :exc:" -"`TypeError` will be raised. If *iterable* is not an array, it must be " -"iterable and its elements must be the right type to be appended to the array." +"another array, it must have *exactly* the same type code; if " +"not, :exc:`TypeError` will be raised. If *iterable* is not an array, it " +"must be iterable and its elements must be the right type to be appended to " +"the array." msgstr "" "從 *iterable* 中新增元素到陣列的尾端,如果 *iterable* 是另一個陣列,它必須有" "完全相同的 type code,如果不同會導致 :exc:`TypeError`。如果 *iterable* 不是一" @@ -373,8 +374,8 @@ msgstr "" #: ../../library/array.rst:162 msgid "" "Appends items from the :term:`bytes-like object`, interpreting its content " -"as an array of machine values (as if it had been read from a file using the :" -"meth:`fromfile` method)." +"as an array of machine values (as if it had been read from a file using " +"the :meth:`fromfile` method)." msgstr "" "從 :term:`bytes-like object` 中新增元素。讀取時會將其內容當作一個機器數值組成" "的陣列(就像從檔案中使用 :meth:`fromfile` 方法讀出的資料)。" @@ -410,9 +411,9 @@ msgid "" "an array of some other type." msgstr "" "用給定的 Unicode 字串擴展這個陣列。陣列的 type code 必須是 ``u`` 或 ``'w'``;" -"其他的型別會導致 :exc:`ValueError` 被引發。使用 ``array." -"frombytes(unicodestring.encode(enc))`` 來新增 Unicode 資料到一個其他型別的陣" -"列。" +"其他的型別會導致 :exc:`ValueError` 被引發。使用 " +"``array.frombytes(unicodestring.encode(enc))`` 來新增 Unicode 資料到一個其他" +"型別的陣列。" #: ../../library/array.rst:194 msgid "" @@ -449,9 +450,8 @@ msgid "Remove the first occurrence of *x* from the array." msgstr "從陣列中刪除第一個出現的 *x*。" #: ../../library/array.rst:223 -#, fuzzy msgid "Remove all elements from the array." -msgstr "從陣列中刪除第一個出現的 *x*。" +msgstr "從陣列中刪除所有元素。" #: ../../library/array.rst:230 msgid "Reverse the order of the items in the array." @@ -479,18 +479,16 @@ msgid "Convert the array to an ordinary list with the same items." msgstr "不更改元素,將陣列轉為一般的 list。" #: ../../library/array.rst:255 -#, fuzzy msgid "" "Convert the array to a Unicode string. The array must have a type ``'u'`` " "or ``'w'``; otherwise a :exc:`ValueError` is raised. Use ``array.tobytes()." "decode(enc)`` to obtain a Unicode string from an array of some other type." msgstr "" -"將陣列轉為一個 Unicode 字串。陣列的型別必須為 ``u``。其他型別的陣列會導致 :" -"exc:`ValueError` 錯誤。請使用 ``array.tobytes().decode(enc)`` 來為其他型別的" -"陣列轉為 Unicode 字串。" +"將陣列轉為一個 Unicode 字串。陣列的型別必須為 ``u`` 或 ``'w'``;其他型別的陣" +"列會引發 :exc:`ValueError`。請使用 ``array.tobytes().decode(enc)`` 來為其他型" +"別的陣列轉為 Unicode 字串。" #: ../../library/array.rst:260 -#, fuzzy msgid "" "The string representation of array objects has the form ``array(typecode, " "initializer)``. The *initializer* is omitted if the array is empty, " @@ -503,13 +501,13 @@ msgid "" "Examples::" msgstr "" "陣列物件的字串表示形式為 ``array(typecode, initializer)``。若為空陣列則參數 " -"*initializer* 被省略,若 *typecode* 是 ``'u'`` 將被表示為 Unicode 字串,其他" -"情況則被表示為由數字組成的 list。只要 :class:`~array.array` class(類別)透" -"過 ``from array import array`` 的方式引入,便能確保該字串表示能透過 :func:" -"`eval` 轉換回一個擁有相同型別及數值的陣列。範例: ::" +"*initializer* 被省略,若 *typecode* 是 ``'u'`` 或 ``'w'`` 將被表示為 Unicode " +"字串,其他情況則被表示為由數字組成的 list。只要 :class:`~array.array` class" +"(類別)透過 ``from array import array`` 的方式引入,便能確保該字串表示能透" +"過 :func:`eval` 轉換回一個擁有相同型別及數值的陣列。如果它包含相應的浮點值," +"``inf`` 和 ``nan`` 也必須被定義。範例: ::" #: ../../library/array.rst:272 -#, fuzzy msgid "" "array('l')\n" "array('w', 'hello \\u2641')\n" @@ -517,7 +515,7 @@ msgid "" "array('d', [1.0, 2.0, 3.14, -inf, nan])" msgstr "" "array('l')\n" -"array('u', 'hello \\u2641')\n" +"array('w', 'hello \\u2641')\n" "array('l', [1, 2, 3, 4, 5])\n" "array('d', [1.0, 2.0, 3.14, -inf, nan])" diff --git a/library/asyncio-sync.po b/library/asyncio-sync.po index c9efe21b78..cee3fe6789 100644 --- a/library/asyncio-sync.po +++ b/library/asyncio-sync.po @@ -253,12 +253,11 @@ msgid "Clear (unset) the event." msgstr "清除(還原)事件。" #: ../../library/asyncio-sync.rst:160 -#, fuzzy msgid "" "Subsequent tasks awaiting on :meth:`~Event.wait` will now block until the :" "meth:`~Event.set` method is called again." msgstr "" -"正透過 :meth:`~Event.wait` 等待的 Tasks 現在會持續阻塞直到 :meth:`~Event." +"正透過 :meth:`~Event.wait` 等待的後續 Tasks 現在會持續阻塞直到 :meth:`~Event." "set` 方法再次被呼叫。" #: ../../library/asyncio-sync.rst:165 diff --git a/library/asyncio.po b/library/asyncio.po index ffff473328..980b757215 100644 --- a/library/asyncio.po +++ b/library/asyncio.po @@ -87,11 +87,11 @@ msgstr "" #: ../../library/asyncio.rst:34 msgid ":ref:`a-conceptual-overview-of-asyncio`" -msgstr "" +msgstr ":ref:`a-conceptual-overview-of-asyncio`" #: ../../library/asyncio.rst:35 msgid "Explanation of the fundamentals of asyncio." -msgstr "" +msgstr "asyncio 的基本原理說明。" #: ../../library/asyncio.rst:37 msgid "asyncio provides a set of **high-level** APIs to:" diff --git a/library/cmdlinelibs.po b/library/cmdlinelibs.po index c5711318fd..7cce8dba34 100644 --- a/library/cmdlinelibs.po +++ b/library/cmdlinelibs.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # @@ -18,7 +18,6 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../library/cmdlinelibs.rst:5 -#, fuzzy msgid "Command-line interface libraries" msgstr "命令列介面函式庫" diff --git a/library/concurrent.futures.po b/library/concurrent.futures.po index 8d810cc18c..1ad6ca601a 100644 --- a/library/concurrent.futures.po +++ b/library/concurrent.futures.po @@ -192,16 +192,15 @@ msgstr "" "future 將在此方法回傳之前完成。剩餘的 future 被取消。" #: ../../library/concurrent.futures.rst:95 -#, fuzzy msgid "" "You can avoid having to call this method explicitly if you use the executor " "as a :term:`context manager` via the :keyword:`with` statement, which will " "shutdown the :class:`Executor` (waiting as if :meth:`Executor.shutdown` were " "called with *wait* set to ``True``)::" msgstr "" -"如果使用 :keyword:`with` 陳述句,你就可以不用明確地呼叫此方法,這將會自己關" -"閉 :class:`Executor`\\(如同呼叫 :meth:`Executor.shutdown` 時 *wait* 被設定" -"為 ``True`` 般等待): ::" +"如果透過 :keyword:`with` 陳述式來將 executor 作為\\ :term:`情境管理器 `\\ " +"使用,你就可以不用明確地呼叫此方法,這將會自己關閉 :class:`Executor`\\(如同呼叫" +" :meth:`Executor.shutdown` 時 *wait* 被設定為 ``True`` 般等待): ::" #: ../../library/concurrent.futures.rst:100 msgid "" diff --git a/library/constants.po b/library/constants.po index 8cd75e1292..6b622131bc 100644 --- a/library/constants.po +++ b/library/constants.po @@ -160,17 +160,15 @@ msgstr "" "式直譯器中是很有幫助的,但不應該在程式 (programs) 中被使用。" #: ../../library/constants.rst:96 -#, fuzzy msgid "" "Objects that when printed, print a message like \"Use quit() or Ctrl-D (i.e. " "EOF) to exit\", and when accessed directly in the interactive interpreter or " "called as functions, raise :exc:`SystemExit` with the specified exit code." msgstr "" -"當印出物件時,會印出一個訊息: \"Use quit() or Ctrl-D (i.e. EOF) to exit\" 。" -"當被呼叫時,則會拋出 :exc:`SystemExit` 並帶有指定的返回碼(exit code)。" +"當印出物件時,會印出一個訊息:\"Use quit() or Ctrl-D (i.e. EOF) to exit\"。" +"當直接在互動式直譯器中存取或作為函式呼叫時,會引發 :exc:`SystemExit` 並帶有指定的返回碼(exit code)。" #: ../../library/constants.rst:104 -#, fuzzy msgid "" "Object that when printed, prints the message \"Type help() for interactive " "help, or help(object) for help about object.\", and when accessed directly " @@ -178,8 +176,8 @@ msgid "" "`help`)." msgstr "" "當印出此物件時,會印出訊息 \"Type help() for interactive help, or " -"help(object) for help about object.\",並在呼叫時按所述的方式操作 :func:" -"`elsewhere `。" +"help(object) for help about object.\",並在互動式直譯器中直接存取時,會叫用內建的" +"幫助系統(參見 :func:`help`)。" #: ../../library/constants.rst:112 msgid "" diff --git a/library/dataclasses.po b/library/dataclasses.po index 9faa4efe7b..4a2bf07608 100644 --- a/library/dataclasses.po +++ b/library/dataclasses.po @@ -310,7 +310,6 @@ msgstr "" "`TypeError`。" #: ../../library/dataclasses.rst:155 -#, fuzzy msgid "" "If *eq* and *frozen* are both true, by default ``@dataclass`` will generate " "a :meth:`!__hash__` method for you. If *eq* is true and *frozen* is false, :" @@ -320,12 +319,11 @@ msgid "" "used (if the superclass is :class:`object`, this means it will fall back to " "id-based hashing)." msgstr "" -"如果 *eq* 和 *frozen* 都為真,預設情況下 ``@dataclass`` 會為你生成一個:meth:" -"`!__hash__` 方法。如果 ``eq`` 為真且 ``frozen`` 為假,:meth:`!__hash__` 將被" -"設定為 ``None``,將其標記為不可散列(它是不可散列的,因為它是可變的)。如果 " -"``eq`` 為假,:meth:`!__hash__` 將保持不變,這意味著將使用超類別的 :meth:`!" -"__hash__` 方法(如果超類別是 :class:`object`,這意味著它將回退到基於 id 的散" -"列)。" +"如果 *eq* 和 *frozen* 都為真,預設情況下 ``@dataclass`` 會為你生成一個 :meth:" +"`!__hash__` 方法。如果 *eq* 為真且 *frozen* 為假,:meth:`!__hash__` 將被" +"設定為 ``None``,並將其標記為不可雜湊(因為它是可變的)。如果 " +"*eq* 為假,:meth:`!__hash__` 將保持不變,這意味著將使用超類別的 :meth:`!" +"__hash__` 方法(如果超類別是 :class:`object`,這意味著它將回退到基於 id 的雜湊)。" #: ../../library/dataclasses.rst:163 #, fuzzy @@ -339,13 +337,12 @@ msgstr "" "類別中定義,則 :exc:`TypeError` 被引發。請參閱下面的討論。" #: ../../library/dataclasses.rst:167 -#, fuzzy msgid "" "If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in " "the class and *frozen* is true, then :exc:`TypeError` is raised." msgstr "" -"當在使用 frozen=True 定義的資料類別上呼叫隱式定義的 :meth:`__setattr__` 或 :" -"meth:`__delattr__` 時引發。它是 :exc:`AttributeError` 的子類別。" +"如果類別中定義了 :meth:`~object.__setattr__` 或 :meth:`~object.__delattr__` " +"且 *frozen* 為真,則會引發 :exc:`TypeError`。" #: ../../library/dataclasses.rst:170 #, fuzzy @@ -526,13 +523,12 @@ msgid "The parameters to :func:`!field` are:" msgstr ":func:`!field` 的參數是:" #: ../../library/dataclasses.rst:269 -#, fuzzy msgid "" "*default*: If provided, this will be the default value for this field. This " "is needed because the :func:`!field` call itself replaces the normal " "position of the default value." msgstr "" -"*default*:如果提供,這將是該欄位的預設值。這是必需的,因為 :meth:`!field` 呼" +"*default*:如果有提供,這將是該欄位的預設值。這是必需的,因為 :meth:`!field` 呼" "叫本身會替換預設值的正常位置。" #: ../../library/dataclasses.rst:273 diff --git a/library/dbm.po b/library/dbm.po index 9bfe5f9505..efc712a72b 100644 --- a/library/dbm.po +++ b/library/dbm.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -193,7 +193,7 @@ msgstr "" #: ../../library/dbm.rst:114 msgid ":meth:`!clear` methods are now available for all :mod:`dbm` backends." -msgstr "" +msgstr ":meth:`!clear` 方法現在可用於所有 :mod:`dbm` 後端。" #: ../../library/dbm.rst:118 msgid "" @@ -269,9 +269,8 @@ msgstr "" "availability`。" #: ../../library/dbm.rst:176 -#, fuzzy msgid "Open an SQLite database." -msgstr "關閉資料庫。" +msgstr "打開一個 SQLite 資料庫。" #: ../../library/dbm.rst:178 msgid "The path to the database to be opened." @@ -293,12 +292,11 @@ msgstr "" #: ../../library/dbm.rst:198 ../../library/dbm.rst:399 msgid "The following method is also provided:" -msgstr "" +msgstr "也提供了以下方法:" #: ../../library/dbm.rst:202 -#, fuzzy msgid "Close the SQLite database." -msgstr "關閉資料庫。" +msgstr "關閉 SQLite 資料庫。" #: ../../library/dbm.rst:206 msgid ":mod:`dbm.gnu` --- GNU database manager" @@ -344,7 +342,7 @@ msgstr "" #: ../../library/dbm.rst:240 msgid "Open a GDBM database and return a :class:`!gdbm` object." -msgstr "" +msgstr "打開一個 GDBM 資料庫,並回傳一個 :class:`!gdbm` 物件。" #: ../../library/dbm.rst:246 msgid "" @@ -636,9 +634,3 @@ msgstr "" #: ../../library/dbm.rst:414 msgid "databases" msgstr "databases(資料庫)" - -#~ msgid "Remove all items from the GDBM database." -#~ msgstr "移除 GDBM 資料庫中所有項目。" - -#~ msgid "Remove all items from the NDBM database." -#~ msgstr "移除 NDBM 資料庫中所有項目。" diff --git a/library/doctest.po b/library/doctest.po index 1f3152e43c..37c9b9bb18 100644 --- a/library/doctest.po +++ b/library/doctest.po @@ -402,16 +402,16 @@ msgstr "" #: ../../library/doctest.rst:249 msgid "Command-line Usage" -msgstr "" +msgstr "命令列用法" #: ../../library/doctest.rst:251 msgid "" "The :mod:`doctest` module can be invoked as a script from the command line:" -msgstr "" +msgstr "可以從命令列以腳本方式叫用 :mod:`doctest` 模組:" #: ../../library/doctest.rst:253 msgid "python -m doctest [-v] [-o OPTION] [-f] file [file ...]" -msgstr "" +msgstr "python -m doctest [-v] [-o OPTION] [-f] file [file ...]" #: ../../library/doctest.rst:261 msgid "" @@ -452,7 +452,7 @@ msgstr "" #: ../../library/doctest.rst:292 msgid "How It Works" -msgstr "" +msgstr "運作方式" #: ../../library/doctest.rst:294 msgid "" @@ -1129,7 +1129,7 @@ msgstr "" #: ../../library/doctest.rst:770 msgid "For example, this test passes:" -msgstr "" +msgstr "舉例來說,這個測試會通過:" #: ../../library/doctest.rst:772 msgid "" @@ -1479,7 +1479,7 @@ msgstr "" #: ../../library/doctest.rst:990 msgid "Return ``(failure_count, test_count)``." -msgstr "" +msgstr "回傳 ``(failure_count, test_count)``。" #: ../../library/doctest.rst:992 msgid "" @@ -1545,7 +1545,7 @@ msgstr "" #: ../../library/doctest.rst:1031 msgid "Unittest API" -msgstr "" +msgstr "Unittest API" #: ../../library/doctest.rst:1033 msgid "" @@ -2156,15 +2156,15 @@ msgstr "TestResults 物件" #: ../../library/doctest.rst:1482 msgid "Number of failed tests." -msgstr "" +msgstr "失敗的測試數量。" #: ../../library/doctest.rst:1486 msgid "Number of attempted tests." -msgstr "" +msgstr "嘗試的測試數量。" #: ../../library/doctest.rst:1490 msgid "Number of skipped tests." -msgstr "" +msgstr "跳過的測試數量。" #: ../../library/doctest.rst:1498 msgid "DocTestRunner objects" @@ -2330,15 +2330,15 @@ msgstr ":class:`DocTestParser` 有以下屬性:" #: ../../library/doctest.rst:1620 msgid "Number of attempted examples." -msgstr "" +msgstr "嘗試的範例數量。" #: ../../library/doctest.rst:1624 msgid "Number of failed examples." -msgstr "" +msgstr "失敗的範例數量。" #: ../../library/doctest.rst:1628 msgid "Number of skipped examples." -msgstr "" +msgstr "跳過的範例數量。" #: ../../library/doctest.rst:1636 msgid "OutputChecker objects" @@ -2375,11 +2375,11 @@ msgstr "" #: ../../library/doctest.rst:1669 msgid "Debugging" -msgstr "" +msgstr "偵錯" #: ../../library/doctest.rst:1671 msgid "Doctest provides several mechanisms for debugging doctest examples:" -msgstr "" +msgstr "Doctest 提供了幾種偵錯 doctest 範例的機制:" #: ../../library/doctest.rst:1673 msgid "" @@ -2718,7 +2718,7 @@ msgstr "" #: ../../library/doctest.rst:1903 msgid "Regression testing." -msgstr "" +msgstr "回歸測試。" #: ../../library/doctest.rst:1905 msgid "Executable documentation / literate testing." diff --git a/library/enum.po b/library/enum.po index acd468baa1..d2e7a9d28c 100644 --- a/library/enum.po +++ b/library/enum.po @@ -934,33 +934,29 @@ msgid "Added :ref:`enum-dataclass-support`" msgstr "新增 :ref:`enum-dataclass-support`" #: ../../library/enum.rst:465 -#, fuzzy msgid "Adds a new name as an alias to an existing member::" -msgstr ":meth:`~EnumType._add_alias_` -- 新增一個名稱作為現有成員的別名。" +msgstr "新增一個名稱作為現有成員的別名: ::" #: ../../library/enum.rst:467 -#, fuzzy msgid "" ">>> Color.RED._add_alias_(\"ERROR\")\n" ">>> Color.ERROR\n" "" msgstr "" -">>> Color.RED | Color.GREEN\n" -"" +">>> Color.RED._add_alias_(\"ERROR\")\n" +">>> Color.ERROR\n" +"" #: ../../library/enum.rst:471 -#, fuzzy msgid "" "Raises a :exc:`NameError` if the name is already assigned to a different " "member." msgstr "" -"新增一個名稱作為現有成員的別名。如果該名稱已被指派給不同的成員,則會引發 :" -"exc:`NameError`。" +"如果該名稱已被指派給不同的成員,則會引發 :exc:`NameError`。" #: ../../library/enum.rst:477 -#, fuzzy msgid "Adds a new value as an alias to an existing member::" -msgstr ":meth:`~EnumType._add_value_alias_` -- 新增一個值作為現有成員的別名。" +msgstr "新增一個值作為現有成員的別名: ::" #: ../../library/enum.rst:479 msgid "" @@ -968,15 +964,16 @@ msgid "" ">>> Color(42)\n" "" msgstr "" +">>> Color.RED._add_value_alias_(42)\n" +">>> Color(42)\n" +"" #: ../../library/enum.rst:483 -#, fuzzy msgid "" "Raises a :exc:`ValueError` if the value is already linked with a different " "member." msgstr "" -"新增一個值作為現有成員的別名。如果該值已與不同成員連結,則會引發 :exc:" -"`ValueError`。" +"如果該值已與不同成員連結,則會引發 :exc:`ValueError`。" #: ../../library/enum.rst:490 msgid "" @@ -1632,18 +1629,16 @@ msgstr "" "對 :class:`Flag` 類別來說,下一個被選擇的值是下一個最大的 2 的次方的數字。" #: ../../library/enum.rst:916 -#, fuzzy msgid "" ":meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing " "member." -msgstr ":meth:`~EnumType._add_alias_` -- 新增一個名稱作為現有成員的別名。" +msgstr ":meth:`~Enum._add_alias_` -- 新增一個名稱作為現有成員的別名。" #: ../../library/enum.rst:918 -#, fuzzy msgid "" ":meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an " "existing member." -msgstr ":meth:`~EnumType._add_value_alias_` -- 新增一個值作為現有成員的別名。" +msgstr ":meth:`~Enum._add_value_alias_` -- 新增一個值作為現有成員的別名。" #: ../../library/enum.rst:921 msgid "" diff --git a/library/frameworks.po b/library/frameworks.po index 6d2fac470a..7f997c290b 100644 --- a/library/frameworks.po +++ b/library/frameworks.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -21,7 +20,6 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/frameworks.rst:7 -#, fuzzy msgid "Program frameworks" msgstr "程式框架" @@ -29,27 +27,16 @@ msgstr "程式框架" msgid "" "This chapter is no longer maintained, and the modules it contained have been " "moved to their respective topical documentation." -msgstr "" +msgstr "此章節不再維護,所包含的模組已移至各自的主題文件中。" #: ../../library/frameworks.rst:11 msgid ":mod:`cmd` — :doc:`Command Line Interface Libraries <./cmdlinelibs>`" -msgstr "" +msgstr ":mod:`cmd` — :doc:`命令列介面函式庫 <./cmdlinelibs>`" #: ../../library/frameworks.rst:12 msgid ":mod:`shlex` — :doc:`Unix Specific Services <./unix>`" -msgstr "" +msgstr ":mod:`shlex` — :doc:`Unix 特定服務 <./unix>`" #: ../../library/frameworks.rst:13 msgid ":mod:`turtle` — :doc:`Graphical User Interfaces with Tk <./tk>`" -msgstr "" - -#~ msgid "" -#~ "The modules described in this chapter are frameworks that will largely " -#~ "dictate the structure of your program. Currently the modules described " -#~ "here are all oriented toward writing command-line interfaces." -#~ msgstr "" -#~ "本章所描述的模組屬於框架性質,它們將在很大程度上決定程式的結構。目前本章介" -#~ "紹的所有模組皆專注於撰寫命令列介面。" - -#~ msgid "The full list of modules described in this chapter is:" -#~ msgstr "完整的模組列表為:" +msgstr ":mod:`turtle` — :doc:`使用 Tk 的圖形化使用者介面 <./tk>`" diff --git a/library/functions.po b/library/functions.po index 59195e3e29..8e0ff9c05a 100644 --- a/library/functions.po +++ b/library/functions.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # Translators: # Adrian Liaw , 2018 @@ -2720,14 +2720,13 @@ msgid "Return the ordinal value of a character." msgstr "" #: ../../library/functions.rst:1557 -#, fuzzy msgid "" "If the argument is a one-character string, return the Unicode code point of " "that character. For example, ``ord('a')`` returns the integer ``97`` and " "``ord('€')`` (Euro sign) returns ``8364``. This is the inverse of :func:" "`chr`." msgstr "" -"對於代表單個 Unicode 字元的字串,回傳代表它 Unicode 編碼位置的整數。例如 " +"如果引數是單字元字串,則回傳該字元的 Unicode 編碼位置。例如 " "``ord('a')`` 回傳整數 ``97``、``ord('€')``\\ (歐元符號)回傳 ``8364``。這" "是 :func:`chr` 的逆函式。" @@ -2750,7 +2749,6 @@ msgstr "" "的 ``pow(exp, exp)`` 等價於次方運算子:``base**exp``。" #: ../../library/functions.rst:1574 -#, fuzzy msgid "" "When arguments are builtin numeric types with mixed operand types, the " "coercion rules for binary arithmetic operators apply. For :class:`int` " @@ -2764,7 +2762,7 @@ msgid "" "`float` with an integral exponent, a float result is delivered. For example, " "``pow(-9, 2.0)`` returns ``81.0``." msgstr "" -"引數必須是數值型別。對於混合型別的運算元,會套用二元算術運算子的強制轉型 " +"當引數為內建數值型別,且用於混合型別的運算元,會套用二元算術運算子的強制轉型 " "(coercion) 規則。對於 :class:`int` 運算元,運算結果會(在強制轉型後)與運算元" "的型別相同,除非第二個引數是負數;在這種情況下,所有的引數都會被轉換為浮點數" "並得到浮點數的結果。例如,``pow(10, 2)`` 會回傳 ``100``,但 ``pow(10, -2)`` " diff --git a/library/numbers.po b/library/numbers.po index d33387bbdc..1ce21e8150 100644 --- a/library/numbers.po +++ b/library/numbers.po @@ -121,14 +121,12 @@ msgstr "" "class:`Integral` 的實例且 :attr:`~Rational.denominator` 要是正數。" #: ../../library/numbers.rst:72 -#, fuzzy msgid "Abstract. The numerator of this rational number." -msgstr "為抽象的。取得該數值的實數部分。" +msgstr "為抽象的。該有理數的分子。" #: ../../library/numbers.rst:76 -#, fuzzy msgid "Abstract. The denominator of this rational number." -msgstr "為抽象的。取得該數值的實數部分。" +msgstr "為抽象的。該有理數的分母。" #: ../../library/numbers.rst:81 msgid "" diff --git a/library/ssl.po b/library/ssl.po index 4b4e3e5db7..a9dc4282fc 100644 --- a/library/ssl.po +++ b/library/ssl.po @@ -82,7 +82,6 @@ msgstr "" "可以去參考此章節底部的「詳情」部分。" #: ../../library/ssl.rst:42 -#, fuzzy msgid "" "This module provides a class, :class:`ssl.SSLSocket`, which is derived from " "the :class:`socket.socket` type, and provides a socket-like wrapper that " diff --git a/library/time.po b/library/time.po index d1f6d8d81b..ac4f7ce5b5 100644 --- a/library/time.po +++ b/library/time.po @@ -1597,13 +1597,12 @@ msgid "High-resolution per-process timer from the CPU." msgstr "來自 CPU 的高解析度每個行程的計時器。" #: ../../library/time.rst:938 -#, fuzzy msgid "" "`International Atomic Time `_" msgstr "" -"`國際原子時間 `_" +"`國際原子時間 `_ #: ../../library/time.rst:940 msgid "" diff --git a/library/tk.po b/library/tk.po index 6d1785bf11..67478fb57a 100644 --- a/library/tk.po +++ b/library/tk.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -21,7 +21,6 @@ msgstr "" "X-Generator: Poedit 3.3.1\n" #: ../../library/tk.rst:5 -#, fuzzy msgid "Graphical user interfaces with Tk" msgstr "以 Tk 打造圖形使用者介面 (Graphical User Interfaces)" diff --git a/library/typing.po b/library/typing.po index d2b8a3b8c1..4d79f0b698 100644 --- a/library/typing.po +++ b/library/typing.po @@ -81,12 +81,11 @@ msgstr "" "新功能提供了 backport(向後移植的)版本,提供給舊版本的 Python 使用。" #: ../../library/typing.rst:48 -#, fuzzy msgid "" "`Typing cheat sheet `_" msgstr "" -"`\"型別小抄 (Typing cheat sheet)\" `_" #: ../../library/typing.rst:49 @@ -94,13 +93,12 @@ msgid "A quick overview of type hints (hosted at the mypy docs)" msgstr "型別提示的快速預覽(發布於 mypy 的文件中)" #: ../../library/typing.rst:51 -#, fuzzy msgid "" "Type System Reference section of `the mypy docs `_" msgstr "" -"`mypy 文件 `_\\ 的 \"型別系" -"統參考資料 (Type System Reference)\" 章節" +"`mypy 文件 `_\\ 的 型別系" +"統參考資料 (Type System Reference) 章節" #: ../../library/typing.rst:52 msgid "" @@ -112,11 +110,9 @@ msgstr "" "多數 Python 型別檢查器中廣為使用。(某些部分依然是特定給 mypy 使用。)" #: ../../library/typing.rst:56 -#, fuzzy msgid "`Static Typing with Python `_" msgstr "" -"`\"Python 的靜態型別 (Static Typing)\" `_" +"`Python 的靜態型別 (Static Typing) `_" #: ../../library/typing.rst:57 msgid "" @@ -131,14 +127,13 @@ msgid "Specification for the Python Type System" msgstr "Python 型別系統的技術規範" #: ../../library/typing.rst:66 -#, fuzzy msgid "" "The canonical, up-to-date specification of the Python type system can be " "found at `Specification for the Python type system `_." msgstr "" -"關於 Python 型別系統標準的 (canonical)、最新的技術規範可以在\\ `「Python 型別" -"系統的技術規範」 `_\\ 找" +"關於 Python 型別系統標準的 (canonical)、最新的技術規範可以在\\ `Python 型別" +"系統的技術規範 `_\\ 找" "到。" #: ../../library/typing.rst:72 @@ -324,6 +319,11 @@ msgid "" "\n" "ProUserId = NewType('ProUserId', UserId)" msgstr "" +"from typing import NewType\n" +"\n" +"UserId = NewType('UserId', int)\n" +"\n" +"ProUserId = NewType('ProUserId', UserId)" #: ../../library/typing.rst:176 msgid "and typechecking for ``ProUserId`` will work as expected." @@ -440,6 +440,12 @@ msgid "" "x = str # OK\n" "x = concat # Also OK" msgstr "" +"def concat(x: str, y: str) -> str:\n" +" return x + y\n" +"\n" +"x: Callable[..., str]\n" +"x = str # OK\n" +"x = concat # 也 OK" #: ../../library/typing.rst:250 msgid "" @@ -797,6 +803,10 @@ msgid "" " yield start\n" " start += 1" msgstr "" +"def infinite_stream(start: int) -> Generator[int, None, None]:\n" +" while True:\n" +" yield start\n" +" start += 1" #: ../../library/typing.rst:478 msgid "" @@ -812,6 +822,10 @@ msgid "" " yield start\n" " start += 1" msgstr "" +"def infinite_stream(start: int) -> Iterator[int]:\n" +" while True:\n" +" yield start\n" +" start += 1" #: ../../library/typing.rst:488 msgid "" @@ -833,6 +847,15 @@ msgid "" " yield start\n" " start = await increment(start)" msgstr "" +"async def infinite_stream(start: int) -> AsyncGenerator[int]:\n" +" while True:\n" +" yield start\n" +" start = await increment(start)\n" +"\n" +"async def infinite_stream(start: int) -> AsyncGenerator[int, None]:\n" +" while True:\n" +" yield start\n" +" start = await increment(start)" #: ../../library/typing.rst:504 msgid "" @@ -848,6 +871,10 @@ msgid "" " yield start\n" " start = await increment(start)" msgstr "" +"async def infinite_stream(start: int) -> AsyncIterator[int]:\n" +" while True:\n" +" yield start\n" +" start = await increment(start)" #: ../../library/typing.rst:514 msgid "" @@ -894,6 +921,24 @@ msgid "" " def log(self, message: str) -> None:\n" " self.logger.info('%s: %s', self.name, message)" msgstr "" +"from logging import Logger\n" +"\n" +"class LoggedVar[T]:\n" +" def __init__(self, value: T, name: str, logger: Logger) -> None:\n" +" self.name = name\n" +" self.logger = logger\n" +" self.value = value\n" +"\n" +" def set(self, new: T) -> None:\n" +" self.log('Set ' + repr(self.value))\n" +" self.value = new\n" +"\n" +" def get(self) -> T:\n" +" self.log('Get ' + repr(self.value))\n" +" return self.value\n" +"\n" +" def log(self, message: str) -> None:\n" +" self.logger.info('%s: %s', self.name, message)" #: ../../library/typing.rst:553 msgid "" @@ -922,6 +967,12 @@ msgid "" "class LoggedVar(Generic[T]):\n" " ..." msgstr "" +"from typing import TypeVar, Generic\n" +"\n" +"T = TypeVar('T')\n" +"\n" +"class LoggedVar(Generic[T]):\n" +" ..." #: ../../library/typing.rst:568 msgid "" @@ -939,6 +990,11 @@ msgid "" " for var in vars:\n" " var.set(0)" msgstr "" +"from collections.abc import Iterable\n" +"\n" +"def zero_all_vars(vars: Iterable[LoggedVar[int]]) -> None:\n" +" for var in vars:\n" +" var.set(0)" #: ../../library/typing.rst:577 msgid "" @@ -962,6 +1018,17 @@ msgid "" "class OldWeirdTrio(Generic[OldT, OldB, OldS]):\n" " ..." msgstr "" +"from typing import TypeVar, Generic, Sequence\n" +"\n" +"class WeirdTrio[T, B: Sequence[bytes], S: (int, str)]:\n" +" ...\n" +"\n" +"OldT = TypeVar('OldT', contravariant=True)\n" +"OldB = TypeVar('OldB', bound=Sequence[bytes], covariant=True)\n" +"OldS = TypeVar('OldS', int, str)\n" +"\n" +"class OldWeirdTrio(Generic[OldT, OldB, OldS]):\n" +" ..." #: ../../library/typing.rst:592 msgid "" @@ -982,6 +1049,16 @@ msgid "" "class Pair(Generic[T, T]): # INVALID\n" " ..." msgstr "" +"from typing import TypeVar, Generic\n" +"...\n" +"\n" +"class Pair[M, M]: # SyntaxError\n" +" ...\n" +"\n" +"T = TypeVar('T')\n" +"\n" +"class Pair(Generic[T, T]): # INVALID\n" +" ..." #: ../../library/typing.rst:606 msgid "Generic classes can also inherit from other classes::" @@ -994,6 +1071,10 @@ msgid "" "class LinkedList[T](Sized):\n" " ..." msgstr "" +"from collections.abc import Sized\n" +"\n" +"class LinkedList[T](Sized):\n" +" ..." #: ../../library/typing.rst:613 msgid "" @@ -1007,6 +1088,10 @@ msgid "" "class MyDict[T](Mapping[str, T]):\n" " ..." msgstr "" +"from collections.abc import Mapping\n" +"\n" +"class MyDict[T](Mapping[str, T]):\n" +" ..." #: ../../library/typing.rst:620 msgid "In this case ``MyDict`` has a single parameter, ``T``." @@ -1064,6 +1149,11 @@ msgid "" "S = TypeVar(\"S\")\n" "Response = Iterable[S] | int" msgstr "" +"from collections.abc import Iterable\n" +"from typing import TypeVar\n" +"\n" +"S = TypeVar(\"S\")\n" +"Response = Iterable[S] | int" #: ../../library/typing.rst:657 msgid ":class:`Generic` no longer has a custom metaclass." diff --git a/library/unittest.mock.po b/library/unittest.mock.po index 0cc1d43f72..fbcb6ac51a 100644 --- a/library/unittest.mock.po +++ b/library/unittest.mock.po @@ -722,7 +722,6 @@ msgid "Setting :attr:`side_effect` to ``None`` clears it:" msgstr "將 :attr:`side_effect` 設定為 ``None`` 可以清除它:" #: ../../library/unittest.mock.rst:639 -#, fuzzy msgid "" "This is either ``None`` (if the mock hasn't been called), or the arguments " "that the mock was last called with. This will be in the form of a tuple: the " @@ -733,7 +732,7 @@ msgid "" msgstr "" "這會是 ``None``\\ (如果 mock 尚未被呼叫),或是 mock 上次被呼叫時使用的引" "數。這將以元組的形式呈現:第一個成員 (member),其可以通過 ``args`` 屬性存取," -"是 mock 被呼叫時傳遞的所有有序引數(或一個空元組)。第二個成員,其可以通過 " +"是 mock 被呼叫時傳遞的所有位置引數(或一個空元組)。第二個成員,其可以通過 " "``kwargs`` 屬性存取,是所有關鍵字引數(或一個空字典)。" #: ../../library/unittest.mock.rst:672 diff --git a/library/unix.po b/library/unix.po index 65090953a2..aa63925485 100644 --- a/library/unix.po +++ b/library/unix.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -20,7 +20,6 @@ msgstr "" "X-Generator: Poedit 3.0.1\n" #: ../../library/unix.rst:5 -#, fuzzy msgid "Unix-specific services" msgstr "Unix 特有服務" diff --git a/library/urllib.request.po b/library/urllib.request.po index fc66a11e9c..b3f58efff7 100644 --- a/library/urllib.request.po +++ b/library/urllib.request.po @@ -1095,7 +1095,6 @@ msgid "the three-digit code of the error, as a string," msgstr "HTTP 錯誤的三位數代號字串," #: ../../library/urllib.request.rst:792 -#, fuzzy msgid "the user-visible explanation of the code, as a string, and" msgstr "HTTP 錯誤代號的使用者可見解釋字串,以及" @@ -1229,11 +1228,11 @@ msgstr "HTTPCookieProcessor 物件" #: ../../library/urllib.request.rst:910 msgid ":class:`HTTPCookieProcessor` instances have one attribute:" -msgstr "" +msgstr ":class:`HTTPCookieProcessor` 實例有一個屬性:" #: ../../library/urllib.request.rst:914 msgid "The :class:`http.cookiejar.CookieJar` in which cookies are stored." -msgstr "" +msgstr "存放 cookies 的 :class:`http.cookiejar.CookieJar`。" #: ../../library/urllib.request.rst:920 msgid "ProxyHandler Objects" @@ -1641,7 +1640,7 @@ msgstr "" #: ../../library/urllib.request.rst:1276 msgid "Use of Basic HTTP Authentication::" -msgstr "" +msgstr "使用基本 HTTP 認證: ::" #: ../../library/urllib.request.rst:1278 msgid "" @@ -1699,11 +1698,11 @@ msgstr "" #: ../../library/urllib.request.rst:1310 msgid "Adding HTTP headers:" -msgstr "" +msgstr "添加 HTTP 標頭:" #: ../../library/urllib.request.rst:1312 msgid "Use the *headers* argument to the :class:`Request` constructor, or::" -msgstr "" +msgstr "使用 :class:`Request` 建構函式的 *headers* 引數,或: ::" #: ../../library/urllib.request.rst:1314 msgid "" @@ -1845,7 +1844,7 @@ msgstr "" #: ../../library/urllib.request.rst:1381 msgid "Legacy interface" -msgstr "" +msgstr "遺留介面" #: ../../library/urllib.request.rst:1383 msgid "" @@ -2091,7 +2090,7 @@ msgstr "" #: ../../library/urllib.request.rst:1556 msgid ":mod:`urllib.request` Restrictions" -msgstr "" +msgstr ":mod:`urllib.request` 限制" #: ../../library/urllib.request.rst:1562 msgid "" @@ -2184,19 +2183,19 @@ msgstr "" #: ../../library/urllib.request.rst:1635 msgid "Status code returned by server." -msgstr "" +msgstr "伺服器回傳的狀態碼。" #: ../../library/urllib.request.rst:1639 msgid "Deprecated in favor of :attr:`~addinfourl.url`." -msgstr "" +msgstr "已被 :attr:`~addinfourl.url` 取代而棄用。" #: ../../library/urllib.request.rst:1644 msgid "Deprecated in favor of :attr:`~addinfourl.headers`." -msgstr "" +msgstr "已被 :attr:`~addinfourl.headers` 取代而棄用。" #: ../../library/urllib.request.rst:1649 ../../library/urllib.request.rst:1654 msgid "Deprecated in favor of :attr:`~addinfourl.status`." -msgstr "" +msgstr "已被 :attr:`~addinfourl.status` 取代而棄用。" #: ../../library/urllib.request.rst:1558 ../../library/urllib.request.rst:1581 msgid "HTTP" @@ -2213,30 +2212,3 @@ msgstr "FTP" #: ../../library/urllib.request.rst:1581 msgid "HTML" msgstr "HTML" - -#~ msgid "" -#~ ">>> import urllib.request\n" -#~ ">>> with urllib.request.urlopen('http://www.python.org/') as f:\n" -#~ "... print(f.read(300))\n" -#~ "...\n" -#~ "b'\\n\\n\\n\\n\\n\\n\n" -#~ "\\n\n" -#~ "Python Programming '" -#~ msgstr "" -#~ ">>> import urllib.request\n" -#~ ">>> with urllib.request.urlopen('http://www.python.org/') as f:\n" -#~ "... print(f.read(300))\n" -#~ "...\n" -#~ "b'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" -#~ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional." -#~ "dtd\">\\n\\n\\n<html\n" -#~ "xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" " -#~ "lang=\"en\">\\n\\n<head>\\n\n" -#~ "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" /" -#~ ">\\n\n" -#~ "<title>Python Programming '" diff --git a/library/warnings.po b/library/warnings.po index 136d899866..8ef84228e9 100644 --- a/library/warnings.po +++ b/library/warnings.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -937,14 +936,13 @@ msgstr "" " lower.one_way(**kw)" #: ../../library/warnings.rst:453 -#, fuzzy msgid "" "This makes the warning refer to both the ``example.lower.one_way()`` and " "``example.higher.another_way()`` call sites only from calling code living " "outside of ``example`` package." msgstr "" "這使得警告只會從存在於 ``example`` 套件之外的呼叫程式碼中,指向 ``example." -"lower.one_way()`` 和 ``package.higher.another_way()`` 的呼叫點。" +"lower.one_way()`` 和 ``example.higher.another_way()`` 的呼叫點。" #: ../../library/warnings.rst:457 ../../library/warnings.rst:483 msgid "" diff --git a/tutorial/appendix.po b/tutorial/appendix.po index 6ffe2d7d8a..3e9e025ca8 100644 --- a/tutorial/appendix.po +++ b/tutorial/appendix.po @@ -39,7 +39,6 @@ msgstr "" "限度的行控制能力(line control capabilities)。" #: ../../tutorial/appendix.rst:17 -#, fuzzy msgid "" "On Windows, or Unix-like systems with :mod:`curses` support, a new " "interactive shell is used by default since Python 3.13. This one supports " @@ -51,7 +50,7 @@ msgid "" "enters \"paste mode\", which makes pasting larger blocks of code easier. " "Press :kbd:`F3` to return to the regular prompt." msgstr "" -"在 Windows 或支援 :mod:`curses` 的類似 Unix 系統上,預設會使用新的互動式 " +"在 Windows 或支援 :mod:`curses` 的類似 Unix 系統上,自 Python 3.13 起預設會使用新的互動式 " "shell。這個 shell 支援顏色、多行編輯、歷史瀏覽和貼上模式。要停用顏色,請參" "閱 :ref:`using-on-controlling-color` 取得詳細資訊。功能鍵提供了一些額外的功" "能。:kbd:`F1` 進入互動式幫助瀏覽器 :mod:`pydoc`。:kbd:`F2` 允許瀏覽命令列歷" diff --git a/tutorial/classes.po b/tutorial/classes.po index 09a3b5bd12..690c297ae2 100644 --- a/tutorial/classes.po +++ b/tutorial/classes.po @@ -721,14 +721,13 @@ msgid "x.f()" msgstr "x.f()" #: ../../tutorial/classes.rst:362 -#, fuzzy msgid "" "If ``x = MyClass()``, as above, this will return the string ``'hello " "world'``. However, it is not necessary to call a method right away: ``x.f`` " "is a method object, and can be stored away and called at a later time. For " "example::" msgstr "" -"在 :class:`!MyClass` 的例子中,這將回傳字串 ``'hello world'``。然而,並沒有必" +"如果像上面一樣 ``x = MyClass()``,這將回傳字串 ``'hello world'``。然而,並沒有必" "要立即呼叫一個 method:``x.f`` 是一個 method 物件,並且可以被儲藏起來,之後再" "被呼叫。舉例來說: ::" From 3510f0efc65cf9e095c44ed202e870c33458b1cc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 14:10:28 +0000 Subject: [PATCH 23/23] sync with cpython ab8ffc48 --- using/ios.po | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/using/ios.po b/using/ios.po index cd97f600af..a06a0fc031 100644 --- a/using/ios.po +++ b/using/ios.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-22 14:09+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -622,11 +622,28 @@ msgstr "" msgid "This will allow you to use the full Xcode suite of tools for debugging." msgstr "" -#: ../../using/ios.rst:376 +#: ../../using/ios.rst:375 +msgid "" +"The arguments used to run the test suite are defined as part of the test " +"plan. To modify the test plan, select the test plan node of the project tree " +"(it should be the first child of the root node), and select the " +"\"Configurations\" tab. Modify the \"Arguments Passed On Launch\" value to " +"change the testing arguments." +msgstr "" + +#: ../../using/ios.rst:381 +msgid "" +"The test plan also disables parallel testing, and specifies the use of the " +"``iOSTestbed.lldbinit`` file for providing configuration of the debugger. " +"The default debugger configuration disables automatic breakpoints on the " +"``SIGINT``, ``SIGUSR1``, ``SIGUSR2``, and ``SIGXFSZ`` signals." +msgstr "" + +#: ../../using/ios.rst:387 msgid "App Store Compliance" msgstr "" -#: ../../using/ios.rst:378 +#: ../../using/ios.rst:389 msgid "" "The only mechanism for distributing apps to third-party iOS devices is to " "submit the app to the iOS App Store; apps submitted for distribution must " @@ -635,7 +652,7 @@ msgid "" "problematic code." msgstr "" -#: ../../using/ios.rst:383 +#: ../../using/ios.rst:394 msgid "" "The Python standard library contains some code that is known to violate " "these automated rules. While these violations appear to be false positives, " @@ -643,7 +660,7 @@ msgid "" "Python standard library for an app to pass App Store review." msgstr "" -#: ../../using/ios.rst:388 +#: ../../using/ios.rst:399 msgid "" "The Python source tree contains :source:`a patch file <Mac/Resources/app-" "store-compliance.patch>` that will remove all code that is known to cause "